diff options
author | dpranke@chromium.org <dpranke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-26 18:30:34 +0000 |
---|---|---|
committer | dpranke@chromium.org <dpranke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-26 18:30:34 +0000 |
commit | 79bd6e8691a7ff0b1d2b66a54cd09c9b874da8f9 (patch) | |
tree | 2c8c644bbe31800f3053156f73fb44cb3ef7a291 /content | |
parent | 0b91391a2054c836e6710eb19d00342164791a0f (diff) | |
download | chromium_src-79bd6e8691a7ff0b1d2b66a54cd09c9b874da8f9.zip chromium_src-79bd6e8691a7ff0b1d2b66a54cd09c9b874da8f9.tar.gz chromium_src-79bd6e8691a7ff0b1d2b66a54cd09c9b874da8f9.tar.bz2 |
Re-land r102336 (remove webkit_glue::BuildUserAgent) w/ fix.
Remove webkit_glue::BuildUserAgent(), change the contract in webkit_glue so
that SetUserAgent() must be called before GetUserAgent().
This was causing a dependency inversion between webkit_support and its clients,
and was needed for the content component build.
For content users, calling SetContentClient() will automatically initialize the
user agent (retrieved from client->GetUserAgent()).
As a bonus, fixing this allowed me to re-test the "mimic_windows" code path and
it looks like we no longer need it.
R=jam@chromium.org,rsesek@chromium.org
BUG=11136, 90442
TEST=visit yahoo! mail using Chromium on Linux, ensure that we don't get an "unsupported browser" warning.
Review URL: http://codereview.chromium.org/8045005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102763 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/common/child_thread.cc | 6 | ||||
-rw-r--r-- | content/common/content_client.cc | 14 | ||||
-rw-r--r-- | content/common/content_client.h | 8 | ||||
-rw-r--r-- | content/renderer/renderer_glue.cc | 4 | ||||
-rw-r--r-- | content/shell/shell_content_client.cc | 5 | ||||
-rw-r--r-- | content/shell/shell_content_client.h | 2 | ||||
-rw-r--r-- | content/test/test_content_client.cc | 5 | ||||
-rw-r--r-- | content/test/test_content_client.h | 2 |
8 files changed, 26 insertions, 20 deletions
diff --git a/content/common/child_thread.cc b/content/common/child_thread.cc index f76c2a5..bfde285 100644 --- a/content/common/child_thread.cc +++ b/content/common/child_thread.cc @@ -41,12 +41,6 @@ void ChildThread::Init() { check_with_browser_before_shutdown_ = false; on_channel_error_called_ = false; message_loop_ = MessageLoop::current(); - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUserAgent)) { - webkit_glue::SetUserAgent( - CommandLine::ForCurrentProcess()->GetSwitchValueASCII( - switches::kUserAgent)); - } - channel_.reset(new IPC::SyncChannel(channel_name_, IPC::Channel::MODE_CLIENT, this, ChildProcess::current()->io_message_loop_proxy(), true, diff --git a/content/common/content_client.cc b/content/common/content_client.cc index cc2bad4..4622ce4 100644 --- a/content/common/content_client.cc +++ b/content/common/content_client.cc @@ -5,6 +5,7 @@ #include "content/common/content_client.h" #include "base/string_piece.h" +#include "webkit/glue/webkit_glue.h" namespace content { @@ -12,6 +13,19 @@ static ContentClient* g_client; void SetContentClient(ContentClient* client) { g_client = client; + + // TODO(dpranke): Doing real work (calling webkit_glue::SetUserAgent) + // inside what looks like a function that initializes a global is a + // bit odd, but we need to make sure this is done before + // webkit_glue::GetUserAgent() is called (so that the UA doesn't change). + // + // It would be cleaner if we could rename this to something like a + // content::Initialize(). Maybe we can merge this into ContentMain() somehow? + if (client) { + bool custom = false; + std::string ua = client->GetUserAgent(&custom); + webkit_glue::SetUserAgent(ua, custom); + } } ContentClient* GetContentClient() { diff --git a/content/common/content_client.h b/content/common/content_client.h index 9f5521f..ad07400 100644 --- a/content/common/content_client.h +++ b/content/common/content_client.h @@ -76,10 +76,10 @@ class CONTENT_EXPORT ContentClient { // behalf of a swapped out renderer. virtual bool CanHandleWhileSwappedOut(const IPC::Message& msg) = 0; - // Returns the user agent. If mimic_windows is true then the embedder can - // return a fake Windows user agent. This is a workaround for broken - // websites. - virtual std::string GetUserAgent(bool mimic_windows) const = 0; + // Returns the user agent and a flag indicating whether the returned + // string should always be used (if false, callers may override the + // value as needed to work around various user agent sniffing bugs). + virtual std::string GetUserAgent(bool *overriding) const = 0; // Returns a string resource given its id. virtual string16 GetLocalizedString(int message_id) const = 0; diff --git a/content/renderer/renderer_glue.cc b/content/renderer/renderer_glue.cc index 4da134b..7677bd4 100644 --- a/content/renderer/renderer_glue.cc +++ b/content/renderer/renderer_glue.cc @@ -248,8 +248,4 @@ base::StringPiece GetDataResource(int resource_id) { return content::GetContentClient()->GetDataResource(resource_id); } -std::string BuildUserAgent(bool mimic_windows) { - return content::GetContentClient()->GetUserAgent(mimic_windows); -} - } // namespace webkit_glue diff --git a/content/shell/shell_content_client.cc b/content/shell/shell_content_client.cc index 644fd98..5caaef0 100644 --- a/content/shell/shell_content_client.cc +++ b/content/shell/shell_content_client.cc @@ -30,8 +30,9 @@ bool ShellContentClient::CanHandleWhileSwappedOut(const IPC::Message& msg) { return false; } -std::string ShellContentClient::GetUserAgent(bool mimic_windows) const { - return webkit_glue::BuildUserAgentHelper(mimic_windows, "Chrome/15.16.17.18"); +std::string ShellContentClient::GetUserAgent(bool* overriding) const { + *overriding = false; + return std::string("Chrome/15.16.17.18"); } string16 ShellContentClient::GetLocalizedString(int message_id) const { diff --git a/content/shell/shell_content_client.h b/content/shell/shell_content_client.h index 35b2020..d0644d4 100644 --- a/content/shell/shell_content_client.h +++ b/content/shell/shell_content_client.h @@ -21,7 +21,7 @@ class ShellContentClient : public ContentClient { std::vector<PepperPluginInfo>* plugins) OVERRIDE; virtual bool CanSendWhileSwappedOut(const IPC::Message* msg) OVERRIDE; virtual bool CanHandleWhileSwappedOut(const IPC::Message& msg) OVERRIDE; - virtual std::string GetUserAgent(bool mimic_windows) const OVERRIDE; + virtual std::string GetUserAgent(bool* overriding) const OVERRIDE; virtual string16 GetLocalizedString(int message_id) const OVERRIDE; virtual base::StringPiece GetDataResource(int resource_id) const OVERRIDE; diff --git a/content/test/test_content_client.cc b/content/test/test_content_client.cc index 5112532..736be6c 100644 --- a/content/test/test_content_client.cc +++ b/content/test/test_content_client.cc @@ -31,8 +31,9 @@ bool TestContentClient::CanHandleWhileSwappedOut(const IPC::Message& msg) { return true; } -std::string TestContentClient::GetUserAgent(bool mimic_windows) const { - return std::string(); +std::string TestContentClient::GetUserAgent(bool* overriding) const { + *overriding = false; + return std::string("TestContentClient"); } string16 TestContentClient::GetLocalizedString(int message_id) const { diff --git a/content/test/test_content_client.h b/content/test/test_content_client.h index d26684b..c7bafa2 100644 --- a/content/test/test_content_client.h +++ b/content/test/test_content_client.h @@ -21,7 +21,7 @@ class TestContentClient : public content::ContentClient { std::vector<PepperPluginInfo>* plugins) OVERRIDE; virtual bool CanSendWhileSwappedOut(const IPC::Message* msg) OVERRIDE; virtual bool CanHandleWhileSwappedOut(const IPC::Message& msg) OVERRIDE; - virtual std::string GetUserAgent(bool mimic_windows) const OVERRIDE; + virtual std::string GetUserAgent(bool* overriding) const OVERRIDE; virtual string16 GetLocalizedString(int message_id) const OVERRIDE; virtual base::StringPiece GetDataResource(int resource_id) const OVERRIDE; #if defined(OS_WIN) |