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