Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: android_webview/browser/aw_browser_context.cc

Issue 11308362: Add StoragePartition's ProtocolHandlers at URLRequestContext construction time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address awong's comments Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "android_webview/browser/aw_browser_context.h" 5 #include "android_webview/browser/aw_browser_context.h"
6 6
7 #include "android_webview/browser/net/aw_url_request_context_getter.h" 7 #include "android_webview/browser/net/aw_url_request_context_getter.h"
8 #include "components/visitedlink/browser/visitedlink_master.h" 8 #include "components/visitedlink/browser/visitedlink_master.h"
9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/browser/resource_context.h"
11 #include "content/public/browser/storage_partition.h"
9 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
13 #include "net/url_request/url_request_context.h"
10 14
11 namespace android_webview { 15 namespace android_webview {
12 16
17 class AwBrowserContext::AwResourceContext : public content::ResourceContext {
18 public:
19 explicit AwResourceContext(net::URLRequestContextGetter* getter)
20 : getter_(getter) {}
21 virtual ~AwResourceContext() {}
22
23 // content::ResourceContext implementation.
24 virtual net::HostResolver* GetHostResolver() OVERRIDE {
25 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
26 return getter_->GetURLRequestContext()->host_resolver();
27 }
28 virtual net::URLRequestContext* GetRequestContext() OVERRIDE {
29 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
30 return getter_->GetURLRequestContext();
31 }
32
33 private:
34 net::URLRequestContextGetter* getter_;
35
36 DISALLOW_COPY_AND_ASSIGN(AwResourceContext);
37 };
38
13 AwBrowserContext::AwBrowserContext( 39 AwBrowserContext::AwBrowserContext(
14 const FilePath path, 40 const FilePath path,
15 GeolocationPermissionFactoryFn* geolocation_permission_factory) 41 GeolocationPermissionFactoryFn* geolocation_permission_factory)
16 : context_storage_path_(path), 42 : context_storage_path_(path),
17 geolocation_permission_factory_(geolocation_permission_factory) { 43 geolocation_permission_factory_(geolocation_permission_factory) {
18 } 44 }
19 45
20 AwBrowserContext::~AwBrowserContext() { 46 AwBrowserContext::~AwBrowserContext() {
21 } 47 }
22 48
(...skipping 28 matching lines...) Expand all
51 FilePath AwBrowserContext::GetPath() { 77 FilePath AwBrowserContext::GetPath() {
52 return context_storage_path_; 78 return context_storage_path_;
53 } 79 }
54 80
55 bool AwBrowserContext::IsOffTheRecord() const { 81 bool AwBrowserContext::IsOffTheRecord() const {
56 // Android WebView does not support off the record profile yet. 82 // Android WebView does not support off the record profile yet.
57 return false; 83 return false;
58 } 84 }
59 85
60 net::URLRequestContextGetter* AwBrowserContext::GetRequestContext() { 86 net::URLRequestContextGetter* AwBrowserContext::GetRequestContext() {
61 DCHECK(url_request_context_getter_); 87 content::StoragePartition* storage_partition =
62 return url_request_context_getter_; 88 BrowserContext::GetStoragePartition(this, NULL);
89 return storage_partition->GetURLRequestContext();
63 } 90 }
64 91
65 net::URLRequestContextGetter* 92 net::URLRequestContextGetter*
66 AwBrowserContext::GetRequestContextForRenderProcess( 93 AwBrowserContext::GetRequestContextForRenderProcess(
67 int renderer_child_id) { 94 int renderer_child_id) {
68 return GetRequestContext(); 95 return GetRequestContext();
69 } 96 }
70 97
71 net::URLRequestContextGetter*
72 AwBrowserContext::GetRequestContextForStoragePartition(
73 const FilePath& partition_path,
74 bool in_memory) {
75 return GetRequestContext();
76 }
77
78 net::URLRequestContextGetter* AwBrowserContext::GetMediaRequestContext() { 98 net::URLRequestContextGetter* AwBrowserContext::GetMediaRequestContext() {
79 return GetRequestContext(); 99 return GetRequestContext();
80 } 100 }
81 101
82 net::URLRequestContextGetter* 102 net::URLRequestContextGetter*
83 AwBrowserContext::GetMediaRequestContextForRenderProcess( 103 AwBrowserContext::GetMediaRequestContextForRenderProcess(
84 int renderer_child_id) { 104 int renderer_child_id) {
85 return GetRequestContext(); 105 return GetRequestContext();
86 } 106 }
87 107
88 net::URLRequestContextGetter* 108 net::URLRequestContextGetter*
89 AwBrowserContext::GetMediaRequestContextForStoragePartition( 109 AwBrowserContext::GetMediaRequestContextForStoragePartition(
90 const FilePath& partition_path, 110 const FilePath& partition_path,
91 bool in_memory) { 111 bool in_memory) {
92 return GetRequestContext(); 112 return GetRequestContext();
93 } 113 }
94 114
95 content::ResourceContext* AwBrowserContext::GetResourceContext() { 115 content::ResourceContext* AwBrowserContext::GetResourceContext() {
96 return url_request_context_getter_->GetResourceContext(); 116 if (!resource_context_) {
117 CHECK(url_request_context_getter_);
118 resource_context_.reset(new AwResourceContext(
119 url_request_context_getter_.get()));
120 }
121 return resource_context_.get();
97 } 122 }
98 123
99 content::DownloadManagerDelegate* 124 content::DownloadManagerDelegate*
100 AwBrowserContext::GetDownloadManagerDelegate() { 125 AwBrowserContext::GetDownloadManagerDelegate() {
101 return &download_manager_delegate_; 126 return &download_manager_delegate_;
102 } 127 }
103 128
104 content::GeolocationPermissionContext* 129 content::GeolocationPermissionContext*
105 AwBrowserContext::GetGeolocationPermissionContext() { 130 AwBrowserContext::GetGeolocationPermissionContext() {
106 if (!geolocation_permission_context_) { 131 if (!geolocation_permission_context_) {
(...skipping 15 matching lines...) Expand all
122 } 147 }
123 148
124 void AwBrowserContext::RebuildTable( 149 void AwBrowserContext::RebuildTable(
125 const scoped_refptr<URLEnumerator>& enumerator) { 150 const scoped_refptr<URLEnumerator>& enumerator) {
126 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client 151 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client
127 // can change in the lifetime of this WebView and may not yet be set here. 152 // can change in the lifetime of this WebView and may not yet be set here.
128 // Therefore this initialization path is not used. 153 // Therefore this initialization path is not used.
129 enumerator->OnComplete(true); 154 enumerator->OnComplete(true);
130 } 155 }
131 156
157 net::URLRequestContextGetter* AwBrowserContext::CreateRequestContext(
158 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
159 blob_protocol_handler,
160 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
161 file_system_protocol_handler,
162 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
163 developer_protocol_handler,
164 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
165 chrome_protocol_handler,
166 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
167 chrome_devtools_protocol_handler) {
168 CHECK(url_request_context_getter_);
169 url_request_context_getter_->SetProtocolHandlers(
170 blob_protocol_handler.Pass(), file_system_protocol_handler.Pass(),
171 developer_protocol_handler.Pass(), chrome_protocol_handler.Pass(),
172 chrome_devtools_protocol_handler.Pass());
173 return url_request_context_getter_.get();
174 }
175
176 net::URLRequestContextGetter*
177 AwBrowserContext::CreateRequestContextForStoragePartition(
178 const FilePath& partition_path,
179 bool in_memory,
180 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
181 blob_protocol_handler,
182 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
183 file_system_protocol_handler,
184 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
185 developer_protocol_handler,
186 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
187 chrome_protocol_handler,
188 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
189 chrome_devtools_protocol_handler) {
190 CHECK(url_request_context_getter_);
191 return url_request_context_getter_.get();
192 }
193
132 } // namespace android_webview 194 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698