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