blob: 8a1170cfbfa13b933a5835b209f807e360ea59ef [file] [log] [blame]
license.botbf09a502008-08-24 00:55:551// 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.commit09911bf2008-07-26 23:55:294
5#include "chrome/browser/navigation_entry.h"
6
7#include "chrome/common/resource_bundle.h"
8
9int NavigationEntry::unique_id_counter_ = 0;
10
[email protected]eb34392b2008-08-19 15:42:2011NavigationEntry::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.commit09911bf2008-07-26 23:55:2919NavigationEntry::NavigationEntry(TabContentsType type)
20 : type_(type),
21 unique_id_(GetUniqueID()),
22 site_instance_(NULL),
23 page_id_(-1),
initial.commit09911bf2008-07-26 23:55:2924 transition_type_(PageTransition::LINK),
25 page_type_(NORMAL_PAGE),
initial.commit09911bf2008-07-26 23:55:2926 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
33NavigationEntry::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.commit09911bf2008-07-26 23:55:2944 title_(title),
45 transition_type_(transition_type),
46 page_type_(NORMAL_PAGE),
initial.commit09911bf2008-07-26 23:55:2947 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
55void 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
69void NavigationEntry::SetContentState(const std::string& state) {
70 state_ = state;
71}
72
initial.commit09911bf2008-07-26 23:55:2973int 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.botbf09a502008-08-24 00:55:5580