summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortzik <tzik@chromium.org>2015-10-08 07:07:45 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-08 14:08:35 +0000
commit34958ad6de9e644bf5b75328d9e9fcc0ad140961 (patch)
treecf531b71828d90086f6fd595cc73a86fbcb3b491
parentbee0a6792475ed0a4a07399278c792df0d58bcce (diff)
downloadchromium_src-34958ad6de9e644bf5b75328d9e9fcc0ad140961.zip
chromium_src-34958ad6de9e644bf5b75328d9e9fcc0ad140961.tar.gz
chromium_src-34958ad6de9e644bf5b75328d9e9fcc0ad140961.tar.bz2
Remove per-URL User Agent override
No one actually uses per-URL UA override in Chrome, and this prevents caching UA string in Blink. BUG=540988 Review URL: https://codereview.chromium.org/1397573003 Cr-Commit-Position: refs/heads/master@{#353051}
-rw-r--r--content/public/renderer/content_renderer_client.cc4
-rw-r--r--content/public/renderer/content_renderer_client.h4
-rw-r--r--content/renderer/render_frame_impl.cc9
-rw-r--r--content/renderer/render_frame_impl.h3
-rw-r--r--third_party/WebKit/Source/core/dom/Document.cpp4
-rw-r--r--third_party/WebKit/Source/core/dom/Document.h2
-rw-r--r--third_party/WebKit/Source/core/dom/ExecutionContext.h2
-rw-r--r--third_party/WebKit/Source/core/frame/Navigator.cpp2
-rw-r--r--third_party/WebKit/Source/core/loader/EmptyClients.h2
-rw-r--r--third_party/WebKit/Source/core/loader/FrameLoader.cpp6
-rw-r--r--third_party/WebKit/Source/core/loader/FrameLoader.h2
-rw-r--r--third_party/WebKit/Source/core/loader/FrameLoaderClient.h2
-rw-r--r--third_party/WebKit/Source/core/testing/NullExecutionContext.h2
-rw-r--r--third_party/WebKit/Source/core/workers/InProcessWorkerBase.cpp2
-rw-r--r--third_party/WebKit/Source/core/workers/WorkerGlobalScope.cpp2
-rw-r--r--third_party/WebKit/Source/core/workers/WorkerGlobalScope.h2
-rw-r--r--third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp4
-rw-r--r--third_party/WebKit/Source/web/FrameLoaderClientImpl.h2
-rw-r--r--third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp2
-rw-r--r--third_party/WebKit/Source/web/tests/FrameLoaderClientImplTest.cpp13
-rw-r--r--third_party/WebKit/public/web/WebFrameClient.h6
21 files changed, 31 insertions, 46 deletions
diff --git a/content/public/renderer/content_renderer_client.cc b/content/public/renderer/content_renderer_client.cc
index 245776d..973cfe2 100644
--- a/content/public/renderer/content_renderer_client.cc
+++ b/content/public/renderer/content_renderer_client.cc
@@ -216,10 +216,6 @@ BrowserPluginDelegate* ContentRendererClient::CreateBrowserPluginDelegate(
return nullptr;
}
-std::string ContentRendererClient::GetUserAgentOverrideForURL(const GURL& url) {
- return std::string();
-}
-
scoped_ptr<blink::WebAppBannerClient>
ContentRendererClient::CreateAppBannerClient(RenderFrame* render_frame) {
return nullptr;
diff --git a/content/public/renderer/content_renderer_client.h b/content/public/renderer/content_renderer_client.h
index 5adc6ff..8b385814 100644
--- a/content/public/renderer/content_renderer_client.h
+++ b/content/public/renderer/content_renderer_client.h
@@ -289,10 +289,6 @@ class CONTENT_EXPORT ContentRendererClient {
// Returns true if dev channel APIs are available for plugins.
virtual bool IsPluginAllowedToUseDevChannelAPIs();
- // Returns a user agent override specific for |url|, or empty string if
- // default user agent should be used.
- virtual std::string GetUserAgentOverrideForURL(const GURL& url);
-
// Records a sample string to a Rappor privacy-preserving metric.
// See: https://www.chromium.org/developers/design-documents/rappor
virtual void RecordRappor(const std::string& metric,
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index c783b8e..8226e91 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -3700,14 +3700,9 @@ bool RenderFrameImpl::willCheckAndDispatchMessageEvent(
return true;
}
-blink::WebString RenderFrameImpl::userAgentOverride(blink::WebLocalFrame* frame,
- const blink::WebURL& url) {
+blink::WebString RenderFrameImpl::userAgentOverride(
+ blink::WebLocalFrame* frame) {
DCHECK(!frame_ || frame_ == frame);
- std::string user_agent_override_for_url =
- GetContentClient()->renderer()->GetUserAgentOverrideForURL(GURL(url));
- if (!user_agent_override_for_url.empty())
- return WebString::fromUTF8(user_agent_override_for_url);
-
if (!render_view_->webview() || !render_view_->webview()->mainFrame() ||
render_view_->renderer_preferences_.user_agent_override.empty()) {
return blink::WebString();
diff --git a/content/renderer/render_frame_impl.h b/content/renderer/render_frame_impl.h
index f6837da..68c42c4 100644
--- a/content/renderer/render_frame_impl.h
+++ b/content/renderer/render_frame_impl.h
@@ -530,8 +530,7 @@ class CONTENT_EXPORT RenderFrameImpl
blink::WebFrame* target_frame,
blink::WebSecurityOrigin target_origin,
blink::WebDOMMessageEvent event) override;
- blink::WebString userAgentOverride(blink::WebLocalFrame* frame,
- const blink::WebURL& url) override;
+ blink::WebString userAgentOverride(blink::WebLocalFrame* frame) override;
blink::WebString doNotTrackValue(blink::WebLocalFrame* frame) override;
bool allowWebGL(blink::WebLocalFrame* frame, bool default_value) override;
void didLoseWebGLContext(blink::WebLocalFrame* frame,
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp
index a8de8a5..15359a4 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -2958,9 +2958,9 @@ void Document::processBaseElement()
m_baseTarget = target ? *target : nullAtom;
}
-String Document::userAgent(const KURL& url) const
+String Document::userAgent() const
{
- return frame() ? frame()->loader().userAgent(url) : String();
+ return frame() ? frame()->loader().userAgent() : String();
}
void Document::disableEval(const String& errorMessage)
diff --git a/third_party/WebKit/Source/core/dom/Document.h b/third_party/WebKit/Source/core/dom/Document.h
index cf8a131..8792af4 100644
--- a/third_party/WebKit/Source/core/dom/Document.h
+++ b/third_party/WebKit/Source/core/dom/Document.h
@@ -526,7 +526,7 @@ public:
KURL completeURL(const String&) const;
KURL completeURLWithOverride(const String&, const KURL& baseURLOverride) const;
- String userAgent(const KURL&) const final;
+ String userAgent() const final;
void disableEval(const String& errorMessage) final;
CSSStyleSheet& elementSheet();
diff --git a/third_party/WebKit/Source/core/dom/ExecutionContext.h b/third_party/WebKit/Source/core/dom/ExecutionContext.h
index c26e5c6..ee4af7d 100644
--- a/third_party/WebKit/Source/core/dom/ExecutionContext.h
+++ b/third_party/WebKit/Source/core/dom/ExecutionContext.h
@@ -87,7 +87,7 @@ public:
KURL completeURL(const String& url) const;
virtual void disableEval(const String& errorMessage) = 0;
virtual LocalDOMWindow* executingWindow() { return 0; }
- virtual String userAgent(const KURL&) const = 0;
+ virtual String userAgent() const = 0;
virtual void postTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTask>) = 0; // Executes the task on context's thread asynchronously.
virtual double timerAlignmentInterval() const = 0;
diff --git a/third_party/WebKit/Source/core/frame/Navigator.cpp b/third_party/WebKit/Source/core/frame/Navigator.cpp
index 3d1e566..379afd2 100644
--- a/third_party/WebKit/Source/core/frame/Navigator.cpp
+++ b/third_party/WebKit/Source/core/frame/Navigator.cpp
@@ -70,7 +70,7 @@ String Navigator::userAgent() const
if (!m_frame || !m_frame->page())
return String();
- return m_frame->loader().userAgent(m_frame->document()->url());
+ return m_frame->loader().userAgent();
}
bool Navigator::cookieEnabled() const
diff --git a/third_party/WebKit/Source/core/loader/EmptyClients.h b/third_party/WebKit/Source/core/loader/EmptyClients.h
index 731829e..1048eae 100644
--- a/third_party/WebKit/Source/core/loader/EmptyClients.h
+++ b/third_party/WebKit/Source/core/loader/EmptyClients.h
@@ -220,7 +220,7 @@ public:
PassRefPtrWillBeRawPtr<DocumentLoader> createDocumentLoader(LocalFrame*, const ResourceRequest&, const SubstituteData&) override;
- String userAgent(const KURL&) override { return ""; }
+ String userAgent() override { return ""; }
String doNotTrackValue() override { return String(); }
diff --git a/third_party/WebKit/Source/core/loader/FrameLoader.cpp b/third_party/WebKit/Source/core/loader/FrameLoader.cpp
index c3abf16..3c711ab 100644
--- a/third_party/WebKit/Source/core/loader/FrameLoader.cpp
+++ b/third_party/WebKit/Source/core/loader/FrameLoader.cpp
@@ -1172,9 +1172,9 @@ void FrameLoader::restoreScrollPositionAndViewState()
documentLoader()->initialScrollState().didRestoreFromHistory = true;
}
-String FrameLoader::userAgent(const KURL& url) const
+String FrameLoader::userAgent() const
{
- String userAgent = client()->userAgent(url);
+ String userAgent = client()->userAgent();
InspectorInstrumentation::applyUserAgentOverride(m_frame, &userAgent);
return userAgent;
}
@@ -1372,7 +1372,7 @@ void FrameLoader::startLoad(FrameLoadRequest& frameLoadRequest, FrameLoadType ty
void FrameLoader::applyUserAgent(ResourceRequest& request)
{
- String userAgent = this->userAgent(request.url());
+ String userAgent = this->userAgent();
ASSERT(!userAgent.isNull());
request.setHTTPUserAgent(AtomicString(userAgent));
}
diff --git a/third_party/WebKit/Source/core/loader/FrameLoader.h b/third_party/WebKit/Source/core/loader/FrameLoader.h
index 81e75d5..2fe9002 100644
--- a/third_party/WebKit/Source/core/loader/FrameLoader.h
+++ b/third_party/WebKit/Source/core/loader/FrameLoader.h
@@ -132,7 +132,7 @@ public:
void receivedFirstData();
- String userAgent(const KURL&) const;
+ String userAgent() const;
void dispatchDidClearWindowObjectInMainWorld();
void dispatchDidClearDocumentOfWindowObject();
diff --git a/third_party/WebKit/Source/core/loader/FrameLoaderClient.h b/third_party/WebKit/Source/core/loader/FrameLoaderClient.h
index 72155e4..d044f5b 100644
--- a/third_party/WebKit/Source/core/loader/FrameLoaderClient.h
+++ b/third_party/WebKit/Source/core/loader/FrameLoaderClient.h
@@ -136,7 +136,7 @@ public:
virtual PassRefPtrWillBeRawPtr<DocumentLoader> createDocumentLoader(LocalFrame*, const ResourceRequest&, const SubstituteData&) = 0;
- virtual String userAgent(const KURL&) = 0;
+ virtual String userAgent() = 0;
virtual String doNotTrackValue() = 0;
diff --git a/third_party/WebKit/Source/core/testing/NullExecutionContext.h b/third_party/WebKit/Source/core/testing/NullExecutionContext.h
index cc99563..9cb49be 100644
--- a/third_party/WebKit/Source/core/testing/NullExecutionContext.h
+++ b/third_party/WebKit/Source/core/testing/NullExecutionContext.h
@@ -22,7 +22,7 @@ public:
NullExecutionContext();
void disableEval(const String&) override { }
- String userAgent(const KURL&) const override { return String(); }
+ String userAgent() const override { return String(); }
void postTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTask>) override;
diff --git a/third_party/WebKit/Source/core/workers/InProcessWorkerBase.cpp b/third_party/WebKit/Source/core/workers/InProcessWorkerBase.cpp
index 254bdf5..b369a06 100644
--- a/third_party/WebKit/Source/core/workers/InProcessWorkerBase.cpp
+++ b/third_party/WebKit/Source/core/workers/InProcessWorkerBase.cpp
@@ -102,7 +102,7 @@ void InProcessWorkerBase::onFinished()
WorkerThreadStartMode startMode = DontPauseWorkerGlobalScopeOnStart;
if (InspectorInstrumentation::shouldPauseDedicatedWorkerOnStart(executionContext()))
startMode = PauseWorkerGlobalScopeOnStart;
- m_contextProxy->startWorkerGlobalScope(m_scriptLoader->url(), executionContext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script(), startMode);
+ m_contextProxy->startWorkerGlobalScope(m_scriptLoader->url(), executionContext()->userAgent(), m_scriptLoader->script(), startMode);
InspectorInstrumentation::scriptImported(executionContext(), m_scriptLoader->identifier(), m_scriptLoader->script());
}
m_contentSecurityPolicy = m_scriptLoader->releaseContentSecurityPolicy();
diff --git a/third_party/WebKit/Source/core/workers/WorkerGlobalScope.cpp b/third_party/WebKit/Source/core/workers/WorkerGlobalScope.cpp
index d7efd1a..dadf25d 100644
--- a/third_party/WebKit/Source/core/workers/WorkerGlobalScope.cpp
+++ b/third_party/WebKit/Source/core/workers/WorkerGlobalScope.cpp
@@ -137,7 +137,7 @@ KURL WorkerGlobalScope::completeURL(const String& url) const
return KURL(m_url, url);
}
-String WorkerGlobalScope::userAgent(const KURL&) const
+String WorkerGlobalScope::userAgent() const
{
return m_userAgent;
}
diff --git a/third_party/WebKit/Source/core/workers/WorkerGlobalScope.h b/third_party/WebKit/Source/core/workers/WorkerGlobalScope.h
index b7ffa07..51da5e3 100644
--- a/third_party/WebKit/Source/core/workers/WorkerGlobalScope.h
+++ b/third_party/WebKit/Source/core/workers/WorkerGlobalScope.h
@@ -78,7 +78,7 @@ public:
const KURL& url() const { return m_url; }
KURL completeURL(const String&) const;
- String userAgent(const KURL&) const final;
+ String userAgent() const final;
void disableEval(const String& errorMessage) final;
WorkerScriptController* script() { return m_script.get(); }
diff --git a/third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp b/third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp
index d926ef8..4a6c434 100644
--- a/third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp
+++ b/third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp
@@ -680,9 +680,9 @@ PassRefPtrWillBeRawPtr<DocumentLoader> FrameLoaderClientImpl::createDocumentLoad
return ds.release();
}
-String FrameLoaderClientImpl::userAgent(const KURL& url)
+String FrameLoaderClientImpl::userAgent()
{
- WebString override = m_webFrame->client()->userAgentOverride(m_webFrame, WebURL(url));
+ WebString override = m_webFrame->client()->userAgentOverride(m_webFrame);
if (!override.isEmpty())
return override;
diff --git a/third_party/WebKit/Source/web/FrameLoaderClientImpl.h b/third_party/WebKit/Source/web/FrameLoaderClientImpl.h
index c468e0e..d0b498f 100644
--- a/third_party/WebKit/Source/web/FrameLoaderClientImpl.h
+++ b/third_party/WebKit/Source/web/FrameLoaderClientImpl.h
@@ -117,7 +117,7 @@ public:
void didChangePerformanceTiming() override;
void selectorMatchChanged(const Vector<String>& addedSelectors, const Vector<String>& removedSelectors) override;
PassRefPtrWillBeRawPtr<DocumentLoader> createDocumentLoader(LocalFrame*, const ResourceRequest&, const SubstituteData&) override;
- WTF::String userAgent(const KURL&) override;
+ WTF::String userAgent() override;
WTF::String doNotTrackValue() override;
void transitionToCommittedForNewPage() override;
PassRefPtrWillBeRawPtr<LocalFrame> createFrame(const FrameLoadRequest&, const WTF::AtomicString& name, HTMLFrameOwnerElement*) override;
diff --git a/third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp b/third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp
index 4f49219..28be457 100644
--- a/third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp
+++ b/third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp
@@ -337,7 +337,7 @@ void WebSharedWorkerImpl::onScriptLoaderFinished()
RefPtrWillBeRawPtr<ContentSecurityPolicy> contentSecurityPolicy = m_mainScriptLoader->releaseContentSecurityPolicy();
OwnPtr<WorkerThreadStartupData> startupData = WorkerThreadStartupData::create(
m_url,
- m_loadingDocument->userAgent(m_url),
+ m_loadingDocument->userAgent(),
m_mainScriptLoader->script(),
nullptr,
startMode,
diff --git a/third_party/WebKit/Source/web/tests/FrameLoaderClientImplTest.cpp b/third_party/WebKit/Source/web/tests/FrameLoaderClientImplTest.cpp
index 48ef6cf..4fe1d6e 100644
--- a/third_party/WebKit/Source/web/tests/FrameLoaderClientImplTest.cpp
+++ b/third_party/WebKit/Source/web/tests/FrameLoaderClientImplTest.cpp
@@ -54,14 +54,14 @@ class MockWebFrameClient : public WebFrameClient {
public:
~MockWebFrameClient() override { }
- MOCK_METHOD2(userAgentOverride, WebString(WebLocalFrame*, const WebURL&));
+ MOCK_METHOD1(userAgentOverride, WebString(WebLocalFrame*));
};
class FrameLoaderClientImplTest : public ::testing::Test {
protected:
void SetUp() override
{
- ON_CALL(m_webFrameClient, userAgentOverride(_, _)).WillByDefault(Return(WebString()));
+ ON_CALL(m_webFrameClient, userAgentOverride(_)).WillByDefault(Return(WebString()));
FrameTestHelpers::TestWebViewClient webViewClient;
m_webView = WebView::create(&webViewClient);
@@ -80,9 +80,8 @@ protected:
WebString userAgent()
{
- // The test always returns the same user agent, regardless of the URL passed in.
- KURL dummyURL(ParsedURLString, "about:blank");
- WTF::CString userAgent = frameLoaderClient().userAgent(dummyURL).utf8();
+ // The test always returns the same user agent .
+ WTF::CString userAgent = frameLoaderClient().userAgent().utf8();
return WebString::fromUTF8(userAgent.data(), userAgent.length());
}
@@ -103,12 +102,12 @@ TEST_F(FrameLoaderClientImplTest, UserAgentOverride)
const WebString overrideUserAgent = WebString::fromUTF8("dummy override");
// Override the user agent and make sure we get it back.
- EXPECT_CALL(webFrameClient(), userAgentOverride(_, _)).WillOnce(Return(overrideUserAgent));
+ EXPECT_CALL(webFrameClient(), userAgentOverride(_)).WillOnce(Return(overrideUserAgent));
EXPECT_TRUE(overrideUserAgent.equals(userAgent()));
Mock::VerifyAndClearExpectations(&webFrameClient());
// Remove the override and make sure we get the original back.
- EXPECT_CALL(webFrameClient(), userAgentOverride(_, _)).WillOnce(Return(WebString()));
+ EXPECT_CALL(webFrameClient(), userAgentOverride(_)).WillOnce(Return(WebString()));
EXPECT_TRUE(defaultUserAgent.equals(userAgent()));
}
diff --git a/third_party/WebKit/public/web/WebFrameClient.h b/third_party/WebKit/public/web/WebFrameClient.h
index 7ad9298..c52278c 100644
--- a/third_party/WebKit/public/web/WebFrameClient.h
+++ b/third_party/WebKit/public/web/WebFrameClient.h
@@ -555,10 +555,10 @@ public:
WebSecurityOrigin target,
WebDOMMessageEvent event) { return false; }
- // Asks the embedder if a specific user agent should be used for the given
- // URL. Non-empty strings indicate an override should be used. Otherwise,
+ // Asks the embedder if a specific user agent should be used. Non-empty
+ // strings indicate an override should be used. Otherwise,
// Platform::current()->userAgent() will be called to provide one.
- virtual WebString userAgentOverride(WebLocalFrame*, const WebURL& url) { return WebString(); }
+ virtual WebString userAgentOverride(WebLocalFrame*) { return WebString(); }
// Asks the embedder what value the network stack will send for the DNT
// header. An empty string indicates that no DNT header will be send.