license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame^] | 1 | // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
| 5 | #include "chrome/browser/navigation_entry.h" |
| 6 | |
| 7 | #include "chrome/common/resource_bundle.h" |
| 8 | |
| 9 | int NavigationEntry::unique_id_counter_ = 0; |
| 10 | |
[email protected] | eb34392b | 2008-08-19 15:42:20 | [diff] [blame] | 11 | NavigationEntry::SSLStatus::SSLStatus() |
| 12 | : security_style_(SECURITY_STYLE_UNKNOWN), |
| 13 | cert_id_(0), |
| 14 | cert_status_(0), |
| 15 | security_bits_(-1), |
| 16 | content_status_(NORMAL_CONTENT) { |
| 17 | } |
| 18 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 19 | NavigationEntry::NavigationEntry(TabContentsType type) |
| 20 | : type_(type), |
| 21 | unique_id_(GetUniqueID()), |
| 22 | site_instance_(NULL), |
| 23 | page_id_(-1), |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 24 | transition_type_(PageTransition::LINK), |
| 25 | page_type_(NORMAL_PAGE), |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 26 | valid_fav_icon_(false), |
| 27 | has_post_data_(false), |
| 28 | restored_(false) { |
| 29 | ResourceBundle &rb = ResourceBundle::GetSharedInstance(); |
| 30 | favicon_ = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); |
| 31 | } |
| 32 | |
| 33 | NavigationEntry::NavigationEntry(TabContentsType type, |
| 34 | SiteInstance* instance, |
| 35 | int page_id, |
| 36 | const GURL& url, |
| 37 | const std::wstring& title, |
| 38 | PageTransition::Type transition_type) |
| 39 | : type_(type), |
| 40 | unique_id_(GetUniqueID()), |
| 41 | site_instance_(instance), |
| 42 | page_id_(page_id), |
| 43 | url_(url), |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 44 | title_(title), |
| 45 | transition_type_(transition_type), |
| 46 | page_type_(NORMAL_PAGE), |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 47 | valid_fav_icon_(false), |
| 48 | has_post_data_(false), |
| 49 | restored_(false) { |
| 50 | ResourceBundle &rb = ResourceBundle::GetSharedInstance(); |
| 51 | favicon_ = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); |
| 52 | } |
| 53 | |
| 54 | |
| 55 | void NavigationEntry::SetSiteInstance(SiteInstance* site_instance) { |
| 56 | // Note that the SiteInstance should usually not be changed after it is set, |
| 57 | // but this may happen if the NavigationEntry was cloned and needs to use a |
| 58 | // different SiteInstance. |
| 59 | |
| 60 | if (site_instance_ == site_instance) { |
| 61 | // No change necessary. |
| 62 | return; |
| 63 | } |
| 64 | |
| 65 | // The ref counting is handled automatically, since these are scoped_refptrs. |
| 66 | site_instance_ = site_instance; |
| 67 | } |
| 68 | |
| 69 | void NavigationEntry::SetContentState(const std::string& state) { |
| 70 | state_ = state; |
| 71 | } |
| 72 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 73 | int NavigationEntry::GetUniqueID() { |
| 74 | // Never return 0, as that is the "no ID" value. |
| 75 | do { |
| 76 | ++unique_id_counter_; |
| 77 | } while (!unique_id_counter_); |
| 78 | return unique_id_counter_; |
| 79 | } |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame^] | 80 | |