summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-25 05:13:35 +0000
committereroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-25 05:13:35 +0000
commitbd0875ed222d58f51816ebb08e6203ef94053276 (patch)
tree128b7a192f78903b519fb38d07c505e0d8304ec4
parent30d767ff3ae37bf4bd46b58fbff62b45dc425051 (diff)
downloadchromium_src-bd0875ed222d58f51816ebb08e6203ef94053276.zip
chromium_src-bd0875ed222d58f51816ebb08e6203ef94053276.tar.gz
chromium_src-bd0875ed222d58f51816ebb08e6203ef94053276.tar.bz2
Make sure the system request context specifies a user agent.
BUG=76833 TEST=open about:net-internals. Change your proxy settings to use an http:// URL for PAC. Check that the request headers sent contains a User-Agent line. Review URL: http://codereview.chromium.org/6732048 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79371 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/io_thread.cc18
1 files changed, 16 insertions, 2 deletions
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc
index 6ddad22..f73a5f2 100644
--- a/chrome/browser/io_thread.cc
+++ b/chrome/browser/io_thread.cc
@@ -50,9 +50,21 @@
#include "net/ocsp/nss_ocsp.h"
#endif // defined(USE_NSS)
#include "net/proxy/proxy_script_fetcher_impl.h"
+#include "webkit/glue/webkit_glue.h"
namespace {
+// Custom URLRequestContext used by requests which aren't associated with a
+// particular profile. We need to use a subclass of URLRequestContext in order
+// to provide the correct User-Agent.
+class URLRequestContextWithUserAgent : public net::URLRequestContext {
+ public:
+ virtual const std::string& GetUserAgent(
+ const GURL& url) const OVERRIDE {
+ return webkit_glue::GetUserAgent(url);
+ }
+};
+
net::HostResolver* CreateGlobalHostResolver(net::NetLog* net_log) {
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
@@ -186,7 +198,8 @@ class LoggingNetworkChangeObserver
scoped_refptr<net::URLRequestContext>
ConstructProxyScriptFetcherContext(IOThread::Globals* globals,
net::NetLog* net_log) {
- scoped_refptr<net::URLRequestContext> context(new net::URLRequestContext);
+ scoped_refptr<net::URLRequestContext> context(
+ new URLRequestContextWithUserAgent);
context->set_net_log(net_log);
context->set_host_resolver(globals->host_resolver.get());
context->set_cert_verifier(globals->cert_verifier.get());
@@ -205,7 +218,8 @@ ConstructProxyScriptFetcherContext(IOThread::Globals* globals,
scoped_refptr<net::URLRequestContext>
ConstructSystemRequestContext(IOThread::Globals* globals,
net::NetLog* net_log) {
- scoped_refptr<net::URLRequestContext> context(new net::URLRequestContext);
+ scoped_refptr<net::URLRequestContext> context(
+ new URLRequestContextWithUserAgent);
context->set_net_log(net_log);
context->set_host_resolver(globals->host_resolver.get());
context->set_cert_verifier(globals->cert_verifier.get());