Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(951)

Side by Side Diff: content/browser/tab_contents/navigation_entry_impl.cc

Issue 8956059: Rename NavigationController to NavigationControllerImpl and put it into the content namespace. Al... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/tab_contents/navigation_entry.h" 5 #include "content/browser/tab_contents/navigation_entry_impl.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "content/browser/site_instance.h" 9 #include "content/browser/site_instance.h"
10 #include "content/public/common/content_constants.h" 10 #include "content/public/common/content_constants.h"
11 #include "content/public/common/url_constants.h" 11 #include "content/public/common/url_constants.h"
12 #include "net/base/net_util.h" 12 #include "net/base/net_util.h"
13 #include "ui/base/text/text_elider.h" 13 #include "ui/base/text/text_elider.h"
14 14
15 using content::FaviconStatus;
16 using content::SSLStatus;
17
18 // Use this to get a new unique ID for a NavigationEntry during construction. 15 // Use this to get a new unique ID for a NavigationEntry during construction.
19 // The returned ID is guaranteed to be nonzero (which is the "no ID" indicator). 16 // The returned ID is guaranteed to be nonzero (which is the "no ID" indicator).
20 static int GetUniqueIDInConstructor() { 17 static int GetUniqueIDInConstructor() {
21 static int unique_id_counter = 0; 18 static int unique_id_counter = 0;
22 return ++unique_id_counter; 19 return ++unique_id_counter;
23 } 20 }
24 21
25 namespace content { 22 namespace content {
26 23
27 NavigationEntry* NavigationEntry::Create() { 24 NavigationEntry* NavigationEntry::Create() {
28 return new ::NavigationEntry(); 25 return new NavigationEntryImpl();
29 } 26 }
30 27
31 NavigationEntry* NavigationEntry::Create(const NavigationEntry& copy) { 28 NavigationEntry* NavigationEntry::Create(const NavigationEntry& copy) {
32 return new ::NavigationEntry(static_cast<const ::NavigationEntry&>(copy)); 29 return new NavigationEntryImpl(static_cast<const NavigationEntryImpl&>(copy));
33 } 30 }
34 31
32 NavigationEntryImpl* NavigationEntryImpl::FromNavigationEntry(
33 NavigationEntry* entry) {
34 return static_cast<NavigationEntryImpl*>(entry);
35 } 35 }
36 36
37 NavigationEntry* NavigationEntry::FromNavigationEntry( 37 NavigationEntryImpl::NavigationEntryImpl()
38 content::NavigationEntry* entry) {
39 return static_cast<NavigationEntry*>(entry);
40 }
41
42 NavigationEntry::NavigationEntry()
43 : unique_id_(GetUniqueIDInConstructor()), 38 : unique_id_(GetUniqueIDInConstructor()),
44 site_instance_(NULL), 39 site_instance_(NULL),
45 page_type_(content::PAGE_TYPE_NORMAL), 40 page_type_(PAGE_TYPE_NORMAL),
46 update_virtual_url_with_url_(false), 41 update_virtual_url_with_url_(false),
47 page_id_(-1), 42 page_id_(-1),
48 transition_type_(content::PAGE_TRANSITION_LINK), 43 transition_type_(PAGE_TRANSITION_LINK),
49 has_post_data_(false), 44 has_post_data_(false),
50 restore_type_(RESTORE_NONE), 45 restore_type_(RESTORE_NONE),
51 is_renderer_initiated_(false) { 46 is_renderer_initiated_(false) {
52 } 47 }
53 48
54 NavigationEntry::NavigationEntry(SiteInstance* instance, 49 NavigationEntryImpl::NavigationEntryImpl(SiteInstance* instance,
55 int page_id, 50 int page_id,
56 const GURL& url, 51 const GURL& url,
57 const content::Referrer& referrer, 52 const Referrer& referrer,
58 const string16& title, 53 const string16& title,
59 content::PageTransition transition_type, 54 PageTransition transition_type,
60 bool is_renderer_initiated) 55 bool is_renderer_initiated)
61 : unique_id_(GetUniqueIDInConstructor()), 56 : unique_id_(GetUniqueIDInConstructor()),
62 site_instance_(instance), 57 site_instance_(instance),
63 page_type_(content::PAGE_TYPE_NORMAL), 58 page_type_(PAGE_TYPE_NORMAL),
64 url_(url), 59 url_(url),
65 referrer_(referrer), 60 referrer_(referrer),
66 update_virtual_url_with_url_(false), 61 update_virtual_url_with_url_(false),
67 title_(title), 62 title_(title),
68 page_id_(page_id), 63 page_id_(page_id),
69 transition_type_(transition_type), 64 transition_type_(transition_type),
70 has_post_data_(false), 65 has_post_data_(false),
71 restore_type_(RESTORE_NONE), 66 restore_type_(RESTORE_NONE),
72 is_renderer_initiated_(is_renderer_initiated) { 67 is_renderer_initiated_(is_renderer_initiated) {
73 } 68 }
74 69
75 NavigationEntry::~NavigationEntry() { 70 NavigationEntryImpl::~NavigationEntryImpl() {
76 } 71 }
77 72
78 int NavigationEntry::GetUniqueID() const { 73 int NavigationEntryImpl::GetUniqueID() const {
79 return unique_id_; 74 return unique_id_;
80 } 75 }
81 76
82 content::PageType NavigationEntry::GetPageType() const { 77 PageType NavigationEntryImpl::GetPageType() const {
83 return page_type_; 78 return page_type_;
84 } 79 }
85 80
86 void NavigationEntry::SetURL(const GURL& url) { 81 void NavigationEntryImpl::SetURL(const GURL& url) {
87 url_ = url; 82 url_ = url;
88 cached_display_title_.clear(); 83 cached_display_title_.clear();
89 } 84 }
90 85
91 const GURL& NavigationEntry::GetURL() const { 86 const GURL& NavigationEntryImpl::GetURL() const {
92 return url_; 87 return url_;
93 } 88 }
94 89
95 void NavigationEntry::SetReferrer(const content::Referrer& referrer) { 90 void NavigationEntryImpl::SetReferrer(const Referrer& referrer) {
96 referrer_ = referrer; 91 referrer_ = referrer;
97 } 92 }
98 93
99 const content::Referrer& NavigationEntry::GetReferrer() const { 94 const Referrer& NavigationEntryImpl::GetReferrer() const {
100 return referrer_; 95 return referrer_;
101 } 96 }
102 97
103 void NavigationEntry::SetVirtualURL(const GURL& url) { 98 void NavigationEntryImpl::SetVirtualURL(const GURL& url) {
104 virtual_url_ = (url == url_) ? GURL() : url; 99 virtual_url_ = (url == url_) ? GURL() : url;
105 cached_display_title_.clear(); 100 cached_display_title_.clear();
106 } 101 }
107 102
108 const GURL& NavigationEntry::GetVirtualURL() const { 103 const GURL& NavigationEntryImpl::GetVirtualURL() const {
109 return virtual_url_.is_empty() ? url_ : virtual_url_; 104 return virtual_url_.is_empty() ? url_ : virtual_url_;
110 } 105 }
111 106
112 void NavigationEntry::SetTitle(const string16& title) { 107 void NavigationEntryImpl::SetTitle(const string16& title) {
113 title_ = title; 108 title_ = title;
114 cached_display_title_.clear(); 109 cached_display_title_.clear();
115 } 110 }
116 111
117 const string16& NavigationEntry::GetTitle() const { 112 const string16& NavigationEntryImpl::GetTitle() const {
118 return title_; 113 return title_;
119 } 114 }
120 115
121 void NavigationEntry::SetContentState(const std::string& state) { 116 void NavigationEntryImpl::SetContentState(const std::string& state) {
122 content_state_ = state; 117 content_state_ = state;
123 } 118 }
124 119
125 const std::string& NavigationEntry::GetContentState() const { 120 const std::string& NavigationEntryImpl::GetContentState() const {
126 return content_state_; 121 return content_state_;
127 } 122 }
128 123
129 void NavigationEntry::SetPageID(int page_id) { 124 void NavigationEntryImpl::SetPageID(int page_id) {
130 page_id_ = page_id; 125 page_id_ = page_id;
131 } 126 }
132 127
133 int32 NavigationEntry::GetPageID() const { 128 int32 NavigationEntryImpl::GetPageID() const {
134 return page_id_; 129 return page_id_;
135 } 130 }
136 131
137 void NavigationEntry::set_site_instance(SiteInstance* site_instance) { 132 void NavigationEntryImpl::set_site_instance(SiteInstance* site_instance) {
138 site_instance_ = site_instance; 133 site_instance_ = site_instance;
139 } 134 }
140 135
141 const string16& NavigationEntry::GetTitleForDisplay( 136 const string16& NavigationEntryImpl::GetTitleForDisplay(
142 const std::string& languages) const { 137 const std::string& languages) const {
143 // Most pages have real titles. Don't even bother caching anything if this is 138 // Most pages have real titles. Don't even bother caching anything if this is
144 // the case. 139 // the case.
145 if (!title_.empty()) 140 if (!title_.empty())
146 return title_; 141 return title_;
147 142
148 // More complicated cases will use the URLs as the title. This result we will 143 // More complicated cases will use the URLs as the title. This result we will
149 // cache since it's more complicated to compute. 144 // cache since it's more complicated to compute.
150 if (!cached_display_title_.empty()) 145 if (!cached_display_title_.empty())
151 return cached_display_title_; 146 return cached_display_title_;
152 147
153 // Use the virtual URL first if any, and fall back on using the real URL. 148 // Use the virtual URL first if any, and fall back on using the real URL.
154 string16 title; 149 string16 title;
155 if (!virtual_url_.is_empty()) { 150 if (!virtual_url_.is_empty()) {
156 title = net::FormatUrl(virtual_url_, languages); 151 title = net::FormatUrl(virtual_url_, languages);
157 } else if (!url_.is_empty()) { 152 } else if (!url_.is_empty()) {
158 title = net::FormatUrl(url_, languages); 153 title = net::FormatUrl(url_, languages);
159 } 154 }
160 155
161 // For file:// URLs use the filename as the title, not the full path. 156 // For file:// URLs use the filename as the title, not the full path.
162 if (url_.SchemeIsFile()) { 157 if (url_.SchemeIsFile()) {
163 string16::size_type slashpos = title.rfind('/'); 158 string16::size_type slashpos = title.rfind('/');
164 if (slashpos != string16::npos) 159 if (slashpos != string16::npos)
165 title = title.substr(slashpos + 1); 160 title = title.substr(slashpos + 1);
166 } 161 }
167 162
168 ui::ElideString(title, content::kMaxTitleChars, &cached_display_title_); 163 ui::ElideString(title, kMaxTitleChars, &cached_display_title_);
169 return cached_display_title_; 164 return cached_display_title_;
170 } 165 }
171 166
172 bool NavigationEntry::IsViewSourceMode() const { 167 bool NavigationEntryImpl::IsViewSourceMode() const {
173 return virtual_url_.SchemeIs(chrome::kViewSourceScheme); 168 return virtual_url_.SchemeIs(chrome::kViewSourceScheme);
174 } 169 }
175 170
176 void NavigationEntry::SetTransitionType( 171 void NavigationEntryImpl::SetTransitionType(
177 content::PageTransition transition_type) { 172 PageTransition transition_type) {
178 transition_type_ = transition_type; 173 transition_type_ = transition_type;
179 } 174 }
180 175
181 content::PageTransition NavigationEntry::GetTransitionType() const { 176 PageTransition NavigationEntryImpl::GetTransitionType() const {
182 return transition_type_; 177 return transition_type_;
183 } 178 }
184 179
185 const GURL& NavigationEntry::GetUserTypedURL() const { 180 const GURL& NavigationEntryImpl::GetUserTypedURL() const {
186 return user_typed_url_; 181 return user_typed_url_;
187 } 182 }
188 183
189 void NavigationEntry::SetHasPostData(bool has_post_data) { 184 void NavigationEntryImpl::SetHasPostData(bool has_post_data) {
190 has_post_data_ = has_post_data; 185 has_post_data_ = has_post_data;
191 } 186 }
192 187
193 bool NavigationEntry::GetHasPostData() const { 188 bool NavigationEntryImpl::GetHasPostData() const {
194 return has_post_data_; 189 return has_post_data_;
195 } 190 }
196 191
197 const FaviconStatus& NavigationEntry::GetFavicon() const { 192 const FaviconStatus& NavigationEntryImpl::GetFavicon() const {
198 return favicon_; 193 return favicon_;
199 } 194 }
200 195
201 FaviconStatus& NavigationEntry::GetFavicon() { 196 FaviconStatus& NavigationEntryImpl::GetFavicon() {
202 return favicon_; 197 return favicon_;
203 } 198 }
204 199
205 const SSLStatus& NavigationEntry::GetSSL() const { 200 const SSLStatus& NavigationEntryImpl::GetSSL() const {
206 return ssl_; 201 return ssl_;
207 } 202 }
208 203
209 SSLStatus& NavigationEntry::GetSSL() { 204 SSLStatus& NavigationEntryImpl::GetSSL() {
210 return ssl_; 205 return ssl_;
211 } 206 }
207
208 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/tab_contents/navigation_entry_impl.h ('k') | content/browser/tab_contents/navigation_entry_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698