diff options
author | dfalcantara@chromium.org <dfalcantara@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-11 22:03:11 +0000 |
---|---|---|
committer | dfalcantara@chromium.org <dfalcantara@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-11 22:03:11 +0000 |
commit | 86ef6a39b9c3cd564472d23a38e602dd4e8e39d7 (patch) | |
tree | c69c8e4c94595ee108b5bcf9ec8c99eee372ef68 /content/browser | |
parent | 0a72b2f71b8bac679a2de93bfe09ecf952fdb712 (diff) | |
download | chromium_src-86ef6a39b9c3cd564472d23a38e602dd4e8e39d7.zip chromium_src-86ef6a39b9c3cd564472d23a38e602dd4e8e39d7.tar.gz chromium_src-86ef6a39b9c3cd564472d23a38e602dd4e8e39d7.tar.bz2 |
Add info about user agent overrides to WebContents
* NavigationEntries store booleans indicating whether they should be using
an overridden user agent instead of the regular one.
* WebContents stores a user agent override string that will (in a later CL)
be sent to the renderer whenever the user agent needs to be overridden
for a navigation entry.
* Adds the requisite framework for saving and restoring this data from disk.
Part of upstreaming b/5119921, tracked in b/6272286
BUG=112923
Review URL: https://chromiumcodereview.appspot.com/10170016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136683 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
5 files changed, 33 insertions, 0 deletions
diff --git a/content/browser/web_contents/navigation_entry_impl.cc b/content/browser/web_contents/navigation_entry_impl.cc index 15ac9cb..8c8bbbb 100644 --- a/content/browser/web_contents/navigation_entry_impl.cc +++ b/content/browser/web_contents/navigation_entry_impl.cc @@ -45,6 +45,7 @@ NavigationEntryImpl::NavigationEntryImpl() has_post_data_(false), post_id_(-1), restore_type_(RESTORE_NONE), + is_overriding_user_agent_(false), is_renderer_initiated_(false), is_cross_site_reload_(false) { } @@ -68,6 +69,7 @@ NavigationEntryImpl::NavigationEntryImpl(SiteInstanceImpl* instance, has_post_data_(false), post_id_(-1), restore_type_(RESTORE_NONE), + is_overriding_user_agent_(false), is_renderer_initiated_(is_renderer_initiated), is_cross_site_reload_(false) { } @@ -226,4 +228,12 @@ const GURL& NavigationEntryImpl::GetOriginalRequestURL() const { return original_request_url_; } +void NavigationEntryImpl::SetIsOverridingUserAgent(bool override) { + is_overriding_user_agent_ = override; +} + +bool NavigationEntryImpl::GetIsOverridingUserAgent() const { + return is_overriding_user_agent_; +} + } // namespace content diff --git a/content/browser/web_contents/navigation_entry_impl.h b/content/browser/web_contents/navigation_entry_impl.h index 391ff00..88d8992 100644 --- a/content/browser/web_contents/navigation_entry_impl.h +++ b/content/browser/web_contents/navigation_entry_impl.h @@ -62,6 +62,8 @@ class CONTENT_EXPORT NavigationEntryImpl virtual SSLStatus& GetSSL() OVERRIDE; virtual void SetOriginalRequestURL(const GURL& original_url) OVERRIDE; virtual const GURL& GetOriginalRequestURL() const OVERRIDE; + virtual void SetIsOverridingUserAgent(bool override) OVERRIDE; + virtual bool GetIsOverridingUserAgent() const OVERRIDE; void set_unique_id(int unique_id) { unique_id_ = unique_id; @@ -180,6 +182,7 @@ class CONTENT_EXPORT NavigationEntryImpl int64 post_id_; RestoreType restore_type_; GURL original_request_url_; + bool is_overriding_user_agent_; // This member is not persisted with sesssion restore. std::string extra_headers_; diff --git a/content/browser/web_contents/navigation_entry_impl_unittest.cc b/content/browser/web_contents/navigation_entry_impl_unittest.cc index bb46c8e..055a0cd 100644 --- a/content/browser/web_contents/navigation_entry_impl_unittest.cc +++ b/content/browser/web_contents/navigation_entry_impl_unittest.cc @@ -179,6 +179,12 @@ TEST_F(NavigationEntryTest, NavigationEntryAccessors) { EXPECT_EQ(GURL(), entry2_.get()->GetOriginalRequestURL()); entry2_.get()->SetOriginalRequestURL(GURL("original_url")); EXPECT_EQ(GURL("original_url"), entry2_.get()->GetOriginalRequestURL()); + + // User agent override + EXPECT_FALSE(entry1_.get()->GetIsOverridingUserAgent()); + EXPECT_FALSE(entry2_.get()->GetIsOverridingUserAgent()); + entry2_.get()->SetIsOverridingUserAgent(true); + EXPECT_TRUE(entry2_.get()->GetIsOverridingUserAgent()); } } // namespace content diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 2aba4bc..558fa45 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -707,6 +707,14 @@ content::WebUI* WebContentsImpl::GetCommittedWebUI() const { return render_manager_.web_ui(); } +void WebContentsImpl::SetUserAgentOverride(const std::string& override) { + user_agent_override_ = override; +} + +const std::string& WebContentsImpl::GetUserAgentOverride() const { + return user_agent_override_; +} + const string16& WebContentsImpl::GetTitle() const { // Transient entries take precedence. They are used for interstitial pages // that are shown on top of existing pages. diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h index 934ad7a5..5ed6325 100644 --- a/content/browser/web_contents/web_contents_impl.h +++ b/content/browser/web_contents/web_contents_impl.h @@ -153,6 +153,8 @@ class CONTENT_EXPORT WebContentsImpl virtual content::WebUI* CreateWebUI(const GURL& url) OVERRIDE; virtual content::WebUI* GetWebUI() const OVERRIDE; virtual content::WebUI* GetCommittedWebUI() const OVERRIDE; + virtual void SetUserAgentOverride(const std::string& override) OVERRIDE; + virtual const std::string& GetUserAgentOverride() const OVERRIDE; virtual const string16& GetTitle() const OVERRIDE; virtual int32 GetMaxPageID() OVERRIDE; virtual int32 GetMaxPageIDForSiteInstance( @@ -578,6 +580,10 @@ class CONTENT_EXPORT WebContentsImpl // is closed. WebContentsImpl* opener_; + // User agent to use if a NavigationEntry requires that the default user agent + // is overridden. + std::string user_agent_override_; + // Helper classes ------------------------------------------------------------ // Manages creation and swapping of render views. |