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 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 21 ::switches::kIgnoreCertificateErrors); |
| 22 } |
| 23 |
| 24 } // namespace |
| 25 |
18 // Create a normal recording browser context. If we used an incognito context | 26 // 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. | 27 // then app_shell would also have to create a normal context and manage both. |
20 ShellBrowserContext::ShellBrowserContext(net::NetLog* net_log) | 28 ShellBrowserContext::ShellBrowserContext(net::NetLog* net_log) |
21 : content::ShellBrowserContext(false, NULL), | 29 : content::ShellBrowserContext(false, NULL), |
22 net_log_(net_log), | 30 net_log_(net_log), |
23 ignore_certificate_errors_(false), | |
24 storage_policy_(new ShellSpecialStoragePolicy) { | 31 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 } | 32 } |
31 | 33 |
32 ShellBrowserContext::~ShellBrowserContext() { | 34 ShellBrowserContext::~ShellBrowserContext() { |
33 } | 35 } |
34 | 36 |
35 content::BrowserPluginGuestManager* ShellBrowserContext::GetGuestManager() { | 37 content::BrowserPluginGuestManager* ShellBrowserContext::GetGuestManager() { |
36 return GuestViewManager::FromBrowserContext(this); | 38 return GuestViewManager::FromBrowserContext(this); |
37 } | 39 } |
38 | 40 |
39 storage::SpecialStoragePolicy* ShellBrowserContext::GetSpecialStoragePolicy() { | 41 storage::SpecialStoragePolicy* ShellBrowserContext::GetSpecialStoragePolicy() { |
40 return storage_policy_.get(); | 42 return storage_policy_.get(); |
41 } | 43 } |
42 | 44 |
43 net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext( | 45 net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext( |
44 content::ProtocolHandlerMap* protocol_handlers, | 46 content::ProtocolHandlerMap* protocol_handlers, |
45 content::URLRequestInterceptorScopedVector request_interceptors, | 47 content::URLRequestInterceptorScopedVector request_interceptors, |
46 InfoMap* extension_info_map) { | 48 InfoMap* extension_info_map) { |
47 DCHECK(!url_request_context_getter_.get()); | 49 DCHECK(!url_request_context_getter()); |
48 url_request_context_getter_ = | 50 set_url_request_context_getter( |
49 new extensions::ExtensionURLRequestContextGetter( | 51 new ShellURLRequestContextGetter( |
50 this, | 52 this, |
51 ignore_certificate_errors_, | 53 IgnoreCertificateErrors(), |
52 GetPath(), | 54 GetPath(), |
53 content::BrowserThread::UnsafeGetMessageLoopForThread( | 55 content::BrowserThread::UnsafeGetMessageLoopForThread( |
54 content::BrowserThread::IO), | 56 content::BrowserThread::IO), |
55 content::BrowserThread::UnsafeGetMessageLoopForThread( | 57 content::BrowserThread::UnsafeGetMessageLoopForThread( |
56 content::BrowserThread::FILE), | 58 content::BrowserThread::FILE), |
57 protocol_handlers, | 59 protocol_handlers, |
58 request_interceptors.Pass(), | 60 request_interceptors.Pass(), |
59 net_log_, | 61 net_log_, |
60 extension_info_map); | 62 extension_info_map)); |
61 Init(); | 63 resource_context_->set_url_request_context_getter( |
62 return url_request_context_getter_.get(); | 64 url_request_context_getter()); |
63 } | 65 content::BrowserThread::PostTask( |
64 | |
65 void ShellBrowserContext::Init(){ | |
66 content:: BrowserThread:: PostTask( | |
67 content::BrowserThread::IO, | 66 content::BrowserThread::IO, |
68 FROM_HERE, | 67 FROM_HERE, |
69 base::Bind( | 68 base::Bind( |
70 &ShellBrowserContext::InitializationOnIOThread, | 69 &ShellBrowserContext::InitURLRequestContextOnIOThread, |
71 base::Unretained(this))); | 70 base::Unretained(this))); |
| 71 return url_request_context_getter(); |
72 } | 72 } |
73 | 73 |
74 void ShellBrowserContext::InitializationOnIOThread() { | 74 void ShellBrowserContext::InitURLRequestContextOnIOThread() { |
75 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 75 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
76 | 76 |
77 url_request_context_getter_->GetURLRequestContext(); | 77 // GetURLRequestContext() will create a URLRequestContext if it isn't |
| 78 // initialized. |
| 79 url_request_context_getter()->GetURLRequestContext(); |
78 } | 80 } |
79 | 81 |
80 void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext1() { | 82 void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext1() { |
81 NOTREACHED(); | 83 NOTREACHED(); |
82 } | 84 } |
83 void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext2() { | 85 void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext2() { |
84 NOTREACHED(); | 86 NOTREACHED(); |
85 } | 87 } |
86 void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext3() { | 88 void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext3() { |
87 NOTREACHED(); | 89 NOTREACHED(); |
(...skipping 29 matching lines...) Expand all Loading... |
117 NOTREACHED(); | 119 NOTREACHED(); |
118 } | 120 } |
119 void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext14() { | 121 void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext14() { |
120 NOTREACHED(); | 122 NOTREACHED(); |
121 } | 123 } |
122 void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext15() { | 124 void ShellBrowserContext::ProfileFunctionCallOnNonProfileBrowserContext15() { |
123 NOTREACHED(); | 125 NOTREACHED(); |
124 } | 126 } |
125 | 127 |
126 } // namespace extensions | 128 } // namespace extensions |
OLD | NEW |