Chromium Code Reviews| Index: extensions/shell/browser/shell_browser_context.cc |
| diff --git a/extensions/shell/browser/shell_browser_context.cc b/extensions/shell/browser/shell_browser_context.cc |
| index 8659de1ec59f8eb88a333e89707a6cc8bf16d2cd..5f1fa2aac042f2dbec35ff11b313338e059db2ca 100644 |
| --- a/extensions/shell/browser/shell_browser_context.cc |
| +++ b/extensions/shell/browser/shell_browser_context.cc |
| @@ -7,26 +7,29 @@ |
| #include "base/command_line.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/common/content_switches.h" |
| -#include "extensions/browser/extension_network_delegate.h" |
| -#include "extensions/browser/extension_url_request_context_getter.h" |
| #include "extensions/browser/guest_view/guest_view_manager.h" |
| -#include "extensions/common/switches.h" |
| +#include "extensions/shell/browser/shell_network_delegate.h" |
| #include "extensions/shell/browser/shell_special_storage_policy.h" |
| +#include "extensions/shell/browser/shell_url_request_context_getter.h" |
| namespace extensions { |
| +namespace { |
| + |
| +bool IgnoreCertificateErrors() { |
| + base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| + return cmd_line->HasSwitch(::switches::kIgnoreCertificateErrors) ? |
|
James Cook
2014/10/08 14:21:22
nit: Just "return cmd_line->HasSwitch()", no need
Xi Han
2014/10/08 14:29:15
Totally agree.
|
| + true : false; |
| +} |
| + |
| +} // namespace |
| + |
| // Create a normal recording browser context. If we used an incognito context |
| // then app_shell would also have to create a normal context and manage both. |
| ShellBrowserContext::ShellBrowserContext(net::NetLog* net_log) |
| : content::ShellBrowserContext(false, NULL), |
| net_log_(net_log), |
| - ignore_certificate_errors_(false), |
| storage_policy_(new ShellSpecialStoragePolicy) { |
| - base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| - if (cmd_line->HasSwitch(::switches::kIgnoreCertificateErrors) || |
| - cmd_line->HasSwitch(switches::kDumpRenderTree)) { |
| - ignore_certificate_errors_ = true; |
| - } |
| } |
| ShellBrowserContext::~ShellBrowserContext() { |
| @@ -44,11 +47,11 @@ net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext( |
| content::ProtocolHandlerMap* protocol_handlers, |
| content::URLRequestInterceptorScopedVector request_interceptors, |
| InfoMap* extension_info_map) { |
| - DCHECK(!url_request_context_getter_.get()); |
| - url_request_context_getter_ = |
| - new extensions::ExtensionURLRequestContextGetter( |
| + DCHECK(!url_request_context_getter()); |
| + set_url_request_context_getter( |
| + new ShellURLRequestContextGetter( |
| this, |
| - ignore_certificate_errors_, |
| + IgnoreCertificateErrors(), |
| GetPath(), |
| content::BrowserThread::UnsafeGetMessageLoopForThread( |
| content::BrowserThread::IO), |
| @@ -57,24 +60,24 @@ net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext( |
| protocol_handlers, |
| request_interceptors.Pass(), |
| net_log_, |
| - extension_info_map); |
| - Init(); |
| - return url_request_context_getter_.get(); |
| -} |
| - |
| -void ShellBrowserContext::Init(){ |
| - content:: BrowserThread:: PostTask( |
| + extension_info_map)); |
| + resource_context_->set_url_request_context_getter( |
| + url_request_context_getter()); |
| + content::BrowserThread::PostTask( |
| content::BrowserThread::IO, |
| FROM_HERE, |
| base::Bind( |
| - &ShellBrowserContext::InitializationOnIOThread, |
| + &ShellBrowserContext::InitURLRequestContextOnIOThread, |
| base::Unretained(this))); |
| + return url_request_context_getter(); |
| } |
| -void ShellBrowserContext::InitializationOnIOThread() { |
| +void ShellBrowserContext::InitURLRequestContextOnIOThread() { |
| DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| - url_request_context_getter_->GetURLRequestContext(); |
| + // GetURLRequestContext() will create a URLRequestContext if it isn't |
| + // initialized. |
| + url_request_context_getter()->GetURLRequestContext(); |
| } |
| void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext1() { |