Commit 145b29d3 authored by tyoshino@chromium.org's avatar tyoshino@chromium.org

Use the same fake User-Agent string as GetContentShell()->GetUserAgent() for...

Use the same fake User-Agent string as GetContentShell()->GetUserAgent() for URLRequestContext in content_shell

ShellContentClient::GetUserAgent() returns a fake User-Agent. It's used
for navigator.userAgent, loading layout test test case file, etc. But
ShellURLRequestContextGetter has an HttpUserAgentSettings with an empty
string for User-Agent. Factor out the code to build the fake User-Agent
from ShellContentClient::GetUserAgent() into GetShellUserAgent() and use
it for ShellURLRequestContextGetter. This is almost the same as how
ChromeShellContentClient and ChromeURLRequestContextGetter are doing.

With this, we can test that WebSocket handshake request contains the
correct user-agent header value.

BUG=347109

Review URL: https://codereview.chromium.org/319083003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275673 0039d316-1c4b-4281-b951-d872f2087c98
parent 6951f97d
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "content/public/browser/cookie_store_factory.h" #include "content/public/browser/cookie_store_factory.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "content/shell/browser/shell_network_delegate.h" #include "content/shell/browser/shell_network_delegate.h"
#include "content/shell/common/shell_content_client.h"
#include "content/shell/common/shell_switches.h" #include "content/shell/common/shell_switches.h"
#include "net/base/cache_type.h" #include "net/base/cache_type.h"
#include "net/cert/cert_verifier.h" #include "net/cert/cert_verifier.h"
...@@ -109,7 +110,8 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { ...@@ -109,7 +110,8 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() {
new net::DefaultServerBoundCertStore(NULL), new net::DefaultServerBoundCertStore(NULL),
base::WorkerPool::GetTaskRunner(true))); base::WorkerPool::GetTaskRunner(true)));
storage_->set_http_user_agent_settings( storage_->set_http_user_agent_settings(
new net::StaticHttpUserAgentSettings("en-us,en", std::string())); new net::StaticHttpUserAgentSettings(
"en-us,en", GetShellUserAgent()));
scoped_ptr<net::HostResolver> host_resolver( scoped_ptr<net::HostResolver> host_resolver(
net::HostResolver::CreateDefaultResolver( net::HostResolver::CreateDefaultResolver(
......
...@@ -18,10 +18,7 @@ ...@@ -18,10 +18,7 @@
namespace content { namespace content {
ShellContentClient::~ShellContentClient() { std::string GetShellUserAgent() {
}
std::string ShellContentClient::GetUserAgent() const {
std::string product = "Chrome/" CONTENT_SHELL_VERSION; std::string product = "Chrome/" CONTENT_SHELL_VERSION;
CommandLine* command_line = CommandLine::ForCurrentProcess(); CommandLine* command_line = CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kUseMobileUserAgent)) if (command_line->HasSwitch(switches::kUseMobileUserAgent))
...@@ -29,6 +26,13 @@ std::string ShellContentClient::GetUserAgent() const { ...@@ -29,6 +26,13 @@ std::string ShellContentClient::GetUserAgent() const {
return BuildUserAgentFromProduct(product); return BuildUserAgentFromProduct(product);
} }
ShellContentClient::~ShellContentClient() {
}
std::string ShellContentClient::GetUserAgent() const {
return GetShellUserAgent();
}
base::string16 ShellContentClient::GetLocalizedString(int message_id) const { base::string16 ShellContentClient::GetLocalizedString(int message_id) const {
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) {
switch (message_id) { switch (message_id) {
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
namespace content { namespace content {
std::string GetShellUserAgent();
class ShellContentClient : public ContentClient { class ShellContentClient : public ContentClient {
public: public:
virtual ~ShellContentClient(); virtual ~ShellContentClient();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment