| 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_form_database_service.h" | 7 #include "android_webview/browser/aw_form_database_service.h" |
| 8 #include "android_webview/browser/aw_quota_manager_bridge.h" | 8 #include "android_webview/browser/aw_quota_manager_bridge.h" |
| 9 #include "android_webview/browser/jni_dependency_factory.h" | 9 #include "android_webview/browser/jni_dependency_factory.h" |
| 10 #include "android_webview/browser/net/aw_url_request_context_getter.h" | 10 #include "android_webview/browser/net/aw_url_request_context_getter.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 } | 54 } |
| 55 | 55 |
| 56 // static | 56 // static |
| 57 AwBrowserContext* AwBrowserContext::FromWebContents( | 57 AwBrowserContext* AwBrowserContext::FromWebContents( |
| 58 content::WebContents* web_contents) { | 58 content::WebContents* web_contents) { |
| 59 // This is safe; this is the only implementation of the browser context. | 59 // This is safe; this is the only implementation of the browser context. |
| 60 return static_cast<AwBrowserContext*>(web_contents->GetBrowserContext()); | 60 return static_cast<AwBrowserContext*>(web_contents->GetBrowserContext()); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void AwBrowserContext::InitializeBeforeThreadCreation() { | 63 void AwBrowserContext::InitializeBeforeThreadCreation() { |
| 64 DCHECK(!url_request_context_getter_); | 64 DCHECK(!url_request_context_getter_.get()); |
| 65 url_request_context_getter_ = new AwURLRequestContextGetter(this); | 65 url_request_context_getter_ = new AwURLRequestContextGetter(this); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void AwBrowserContext::PreMainMessageLoopRun() { | 68 void AwBrowserContext::PreMainMessageLoopRun() { |
| 69 visitedlink_master_.reset( | 69 visitedlink_master_.reset( |
| 70 new visitedlink::VisitedLinkMaster(this, this, false)); | 70 new visitedlink::VisitedLinkMaster(this, this, false)); |
| 71 visitedlink_master_->Init(); | 71 visitedlink_master_->Init(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) { | 74 void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) { |
| 75 DCHECK(visitedlink_master_); | 75 DCHECK(visitedlink_master_); |
| 76 visitedlink_master_->AddURLs(urls); | 76 visitedlink_master_->AddURLs(urls); |
| 77 } | 77 } |
| 78 | 78 |
| 79 net::URLRequestContextGetter* AwBrowserContext::CreateRequestContext( | 79 net::URLRequestContextGetter* AwBrowserContext::CreateRequestContext( |
| 80 content::ProtocolHandlerMap* protocol_handlers) { | 80 content::ProtocolHandlerMap* protocol_handlers) { |
| 81 CHECK(url_request_context_getter_); | 81 CHECK(url_request_context_getter_.get()); |
| 82 url_request_context_getter_->SetProtocolHandlers(protocol_handlers); | 82 url_request_context_getter_->SetProtocolHandlers(protocol_handlers); |
| 83 return url_request_context_getter_.get(); | 83 return url_request_context_getter_.get(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 net::URLRequestContextGetter* | 86 net::URLRequestContextGetter* |
| 87 AwBrowserContext::CreateRequestContextForStoragePartition( | 87 AwBrowserContext::CreateRequestContextForStoragePartition( |
| 88 const base::FilePath& partition_path, | 88 const base::FilePath& partition_path, |
| 89 bool in_memory, | 89 bool in_memory, |
| 90 content::ProtocolHandlerMap* protocol_handlers) { | 90 content::ProtocolHandlerMap* protocol_handlers) { |
| 91 CHECK(url_request_context_getter_); | 91 CHECK(url_request_context_getter_.get()); |
| 92 return url_request_context_getter_.get(); | 92 return url_request_context_getter_.get(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 AwQuotaManagerBridge* AwBrowserContext::GetQuotaManagerBridge() { | 95 AwQuotaManagerBridge* AwBrowserContext::GetQuotaManagerBridge() { |
| 96 if (!quota_manager_bridge_) { | 96 if (!quota_manager_bridge_) { |
| 97 quota_manager_bridge_.reset( | 97 quota_manager_bridge_.reset( |
| 98 native_factory_->CreateAwQuotaManagerBridge(this)); | 98 native_factory_->CreateAwQuotaManagerBridge(this)); |
| 99 } | 99 } |
| 100 return quota_manager_bridge_.get(); | 100 return quota_manager_bridge_.get(); |
| 101 } | 101 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 152 |
| 153 net::URLRequestContextGetter* | 153 net::URLRequestContextGetter* |
| 154 AwBrowserContext::GetMediaRequestContextForStoragePartition( | 154 AwBrowserContext::GetMediaRequestContextForStoragePartition( |
| 155 const base::FilePath& partition_path, | 155 const base::FilePath& partition_path, |
| 156 bool in_memory) { | 156 bool in_memory) { |
| 157 return GetRequestContext(); | 157 return GetRequestContext(); |
| 158 } | 158 } |
| 159 | 159 |
| 160 content::ResourceContext* AwBrowserContext::GetResourceContext() { | 160 content::ResourceContext* AwBrowserContext::GetResourceContext() { |
| 161 if (!resource_context_) { | 161 if (!resource_context_) { |
| 162 CHECK(url_request_context_getter_); | 162 CHECK(url_request_context_getter_.get()); |
| 163 resource_context_.reset(new AwResourceContext( | 163 resource_context_.reset( |
| 164 url_request_context_getter_.get())); | 164 new AwResourceContext(url_request_context_getter_.get())); |
| 165 } | 165 } |
| 166 return resource_context_.get(); | 166 return resource_context_.get(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 content::DownloadManagerDelegate* | 169 content::DownloadManagerDelegate* |
| 170 AwBrowserContext::GetDownloadManagerDelegate() { | 170 AwBrowserContext::GetDownloadManagerDelegate() { |
| 171 return &download_manager_delegate_; | 171 return &download_manager_delegate_; |
| 172 } | 172 } |
| 173 | 173 |
| 174 content::GeolocationPermissionContext* | 174 content::GeolocationPermissionContext* |
| 175 AwBrowserContext::GetGeolocationPermissionContext() { | 175 AwBrowserContext::GetGeolocationPermissionContext() { |
| 176 if (!geolocation_permission_context_) { | 176 if (!geolocation_permission_context_.get()) { |
| 177 geolocation_permission_context_ = | 177 geolocation_permission_context_ = |
| 178 native_factory_->CreateGeolocationPermission(this); | 178 native_factory_->CreateGeolocationPermission(this); |
| 179 } | 179 } |
| 180 return geolocation_permission_context_; | 180 return geolocation_permission_context_.get(); |
| 181 } | 181 } |
| 182 | 182 |
| 183 content::SpeechRecognitionPreferences* | 183 content::SpeechRecognitionPreferences* |
| 184 AwBrowserContext::GetSpeechRecognitionPreferences() { | 184 AwBrowserContext::GetSpeechRecognitionPreferences() { |
| 185 // By default allows profanities in speech recognition if return NULL. | 185 // By default allows profanities in speech recognition if return NULL. |
| 186 return NULL; | 186 return NULL; |
| 187 } | 187 } |
| 188 | 188 |
| 189 quota::SpecialStoragePolicy* AwBrowserContext::GetSpecialStoragePolicy() { | 189 quota::SpecialStoragePolicy* AwBrowserContext::GetSpecialStoragePolicy() { |
| 190 // TODO(boliu): Implement this so we are not relying on default behavior. | 190 // TODO(boliu): Implement this so we are not relying on default behavior. |
| 191 NOTIMPLEMENTED(); | 191 NOTIMPLEMENTED(); |
| 192 return NULL; | 192 return NULL; |
| 193 } | 193 } |
| 194 | 194 |
| 195 void AwBrowserContext::RebuildTable( | 195 void AwBrowserContext::RebuildTable( |
| 196 const scoped_refptr<URLEnumerator>& enumerator) { | 196 const scoped_refptr<URLEnumerator>& enumerator) { |
| 197 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client | 197 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client |
| 198 // can change in the lifetime of this WebView and may not yet be set here. | 198 // can change in the lifetime of this WebView and may not yet be set here. |
| 199 // Therefore this initialization path is not used. | 199 // Therefore this initialization path is not used. |
| 200 enumerator->OnComplete(true); | 200 enumerator->OnComplete(true); |
| 201 } | 201 } |
| 202 | 202 |
| 203 } // namespace android_webview | 203 } // namespace android_webview |
| OLD | NEW |