OLD | NEW |
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/aw_quota_manager_bridge.h" |
| 8 #include "android_webview/browser/jni_dependency_factory.h" |
7 #include "android_webview/browser/net/aw_url_request_context_getter.h" | 9 #include "android_webview/browser/net/aw_url_request_context_getter.h" |
8 #include "components/visitedlink/browser/visitedlink_master.h" | 10 #include "components/visitedlink/browser/visitedlink_master.h" |
9 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
10 #include "content/public/browser/resource_context.h" | 12 #include "content/public/browser/resource_context.h" |
11 #include "content/public/browser/storage_partition.h" | 13 #include "content/public/browser/storage_partition.h" |
12 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
13 #include "net/url_request/url_request_context.h" | 15 #include "net/url_request/url_request_context.h" |
14 | 16 |
15 namespace android_webview { | 17 namespace android_webview { |
16 | 18 |
(...skipping 18 matching lines...) Expand all Loading... |
35 private: | 37 private: |
36 net::URLRequestContextGetter* getter_; | 38 net::URLRequestContextGetter* getter_; |
37 | 39 |
38 DISALLOW_COPY_AND_ASSIGN(AwResourceContext); | 40 DISALLOW_COPY_AND_ASSIGN(AwResourceContext); |
39 }; | 41 }; |
40 | 42 |
41 } // namespace | 43 } // namespace |
42 | 44 |
43 AwBrowserContext::AwBrowserContext( | 45 AwBrowserContext::AwBrowserContext( |
44 const base::FilePath path, | 46 const base::FilePath path, |
45 GeolocationPermissionFactoryFn* geolocation_permission_factory) | 47 JniDependencyFactory* native_factory) |
46 : context_storage_path_(path), | 48 : context_storage_path_(path), |
47 geolocation_permission_factory_(geolocation_permission_factory) { | 49 native_factory_(native_factory) { |
48 } | 50 } |
49 | 51 |
50 AwBrowserContext::~AwBrowserContext() { | 52 AwBrowserContext::~AwBrowserContext() { |
51 } | 53 } |
52 | 54 |
53 // static | 55 // static |
54 AwBrowserContext* AwBrowserContext::FromWebContents( | 56 AwBrowserContext* AwBrowserContext::FromWebContents( |
55 content::WebContents* web_contents) { | 57 content::WebContents* web_contents) { |
56 // This is safe; this is the only implementation of the browser context. | 58 // This is safe; this is the only implementation of the browser context. |
57 return static_cast<AwBrowserContext*>(web_contents->GetBrowserContext()); | 59 return static_cast<AwBrowserContext*>(web_contents->GetBrowserContext()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 105 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
104 developer_protocol_handler, | 106 developer_protocol_handler, |
105 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 107 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
106 chrome_protocol_handler, | 108 chrome_protocol_handler, |
107 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 109 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
108 chrome_devtools_protocol_handler) { | 110 chrome_devtools_protocol_handler) { |
109 CHECK(url_request_context_getter_); | 111 CHECK(url_request_context_getter_); |
110 return url_request_context_getter_.get(); | 112 return url_request_context_getter_.get(); |
111 } | 113 } |
112 | 114 |
| 115 AwQuotaManagerBridge* AwBrowserContext::GetQuotaManagerBridge() { |
| 116 if (!quota_manager_bridge_) { |
| 117 quota_manager_bridge_.reset( |
| 118 native_factory_->CreateAwQuotaManagerBridge(this)); |
| 119 } |
| 120 return quota_manager_bridge_.get(); |
| 121 } |
| 122 |
113 base::FilePath AwBrowserContext::GetPath() { | 123 base::FilePath AwBrowserContext::GetPath() { |
114 return context_storage_path_; | 124 return context_storage_path_; |
115 } | 125 } |
116 | 126 |
117 bool AwBrowserContext::IsOffTheRecord() const { | 127 bool AwBrowserContext::IsOffTheRecord() const { |
118 // Android WebView does not support off the record profile yet. | 128 // Android WebView does not support off the record profile yet. |
119 return false; | 129 return false; |
120 } | 130 } |
121 | 131 |
122 net::URLRequestContextGetter* AwBrowserContext::GetRequestContext() { | 132 net::URLRequestContextGetter* AwBrowserContext::GetRequestContext() { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } | 166 } |
157 | 167 |
158 content::DownloadManagerDelegate* | 168 content::DownloadManagerDelegate* |
159 AwBrowserContext::GetDownloadManagerDelegate() { | 169 AwBrowserContext::GetDownloadManagerDelegate() { |
160 return &download_manager_delegate_; | 170 return &download_manager_delegate_; |
161 } | 171 } |
162 | 172 |
163 content::GeolocationPermissionContext* | 173 content::GeolocationPermissionContext* |
164 AwBrowserContext::GetGeolocationPermissionContext() { | 174 AwBrowserContext::GetGeolocationPermissionContext() { |
165 if (!geolocation_permission_context_) { | 175 if (!geolocation_permission_context_) { |
166 geolocation_permission_context_ = (*geolocation_permission_factory_)(); | 176 geolocation_permission_context_ = |
| 177 native_factory_->CreateGeolocationPermission(this); |
167 } | 178 } |
168 return geolocation_permission_context_; | 179 return geolocation_permission_context_; |
169 } | 180 } |
170 | 181 |
171 content::SpeechRecognitionPreferences* | 182 content::SpeechRecognitionPreferences* |
172 AwBrowserContext::GetSpeechRecognitionPreferences() { | 183 AwBrowserContext::GetSpeechRecognitionPreferences() { |
173 // By default allows profanities in speech recognition if return NULL. | 184 // By default allows profanities in speech recognition if return NULL. |
174 return NULL; | 185 return NULL; |
175 } | 186 } |
176 | 187 |
177 quota::SpecialStoragePolicy* AwBrowserContext::GetSpecialStoragePolicy() { | 188 quota::SpecialStoragePolicy* AwBrowserContext::GetSpecialStoragePolicy() { |
178 // TODO(boliu): Implement this so we are not relying on default behavior. | 189 // TODO(boliu): Implement this so we are not relying on default behavior. |
179 NOTIMPLEMENTED(); | 190 NOTIMPLEMENTED(); |
180 return NULL; | 191 return NULL; |
181 } | 192 } |
182 | 193 |
183 void AwBrowserContext::RebuildTable( | 194 void AwBrowserContext::RebuildTable( |
184 const scoped_refptr<URLEnumerator>& enumerator) { | 195 const scoped_refptr<URLEnumerator>& enumerator) { |
185 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client | 196 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client |
186 // can change in the lifetime of this WebView and may not yet be set here. | 197 // can change in the lifetime of this WebView and may not yet be set here. |
187 // Therefore this initialization path is not used. | 198 // Therefore this initialization path is not used. |
188 enumerator->OnComplete(true); | 199 enumerator->OnComplete(true); |
189 } | 200 } |
190 | 201 |
191 } // namespace android_webview | 202 } // namespace android_webview |
OLD | NEW |