Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "extensions/shell/browser/shell_browser_context.h" | 5 #include "extensions/shell/browser/shell_browser_context.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "content/public/common/content_switches.h" | 9 #include "content/public/common/content_switches.h" |
| 10 #include "extensions/browser/extension_network_delegate.h" | |
| 11 #include "extensions/browser/extension_url_request_context_getter.h" | |
| 12 #include "extensions/browser/guest_view/guest_view_manager.h" | 10 #include "extensions/browser/guest_view/guest_view_manager.h" |
| 13 #include "extensions/common/switches.h" | 11 #include "extensions/shell/browser/shell_network_delegate.h" |
| 14 #include "extensions/shell/browser/shell_special_storage_policy.h" | 12 #include "extensions/shell/browser/shell_special_storage_policy.h" |
| 13 #include "extensions/shell/browser/shell_url_request_context_getter.h" | |
| 15 | 14 |
| 16 namespace extensions { | 15 namespace extensions { |
| 17 | 16 |
| 17 namespace { | |
| 18 | |
| 19 bool IgnoreCertificateErrors() { | |
| 20 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | |
| 21 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.
| |
| 22 true : false; | |
| 23 } | |
| 24 | |
| 25 } // namespace | |
| 26 | |
| 18 // Create a normal recording browser context. If we used an incognito context | 27 // Create a normal recording browser context. If we used an incognito context |
| 19 // then app_shell would also have to create a normal context and manage both. | 28 // then app_shell would also have to create a normal context and manage both. |
| 20 ShellBrowserContext::ShellBrowserContext(net::NetLog* net_log) | 29 ShellBrowserContext::ShellBrowserContext(net::NetLog* net_log) |
| 21 : content::ShellBrowserContext(false, NULL), | 30 : content::ShellBrowserContext(false, NULL), |
| 22 net_log_(net_log), | 31 net_log_(net_log), |
| 23 ignore_certificate_errors_(false), | |
| 24 storage_policy_(new ShellSpecialStoragePolicy) { | 32 storage_policy_(new ShellSpecialStoragePolicy) { |
| 25 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | |
| 26 if (cmd_line->HasSwitch(::switches::kIgnoreCertificateErrors) || | |
| 27 cmd_line->HasSwitch(switches::kDumpRenderTree)) { | |
| 28 ignore_certificate_errors_ = true; | |
| 29 } | |
| 30 } | 33 } |
| 31 | 34 |
| 32 ShellBrowserContext::~ShellBrowserContext() { | 35 ShellBrowserContext::~ShellBrowserContext() { |
| 33 } | 36 } |
| 34 | 37 |
| 35 content::BrowserPluginGuestManager* ShellBrowserContext::GetGuestManager() { | 38 content::BrowserPluginGuestManager* ShellBrowserContext::GetGuestManager() { |
| 36 return GuestViewManager::FromBrowserContext(this); | 39 return GuestViewManager::FromBrowserContext(this); |
| 37 } | 40 } |
| 38 | 41 |
| 39 storage::SpecialStoragePolicy* ShellBrowserContext::GetSpecialStoragePolicy() { | 42 storage::SpecialStoragePolicy* ShellBrowserContext::GetSpecialStoragePolicy() { |
| 40 return storage_policy_.get(); | 43 return storage_policy_.get(); |
| 41 } | 44 } |
| 42 | 45 |
| 43 net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext( | 46 net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext( |
| 44 content::ProtocolHandlerMap* protocol_handlers, | 47 content::ProtocolHandlerMap* protocol_handlers, |
| 45 content::URLRequestInterceptorScopedVector request_interceptors, | 48 content::URLRequestInterceptorScopedVector request_interceptors, |
| 46 InfoMap* extension_info_map) { | 49 InfoMap* extension_info_map) { |
| 47 DCHECK(!url_request_context_getter_.get()); | 50 DCHECK(!url_request_context_getter()); |
| 48 url_request_context_getter_ = | 51 set_url_request_context_getter( |
| 49 new extensions::ExtensionURLRequestContextGetter( | 52 new ShellURLRequestContextGetter( |
| 50 this, | 53 this, |
| 51 ignore_certificate_errors_, | 54 IgnoreCertificateErrors(), |
| 52 GetPath(), | 55 GetPath(), |
| 53 content::BrowserThread::UnsafeGetMessageLoopForThread( | 56 content::BrowserThread::UnsafeGetMessageLoopForThread( |
| 54 content::BrowserThread::IO), | 57 content::BrowserThread::IO), |
| 55 content::BrowserThread::UnsafeGetMessageLoopForThread( | 58 content::BrowserThread::UnsafeGetMessageLoopForThread( |
| 56 content::BrowserThread::FILE), | 59 content::BrowserThread::FILE), |
| 57 protocol_handlers, | 60 protocol_handlers, |
| 58 request_interceptors.Pass(), | 61 request_interceptors.Pass(), |
| 59 net_log_, | 62 net_log_, |
| 60 extension_info_map); | 63 extension_info_map)); |
| 61 Init(); | 64 resource_context_->set_url_request_context_getter( |
| 62 return url_request_context_getter_.get(); | 65 url_request_context_getter()); |
| 63 } | 66 content::BrowserThread::PostTask( |
| 64 | |
| 65 void ShellBrowserContext::Init(){ | |
| 66 content:: BrowserThread:: PostTask( | |
| 67 content::BrowserThread::IO, | 67 content::BrowserThread::IO, |
| 68 FROM_HERE, | 68 FROM_HERE, |
| 69 base::Bind( | 69 base::Bind( |
| 70 &ShellBrowserContext::InitializationOnIOThread, | 70 &ShellBrowserContext::InitURLRequestContextOnIOThread, |
| 71 base::Unretained(this))); | 71 base::Unretained(this))); |
| 72 return url_request_context_getter(); | |
| 72 } | 73 } |
| 73 | 74 |
| 74 void ShellBrowserContext::InitializationOnIOThread() { | 75 void ShellBrowserContext::InitURLRequestContextOnIOThread() { |
| 75 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 76 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 76 | 77 |
| 77 url_request_context_getter_->GetURLRequestContext(); | 78 // GetURLRequestContext() will create a URLRequestContext if it isn't |
| 79 // initialized. | |
| 80 url_request_context_getter()->GetURLRequestContext(); | |
| 78 } | 81 } |
| 79 | 82 |
| 80 void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext1() { | 83 void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext1() { |
| 81 NOTREACHED(); | 84 NOTREACHED(); |
| 82 } | 85 } |
| 83 void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext2() { | 86 void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext2() { |
| 84 NOTREACHED(); | 87 NOTREACHED(); |
| 85 } | 88 } |
| 86 void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext3() { | 89 void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext3() { |
| 87 NOTREACHED(); | 90 NOTREACHED(); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 117 NOTREACHED(); | 120 NOTREACHED(); |
| 118 } | 121 } |
| 119 void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext14() { | 122 void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext14() { |
| 120 NOTREACHED(); | 123 NOTREACHED(); |
| 121 } | 124 } |
| 122 void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext15() { | 125 void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext15() { |
| 123 NOTREACHED(); | 126 NOTREACHED(); |
| 124 } | 127 } |
| 125 | 128 |
| 126 } // namespace extensions | 129 } // namespace extensions |
| OLD | NEW |