Index: extensions/browser/extension_url_request_context_getter.cc |
diff --git a/content/shell/browser/shell_url_request_context_getter.cc b/extensions/browser/extension_url_request_context_getter.cc |
similarity index 76% |
copy from content/shell/browser/shell_url_request_context_getter.cc |
copy to extensions/browser/extension_url_request_context_getter.cc |
index c606d13cba040da14893d3af6cbb154097a0c33b..78826d119a220b6ea6e9a62330a14e4fe1c2ef42 100644 |
--- a/content/shell/browser/shell_url_request_context_getter.cc |
+++ b/extensions/browser/extension_url_request_context_getter.cc |
@@ -1,8 +1,8 @@ |
-// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "content/shell/browser/shell_url_request_context_getter.h" |
+#include "extensions/browser/extension_url_request_context_getter.h" |
#include "base/command_line.h" |
#include "base/logging.h" |
@@ -13,10 +13,12 @@ |
#include "base/threading/worker_pool.h" |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/cookie_store_factory.h" |
+#include "content/public/browser/resource_request_info.h" |
#include "content/public/common/content_switches.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 "extensions/browser/extension_network_delegate.h" |
+#include "extensions/browser/info_map.h" |
+#include "extensions/common/constants.h" |
+#include "extensions/common/switches.h" |
#include "net/base/cache_type.h" |
#include "net/cert/cert_verifier.h" |
#include "net/cookies/cookie_monster.h" |
@@ -40,14 +42,13 @@ |
#include "net/url_request/url_request_job_factory_impl.h" |
#include "url/url_constants.h" |
-namespace content { |
+namespace extensions { |
namespace { |
- |
void InstallProtocolHandlers(net::URLRequestJobFactoryImpl* job_factory, |
- ProtocolHandlerMap* protocol_handlers) { |
- for (ProtocolHandlerMap::iterator it = |
- protocol_handlers->begin(); |
+ content::ProtocolHandlerMap* protocol_handlers) { |
+ for (content::ProtocolHandlerMap::iterator it = |
+ protocol_handlers->begin(); |
it != protocol_handlers->end(); |
++it) { |
bool set_protocol = job_factory->SetProtocolHandler( |
@@ -59,23 +60,26 @@ void InstallProtocolHandlers(net::URLRequestJobFactoryImpl* job_factory, |
} // namespace |
-ShellURLRequestContextGetter::ShellURLRequestContextGetter( |
+ExtensionURLRequestContextGetter::ExtensionURLRequestContextGetter( |
+ void* browser_context, |
bool ignore_certificate_errors, |
const base::FilePath& base_path, |
base::MessageLoop* io_loop, |
base::MessageLoop* file_loop, |
- ProtocolHandlerMap* protocol_handlers, |
- URLRequestInterceptorScopedVector request_interceptors, |
- net::NetLog* net_log) |
- : ignore_certificate_errors_(ignore_certificate_errors), |
+ content::ProtocolHandlerMap* protocol_handlers, |
+ content::URLRequestInterceptorScopedVector request_interceptors, |
+ net::NetLog* net_log, |
+ InfoMap* extension_info_map) |
+ : browser_context_(browser_context), |
+ ignore_certificate_errors_(ignore_certificate_errors), |
base_path_(base_path), |
io_loop_(io_loop), |
file_loop_(file_loop), |
net_log_(net_log), |
+ extension_info_map_(extension_info_map), |
request_interceptors_(request_interceptors.Pass()) { |
// Must first be created on the UI thread. |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
- |
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
std::swap(protocol_handlers_, *protocol_handlers); |
// We must create the proxy config service on the UI loop on Linux because it |
@@ -88,30 +92,29 @@ ShellURLRequestContextGetter::ShellURLRequestContextGetter( |
} |
} |
-ShellURLRequestContextGetter::~ShellURLRequestContextGetter() { |
+ExtensionURLRequestContextGetter::~ExtensionURLRequestContextGetter() { |
} |
-net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
+net::URLRequestContext* |
+ExtensionURLRequestContextGetter::GetURLRequestContext() { |
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
if (!url_request_context_) { |
const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
url_request_context_.reset(new net::URLRequestContext()); |
url_request_context_->set_net_log(net_log_); |
- network_delegate_.reset(new ShellNetworkDelegate); |
+ network_delegate_.reset( |
+ new ExtensionNetworkDelegate(browser_context_, extension_info_map_)); |
if (command_line.HasSwitch(switches::kDumpRenderTree)) |
- ShellNetworkDelegate::SetAcceptAllCookies(false); |
+ ExtensionNetworkDelegate::SetAcceptAllCookies(false); |
url_request_context_->set_network_delegate(network_delegate_.get()); |
storage_.reset( |
new net::URLRequestContextStorage(url_request_context_.get())); |
- storage_->set_cookie_store(CreateCookieStore(CookieStoreConfig())); |
+ storage_->set_cookie_store(CreateCookieStore(content::CookieStoreConfig())); |
storage_->set_channel_id_service(new net::ChannelIDService( |
new net::DefaultChannelIDStore(NULL), |
base::WorkerPool::GetTaskRunner(true))); |
- storage_->set_http_user_agent_settings( |
- new net::StaticHttpUserAgentSettings( |
- "en-us,en", GetShellUserAgent())); |
scoped_ptr<net::HostResolver> host_resolver( |
net::HostResolver::CreateDefaultResolver( |
@@ -149,7 +152,8 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { |
#endif |
cache_path, |
0, |
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)); |
+ content::BrowserThread::GetMessageLoopProxyForThread( |
+ content::BrowserThread::CACHE)); |
net::HttpNetworkSession::Params network_session_params; |
network_session_params.cert_verifier = |
@@ -172,23 +176,23 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { |
url_request_context_->net_log(); |
network_session_params.ignore_certificate_errors = |
ignore_certificate_errors_; |
- if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) { |
+ if (command_line.HasSwitch(::switches::kTestingFixedHttpPort)) { |
int value; |
base::StringToInt(command_line.GetSwitchValueASCII( |
- switches::kTestingFixedHttpPort), &value); |
+ ::switches::kTestingFixedHttpPort), &value); |
network_session_params.testing_fixed_http_port = value; |
} |
- if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { |
+ if (command_line.HasSwitch(::switches::kTestingFixedHttpsPort)) { |
int value; |
base::StringToInt(command_line.GetSwitchValueASCII( |
- switches::kTestingFixedHttpsPort), &value); |
+ ::switches::kTestingFixedHttpsPort), &value); |
network_session_params.testing_fixed_https_port = value; |
} |
- if (command_line.HasSwitch(switches::kHostResolverRules)) { |
+ if (command_line.HasSwitch(::switches::kHostResolverRules)) { |
scoped_ptr<net::MappedHostResolver> mapped_host_resolver( |
new net::MappedHostResolver(host_resolver.Pass())); |
mapped_host_resolver->SetRulesFromString( |
- command_line.GetSwitchValueASCII(switches::kHostResolverRules)); |
+ command_line.GetSwitchValueASCII(::switches::kHostResolverRules)); |
host_resolver = mapped_host_resolver.Pass(); |
} |
@@ -213,15 +217,16 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { |
set_protocol = job_factory->SetProtocolHandler( |
url::kFileScheme, |
new net::FileProtocolHandler( |
- BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( |
- base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); |
+ content::BrowserThread::GetBlockingPool()-> |
+ GetTaskRunnerWithShutdownBehavior( |
+ base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); |
DCHECK(set_protocol); |
#endif |
// Set up interceptors in the reverse order. |
scoped_ptr<net::URLRequestJobFactory> top_job_factory = |
job_factory.PassAs<net::URLRequestJobFactory>(); |
- for (URLRequestInterceptorScopedVector::reverse_iterator i = |
+ for (content::URLRequestInterceptorScopedVector::reverse_iterator i = |
request_interceptors_.rbegin(); |
i != request_interceptors_.rend(); |
++i) { |
@@ -237,12 +242,9 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { |
} |
scoped_refptr<base::SingleThreadTaskRunner> |
- ShellURLRequestContextGetter::GetNetworkTaskRunner() const { |
- return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
-} |
- |
-net::HostResolver* ShellURLRequestContextGetter::host_resolver() { |
- return url_request_context_->host_resolver(); |
+ ExtensionURLRequestContextGetter::GetNetworkTaskRunner() const { |
+ return content::BrowserThread::GetMessageLoopProxyForThread( |
+ content::BrowserThread::IO); |
} |
-} // namespace content |
+} // namespace extensions |