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