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

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: sync (r181485) 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 namespace {
18
19 class AwResourceContext : public content::ResourceContext {
20 public:
21 explicit AwResourceContext(net::URLRequestContextGetter* getter)
22 : getter_(getter) {}
23 virtual ~AwResourceContext() {}
24
25 // content::ResourceContext implementation.
26 virtual net::HostResolver* GetHostResolver() OVERRIDE {
27 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
28 return getter_->GetURLRequestContext()->host_resolver();
29 }
30 virtual net::URLRequestContext* GetRequestContext() OVERRIDE {
31 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
32 return getter_->GetURLRequestContext();
33 }
34
35 private:
36 net::URLRequestContextGetter* getter_;
37
38 DISALLOW_COPY_AND_ASSIGN(AwResourceContext);
39 };
40
41 } // namespace
42
13 AwBrowserContext::AwBrowserContext( 43 AwBrowserContext::AwBrowserContext(
14 const FilePath path, 44 const FilePath path,
15 GeolocationPermissionFactoryFn* geolocation_permission_factory) 45 GeolocationPermissionFactoryFn* geolocation_permission_factory)
16 : context_storage_path_(path), 46 : context_storage_path_(path),
17 geolocation_permission_factory_(geolocation_permission_factory) { 47 geolocation_permission_factory_(geolocation_permission_factory) {
18 } 48 }
19 49
20 AwBrowserContext::~AwBrowserContext() { 50 AwBrowserContext::~AwBrowserContext() {
21 } 51 }
22 52
(...skipping 13 matching lines...) Expand all
36 visitedlink_master_.reset( 66 visitedlink_master_.reset(
37 new components::VisitedLinkMaster(this, this, false)); 67 new components::VisitedLinkMaster(this, this, false));
38 visitedlink_master_->Init(); 68 visitedlink_master_->Init();
39 } 69 }
40 70
41 void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) { 71 void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) {
42 DCHECK(visitedlink_master_); 72 DCHECK(visitedlink_master_);
43 visitedlink_master_->AddURLs(urls); 73 visitedlink_master_->AddURLs(urls);
44 } 74 }
45 75
76 net::URLRequestContextGetter* AwBrowserContext::CreateRequestContext(
77 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
78 blob_protocol_handler,
79 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
80 file_system_protocol_handler,
81 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
82 developer_protocol_handler,
83 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
84 chrome_protocol_handler,
85 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
86 chrome_devtools_protocol_handler) {
87 CHECK(url_request_context_getter_);
88 url_request_context_getter_->SetProtocolHandlers(
89 blob_protocol_handler.Pass(), file_system_protocol_handler.Pass(),
90 developer_protocol_handler.Pass(), chrome_protocol_handler.Pass(),
91 chrome_devtools_protocol_handler.Pass());
92 return url_request_context_getter_.get();
93 }
94
95 net::URLRequestContextGetter*
96 AwBrowserContext::CreateRequestContextForStoragePartition(
97 const FilePath& partition_path,
98 bool in_memory,
99 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
100 blob_protocol_handler,
101 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
102 file_system_protocol_handler,
103 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
104 developer_protocol_handler,
105 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
106 chrome_protocol_handler,
107 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
108 chrome_devtools_protocol_handler) {
109 CHECK(url_request_context_getter_);
110 return url_request_context_getter_.get();
111 }
112
46 FilePath AwBrowserContext::GetPath() { 113 FilePath AwBrowserContext::GetPath() {
47 return context_storage_path_; 114 return context_storage_path_;
48 } 115 }
49 116
50 bool AwBrowserContext::IsOffTheRecord() const { 117 bool AwBrowserContext::IsOffTheRecord() const {
51 // Android WebView does not support off the record profile yet. 118 // Android WebView does not support off the record profile yet.
52 return false; 119 return false;
53 } 120 }
54 121
55 net::URLRequestContextGetter* AwBrowserContext::GetRequestContext() { 122 net::URLRequestContextGetter* AwBrowserContext::GetRequestContext() {
56 DCHECK(url_request_context_getter_); 123 return GetDefaultStoragePartition(this)->GetURLRequestContext();
57 return url_request_context_getter_;
58 } 124 }
59 125
60 net::URLRequestContextGetter* 126 net::URLRequestContextGetter*
61 AwBrowserContext::GetRequestContextForRenderProcess( 127 AwBrowserContext::GetRequestContextForRenderProcess(
62 int renderer_child_id) { 128 int renderer_child_id) {
63 return GetRequestContext(); 129 return GetRequestContext();
64 } 130 }
65 131
66 net::URLRequestContextGetter*
67 AwBrowserContext::GetRequestContextForStoragePartition(
68 const FilePath& partition_path,
69 bool in_memory) {
70 return GetRequestContext();
71 }
72
73 net::URLRequestContextGetter* AwBrowserContext::GetMediaRequestContext() { 132 net::URLRequestContextGetter* AwBrowserContext::GetMediaRequestContext() {
74 return GetRequestContext(); 133 return GetRequestContext();
75 } 134 }
76 135
77 net::URLRequestContextGetter* 136 net::URLRequestContextGetter*
78 AwBrowserContext::GetMediaRequestContextForRenderProcess( 137 AwBrowserContext::GetMediaRequestContextForRenderProcess(
79 int renderer_child_id) { 138 int renderer_child_id) {
80 return GetRequestContext(); 139 return GetRequestContext();
81 } 140 }
82 141
83 net::URLRequestContextGetter* 142 net::URLRequestContextGetter*
84 AwBrowserContext::GetMediaRequestContextForStoragePartition( 143 AwBrowserContext::GetMediaRequestContextForStoragePartition(
85 const FilePath& partition_path, 144 const FilePath& partition_path,
86 bool in_memory) { 145 bool in_memory) {
87 return GetRequestContext(); 146 return GetRequestContext();
88 } 147 }
89 148
90 content::ResourceContext* AwBrowserContext::GetResourceContext() { 149 content::ResourceContext* AwBrowserContext::GetResourceContext() {
91 return url_request_context_getter_->GetResourceContext(); 150 if (!resource_context_) {
151 CHECK(url_request_context_getter_);
152 resource_context_.reset(new AwResourceContext(
153 url_request_context_getter_.get()));
154 }
155 return resource_context_.get();
92 } 156 }
93 157
94 content::DownloadManagerDelegate* 158 content::DownloadManagerDelegate*
95 AwBrowserContext::GetDownloadManagerDelegate() { 159 AwBrowserContext::GetDownloadManagerDelegate() {
96 return &download_manager_delegate_; 160 return &download_manager_delegate_;
97 } 161 }
98 162
99 content::GeolocationPermissionContext* 163 content::GeolocationPermissionContext*
100 AwBrowserContext::GetGeolocationPermissionContext() { 164 AwBrowserContext::GetGeolocationPermissionContext() {
101 if (!geolocation_permission_context_) { 165 if (!geolocation_permission_context_) {
(...skipping 16 matching lines...) Expand all
118 182
119 void AwBrowserContext::RebuildTable( 183 void AwBrowserContext::RebuildTable(
120 const scoped_refptr<URLEnumerator>& enumerator) { 184 const scoped_refptr<URLEnumerator>& enumerator) {
121 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client 185 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client
122 // can change in the lifetime of this WebView and may not yet be set here. 186 // can change in the lifetime of this WebView and may not yet be set here.
123 // Therefore this initialization path is not used. 187 // Therefore this initialization path is not used.
124 enumerator->OnComplete(true); 188 enumerator->OnComplete(true);
125 } 189 }
126 190
127 } // namespace android_webview 191 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/aw_browser_context.h ('k') | android_webview/browser/aw_content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698