OLD | NEW |
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 #ifndef CONTENT_BROWSER_TAB_CONTENTS_NAVIGATION_ENTRY_H_ | 5 #ifndef CONTENT_BROWSER_TAB_CONTENTS_NAVIGATION_ENTRY_H_ |
6 #define CONTENT_BROWSER_TAB_CONTENTS_NAVIGATION_ENTRY_H_ | 6 #define CONTENT_BROWSER_TAB_CONTENTS_NAVIGATION_ENTRY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 // Copy and assignment is explicitly allowed for this class. | 177 // Copy and assignment is explicitly allowed for this class. |
178 }; | 178 }; |
179 | 179 |
180 // --------------------------------------------------------------------------- | 180 // --------------------------------------------------------------------------- |
181 | 181 |
182 NavigationEntry(); | 182 NavigationEntry(); |
183 NavigationEntry(SiteInstance* instance, | 183 NavigationEntry(SiteInstance* instance, |
184 int page_id, | 184 int page_id, |
185 const GURL& url, | 185 const GURL& url, |
186 const GURL& referrer, | 186 const GURL& referrer, |
187 const string16& title, | 187 const base::i18n::String16WithDirection& title, |
188 PageTransition::Type transition_type); | 188 PageTransition::Type transition_type); |
189 ~NavigationEntry(); | 189 ~NavigationEntry(); |
190 | 190 |
191 // Page-related stuff -------------------------------------------------------- | 191 // Page-related stuff -------------------------------------------------------- |
192 | 192 |
193 // A unique ID is preserved across commits and redirects, which means that | 193 // A unique ID is preserved across commits and redirects, which means that |
194 // sometimes a NavigationEntry's unique ID needs to be set (e.g. when | 194 // sometimes a NavigationEntry's unique ID needs to be set (e.g. when |
195 // creating a committed entry to correspond to a to-be-deleted pending entry, | 195 // creating a committed entry to correspond to a to-be-deleted pending entry, |
196 // the pending entry's ID must be copied). | 196 // the pending entry's ID must be copied). |
197 void set_unique_id(int unique_id) { | 197 void set_unique_id(int unique_id) { |
(...skipping 22 matching lines...) Expand all Loading... |
220 } | 220 } |
221 PageType page_type() const { | 221 PageType page_type() const { |
222 return page_type_; | 222 return page_type_; |
223 } | 223 } |
224 | 224 |
225 // The actual URL of the page. For some about pages, this may be a scary | 225 // The actual URL of the page. For some about pages, this may be a scary |
226 // data: URL or something like that. Use virtual_url() below for showing to | 226 // data: URL or something like that. Use virtual_url() below for showing to |
227 // the user. | 227 // the user. |
228 void set_url(const GURL& url) { | 228 void set_url(const GURL& url) { |
229 url_ = url; | 229 url_ = url; |
230 cached_display_title_.clear(); | 230 cached_display_title_ = base::i18n::String16WithDirection(); |
231 } | 231 } |
232 const GURL& url() const { | 232 const GURL& url() const { |
233 return url_; | 233 return url_; |
234 } | 234 } |
235 | 235 |
236 // The referring URL. Can be empty. | 236 // The referring URL. Can be empty. |
237 void set_referrer(const GURL& referrer) { | 237 void set_referrer(const GURL& referrer) { |
238 referrer_ = referrer; | 238 referrer_ = referrer; |
239 } | 239 } |
240 const GURL& referrer() const { | 240 const GURL& referrer() const { |
241 return referrer_; | 241 return referrer_; |
242 } | 242 } |
243 | 243 |
244 // The virtual URL, when nonempty, will override the actual URL of the page | 244 // The virtual URL, when nonempty, will override the actual URL of the page |
245 // when we display it to the user. This allows us to have nice and friendly | 245 // when we display it to the user. This allows us to have nice and friendly |
246 // URLs that the user sees for things like about: URLs, but actually feed | 246 // URLs that the user sees for things like about: URLs, but actually feed |
247 // the renderer a data URL that results in the content loading. | 247 // the renderer a data URL that results in the content loading. |
248 // | 248 // |
249 // virtual_url() will return the URL to display to the user in all cases, so | 249 // virtual_url() will return the URL to display to the user in all cases, so |
250 // if there is no overridden display URL, it will return the actual one. | 250 // if there is no overridden display URL, it will return the actual one. |
251 void set_virtual_url(const GURL& url) { | 251 void set_virtual_url(const GURL& url) { |
252 virtual_url_ = (url == url_) ? GURL() : url; | 252 virtual_url_ = (url == url_) ? GURL() : url; |
253 cached_display_title_.clear(); | 253 cached_display_title_ = base::i18n::String16WithDirection(); |
254 } | 254 } |
255 bool has_virtual_url() const { | 255 bool has_virtual_url() const { |
256 return !virtual_url_.is_empty(); | 256 return !virtual_url_.is_empty(); |
257 } | 257 } |
258 const GURL& virtual_url() const { | 258 const GURL& virtual_url() const { |
259 return virtual_url_.is_empty() ? url_ : virtual_url_; | 259 return virtual_url_.is_empty() ? url_ : virtual_url_; |
260 } | 260 } |
261 | 261 |
262 bool update_virtual_url_with_url() const { | 262 bool update_virtual_url_with_url() const { |
263 return update_virtual_url_with_url_; | 263 return update_virtual_url_with_url_; |
264 } | 264 } |
265 void set_update_virtual_url_with_url(bool update) { | 265 void set_update_virtual_url_with_url(bool update) { |
266 update_virtual_url_with_url_ = update; | 266 update_virtual_url_with_url_ = update; |
267 } | 267 } |
268 | 268 |
269 // The title as set by the page. This will be empty if there is no title set. | 269 // The title as set by the page. This will be empty if there is no title set. |
270 // The caller is responsible for detecting when there is no title and | 270 // The caller is responsible for detecting when there is no title and |
271 // displaying the appropriate "Untitled" label if this is being displayed to | 271 // displaying the appropriate "Untitled" label if this is being displayed to |
272 // the user. | 272 // the user. |
273 void set_title(const base::i18n::String16WithDirection& title) { | 273 void set_title(const base::i18n::String16WithDirection& title) { |
274 set_title(title.string()); | 274 title_ = title; |
| 275 cached_display_title_ = base::i18n::String16WithDirection(); |
275 } | 276 } |
276 // TODO(evan): remove the string16-setter once callers are updated. | 277 const base::i18n::String16WithDirection& title() const { |
277 // http://code.google.com/p/chromium/issues/detail?id=27094 | |
278 void set_title(const string16& title) { | |
279 title_ = title; | |
280 cached_display_title_.clear(); | |
281 } | |
282 const string16& title() const { | |
283 return title_; | 278 return title_; |
284 } | 279 } |
285 | 280 |
286 // The favicon data and tracking information. See FaviconStatus above. | 281 // The favicon data and tracking information. See FaviconStatus above. |
287 const FaviconStatus& favicon() const { | 282 const FaviconStatus& favicon() const { |
288 return favicon_; | 283 return favicon_; |
289 } | 284 } |
290 FaviconStatus& favicon() { | 285 FaviconStatus& favicon() { |
291 return favicon_; | 286 return favicon_; |
292 } | 287 } |
(...skipping 30 matching lines...) Expand all Loading... |
323 SSLStatus& ssl() { | 318 SSLStatus& ssl() { |
324 return ssl_; | 319 return ssl_; |
325 } | 320 } |
326 | 321 |
327 // Page-related helpers ------------------------------------------------------ | 322 // Page-related helpers ------------------------------------------------------ |
328 | 323 |
329 // Returns the title to be displayed on the tab. This could be the title of | 324 // Returns the title to be displayed on the tab. This could be the title of |
330 // the page if it is available or the URL. |languages| is the list of | 325 // the page if it is available or the URL. |languages| is the list of |
331 // accpeted languages (e.g., prefs::kAcceptLanguages) or empty if proper | 326 // accpeted languages (e.g., prefs::kAcceptLanguages) or empty if proper |
332 // URL formatting isn't needed (e.g., unit tests). | 327 // URL formatting isn't needed (e.g., unit tests). |
333 const string16& GetTitleForDisplay(const std::string& languages); | 328 const base::i18n::String16WithDirection& GetTitleForDisplay( |
| 329 const std::string& languages); |
334 | 330 |
335 // Returns true if the current tab is in view source mode. This will be false | 331 // Returns true if the current tab is in view source mode. This will be false |
336 // if there is no navigation. | 332 // if there is no navigation. |
337 bool IsViewSourceMode() const; | 333 bool IsViewSourceMode() const; |
338 | 334 |
339 // Tracking stuff ------------------------------------------------------------ | 335 // Tracking stuff ------------------------------------------------------------ |
340 | 336 |
341 // The transition type indicates what the user did to move to this page from | 337 // The transition type indicates what the user did to move to this page from |
342 // the previous page. | 338 // the previous page. |
343 void set_transition_type(PageTransition::Type transition_type) { | 339 void set_transition_type(PageTransition::Type transition_type) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING | 402 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING |
407 | 403 |
408 // See the accessors above for descriptions. | 404 // See the accessors above for descriptions. |
409 int unique_id_; | 405 int unique_id_; |
410 scoped_refptr<SiteInstance> site_instance_; | 406 scoped_refptr<SiteInstance> site_instance_; |
411 PageType page_type_; | 407 PageType page_type_; |
412 GURL url_; | 408 GURL url_; |
413 GURL referrer_; | 409 GURL referrer_; |
414 GURL virtual_url_; | 410 GURL virtual_url_; |
415 bool update_virtual_url_with_url_; | 411 bool update_virtual_url_with_url_; |
416 string16 title_; | 412 base::i18n::String16WithDirection title_; |
417 FaviconStatus favicon_; | 413 FaviconStatus favicon_; |
418 std::string content_state_; | 414 std::string content_state_; |
419 int32 page_id_; | 415 int32 page_id_; |
420 SSLStatus ssl_; | 416 SSLStatus ssl_; |
421 PageTransition::Type transition_type_; | 417 PageTransition::Type transition_type_; |
422 GURL user_typed_url_; | 418 GURL user_typed_url_; |
423 bool has_post_data_; | 419 bool has_post_data_; |
424 RestoreType restore_type_; | 420 RestoreType restore_type_; |
425 | 421 |
426 // This is a cached version of the result of GetTitleForDisplay. It prevents | 422 // This is a cached version of the result of GetTitleForDisplay. It prevents |
427 // us from having to do URL formatting on the URL evey time the title is | 423 // us from having to do URL formatting on the URL evey time the title is |
428 // displayed. When the URL, virtual URL, or title is set, this should be | 424 // displayed. When the URL, virtual URL, or title is set, this should be |
429 // cleared to force a refresh. | 425 // cleared to force a refresh. |
430 string16 cached_display_title_; | 426 base::i18n::String16WithDirection cached_display_title_; |
431 | 427 |
432 // Copy and assignment is explicitly allowed for this class. | 428 // Copy and assignment is explicitly allowed for this class. |
433 }; | 429 }; |
434 | 430 |
435 #endif // CONTENT_BROWSER_TAB_CONTENTS_NAVIGATION_ENTRY_H_ | 431 #endif // CONTENT_BROWSER_TAB_CONTENTS_NAVIGATION_ENTRY_H_ |
OLD | NEW |