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..960d5b7793f535878226391b53ce3c9b734aa537 100644 |
| --- a/extensions/shell/browser/shell_browser_context.cc |
| +++ b/extensions/shell/browser/shell_browser_context.cc |
| @@ -7,26 +7,33 @@ |
| #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 "content/shell/common/shell_switches.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(); |
| + if (cmd_line->HasSwitch(::switches::kIgnoreCertificateErrors) || |
|
James Cook
2014/10/07 22:38:45
no need for an if(), just return the result of the
Xi Han
2014/10/08 13:48:48
Done.
|
| + cmd_line->HasSwitch(switches::kDumpRenderTree)) |
|
James Cook
2014/10/07 22:38:45
You don't need kDumpRenderTree. We're not going to
Xi Han
2014/10/08 13:48:48
Done.
|
| + return true; |
| + return 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 +51,12 @@ 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()); |
| + bool ignore_certificate_errors = IgnoreCertificateErrors(); |
| + set_url_request_context_getter( |
| + new ShellURLRequestContextGetter( |
| this, |
| - ignore_certificate_errors_, |
| + ignore_certificate_errors, |
|
James Cook
2014/10/07 22:38:45
just call IgnoreCertificateErrors() here
Xi Han
2014/10/08 13:48:48
Removed.
|
| GetPath(), |
| content::BrowserThread::UnsafeGetMessageLoopForThread( |
| content::BrowserThread::IO), |
| @@ -57,24 +65,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() { |