diff options
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. |