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_pref_store.h" | 8 #include "android_webview/browser/aw_pref_store.h" |
9 #include "android_webview/browser/aw_quota_manager_bridge.h" | 9 #include "android_webview/browser/aw_quota_manager_bridge.h" |
10 #include "android_webview/browser/aw_resource_context.h" | 10 #include "android_webview/browser/aw_resource_context.h" |
11 #include "android_webview/browser/jni_dependency_factory.h" | 11 #include "android_webview/browser/jni_dependency_factory.h" |
12 #include "android_webview/browser/net/aw_url_request_context_getter.h" | 12 #include "android_webview/browser/net/aw_url_request_context_getter.h" |
13 #include "android_webview/browser/net/init_native_callback.h" | 13 #include "android_webview/browser/net/init_native_callback.h" |
14 #include "base/base_paths_android.h" | 14 #include "base/base_paths_android.h" |
15 #include "base/bind.h" | 15 #include "base/bind.h" |
16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
17 #include "base/prefs/pref_registry_simple.h" | 17 #include "base/prefs/pref_registry_simple.h" |
18 #include "base/prefs/pref_service.h" | 18 #include "base/prefs/pref_service.h" |
19 #include "base/prefs/pref_service_factory.h" | 19 #include "base/prefs/pref_service_factory.h" |
20 #include "components/autofill/core/common/autofill_pref_names.h" | 20 #include "components/autofill/core/common/autofill_pref_names.h" |
21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h" | 21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h" |
22 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref s.h" | 22 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref s.h" |
23 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv ice.h" | |
23 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h" | 24 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h" |
25 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat istics_prefs.h" | |
24 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" | 26 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" |
25 #include "components/user_prefs/user_prefs.h" | 27 #include "components/user_prefs/user_prefs.h" |
26 #include "components/visitedlink/browser/visitedlink_master.h" | 28 #include "components/visitedlink/browser/visitedlink_master.h" |
27 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
28 #include "content/public/browser/ssl_host_state_delegate.h" | 30 #include "content/public/browser/ssl_host_state_delegate.h" |
29 #include "content/public/browser/storage_partition.h" | 31 #include "content/public/browser/storage_partition.h" |
30 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" |
31 #include "net/cookies/cookie_store.h" | 33 #include "net/cookies/cookie_store.h" |
32 #include "net/proxy/proxy_config_service_android.h" | 34 #include "net/proxy/proxy_config_service_android.h" |
33 #include "net/proxy/proxy_service.h" | 35 #include "net/proxy/proxy_service.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 } else { | 151 } else { |
150 cache_path = fallback_cache_dir; | 152 cache_path = fallback_cache_dir; |
151 LOG(WARNING) << "Failed to get cache directory for Android WebView. " | 153 LOG(WARNING) << "Failed to get cache directory for Android WebView. " |
152 << "Using app data directory as a fallback."; | 154 << "Using app data directory as a fallback."; |
153 } | 155 } |
154 url_request_context_getter_ = | 156 url_request_context_getter_ = |
155 new AwURLRequestContextGetter( | 157 new AwURLRequestContextGetter( |
156 cache_path, cookie_store_.get(), | 158 cache_path, cookie_store_.get(), |
157 make_scoped_ptr(CreateProxyConfigService()).Pass()); | 159 make_scoped_ptr(CreateProxyConfigService()).Pass()); |
158 | 160 |
159 data_reduction_proxy_settings_.reset( | |
160 new data_reduction_proxy::DataReductionProxySettings( | |
161 scoped_ptr<data_reduction_proxy::DataReductionProxyParams>( | |
162 new data_reduction_proxy::DataReductionProxyParams( | |
163 data_reduction_proxy::DataReductionProxyParams::kAllowed)) | |
164 .Pass())); | |
165 data_reduction_proxy_io_data_.reset( | 161 data_reduction_proxy_io_data_.reset( |
166 new data_reduction_proxy::DataReductionProxyIOData( | 162 new data_reduction_proxy::DataReductionProxyIOData( |
167 data_reduction_proxy::Client::WEBVIEW_ANDROID, | 163 data_reduction_proxy::Client::WEBVIEW_ANDROID, |
168 scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>(), | 164 data_reduction_proxy::DataReductionProxyParams::kAllowed, |
169 data_reduction_proxy_settings_.get(), | |
170 url_request_context_getter_->GetNetLog(), | 165 url_request_context_getter_->GetNetLog(), |
171 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | 166 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |
172 BrowserThread::GetMessageLoopProxyForThread( | 167 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI))); |
173 BrowserThread::UI))); | 168 data_reduction_proxy_settings_.reset( |
174 data_reduction_proxy_io_data_->Init(); | 169 new data_reduction_proxy::DataReductionProxySettings()); |
175 data_reduction_proxy_settings_->SetProxyConfigurator( | 170 data_reduction_proxy_service_.reset( |
176 data_reduction_proxy_io_data_->configurator()); | 171 new data_reduction_proxy::DataReductionProxyService( |
172 scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>(), | |
173 data_reduction_proxy_settings_.get(), GetAwURLRequestContext())); | |
174 data_reduction_proxy_io_data_->SetDataReductionProxyService( | |
175 data_reduction_proxy_service_->GetWeakPtr()); | |
177 | 176 |
178 visitedlink_master_.reset( | 177 visitedlink_master_.reset( |
179 new visitedlink::VisitedLinkMaster(this, this, false)); | 178 new visitedlink::VisitedLinkMaster(this, this, false)); |
180 visitedlink_master_->Init(); | 179 visitedlink_master_->Init(); |
181 | 180 |
182 form_database_service_.reset( | 181 form_database_service_.reset( |
183 new AwFormDatabaseService(context_storage_path_)); | 182 new AwFormDatabaseService(context_storage_path_)); |
184 } | 183 } |
185 | 184 |
186 void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) { | 185 void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 data_reduction_proxy::DataReductionProxySettings* | 225 data_reduction_proxy::DataReductionProxySettings* |
227 AwBrowserContext::GetDataReductionProxySettings() { | 226 AwBrowserContext::GetDataReductionProxySettings() { |
228 return data_reduction_proxy_settings_.get(); | 227 return data_reduction_proxy_settings_.get(); |
229 } | 228 } |
230 | 229 |
231 data_reduction_proxy::DataReductionProxyIOData* | 230 data_reduction_proxy::DataReductionProxyIOData* |
232 AwBrowserContext::GetDataReductionProxyIOData() { | 231 AwBrowserContext::GetDataReductionProxyIOData() { |
233 return data_reduction_proxy_io_data_.get(); | 232 return data_reduction_proxy_io_data_.get(); |
234 } | 233 } |
235 | 234 |
236 data_reduction_proxy::DataReductionProxyConfigurator* | |
237 AwBrowserContext::GetDataReductionProxyConfigurator() { | |
238 return data_reduction_proxy_io_data_->configurator(); | |
239 } | |
240 | |
241 AwURLRequestContextGetter* AwBrowserContext::GetAwURLRequestContext() { | 235 AwURLRequestContextGetter* AwBrowserContext::GetAwURLRequestContext() { |
242 return url_request_context_getter_.get(); | 236 return url_request_context_getter_.get(); |
243 } | 237 } |
244 | 238 |
245 AwMessagePortService* AwBrowserContext::GetMessagePortService() { | 239 AwMessagePortService* AwBrowserContext::GetMessagePortService() { |
246 if (!message_port_service_.get()) { | 240 if (!message_port_service_.get()) { |
247 message_port_service_.reset( | 241 message_port_service_.reset( |
248 native_factory_->CreateAwMessagePortService()); | 242 native_factory_->CreateAwMessagePortService()); |
249 } | 243 } |
250 return message_port_service_.get(); | 244 return message_port_service_.get(); |
(...skipping 18 matching lines...) Expand all Loading... | |
269 | 263 |
270 base::PrefServiceFactory pref_service_factory; | 264 base::PrefServiceFactory pref_service_factory; |
271 pref_service_factory.set_user_prefs(make_scoped_refptr(new AwPrefStore())); | 265 pref_service_factory.set_user_prefs(make_scoped_refptr(new AwPrefStore())); |
272 pref_service_factory.set_read_error_callback(base::Bind(&HandleReadError)); | 266 pref_service_factory.set_read_error_callback(base::Bind(&HandleReadError)); |
273 user_pref_service_ = pref_service_factory.Create(pref_registry).Pass(); | 267 user_pref_service_ = pref_service_factory.Create(pref_registry).Pass(); |
274 | 268 |
275 user_prefs::UserPrefs::Set(this, user_pref_service_.get()); | 269 user_prefs::UserPrefs::Set(this, user_pref_service_.get()); |
276 | 270 |
277 if (data_reduction_proxy_settings_) { | 271 if (data_reduction_proxy_settings_) { |
278 data_reduction_proxy_settings_->InitDataReductionProxySettings( | 272 data_reduction_proxy_settings_->InitDataReductionProxySettings( |
279 user_pref_service_.get(), | 273 user_pref_service_.get(), data_reduction_proxy_io_data_.get(), |
280 scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>(), | 274 data_reduction_proxy_service_.Pass()); |
281 GetRequestContext(), | |
282 GetAwURLRequestContext()->GetNetLog(), | |
283 data_reduction_proxy_io_data_->event_store()); | |
284 data_reduction_proxy_settings_->MaybeActivateDataReductionProxy(true); | 275 data_reduction_proxy_settings_->MaybeActivateDataReductionProxy(true); |
285 | 276 |
286 SetDataReductionProxyEnabled(data_reduction_proxy_enabled_); | 277 SetDataReductionProxyEnabled(data_reduction_proxy_enabled_); |
287 } | 278 } |
288 } | 279 } |
289 | 280 |
290 scoped_ptr<content::ZoomLevelDelegate> | 281 scoped_ptr<content::ZoomLevelDelegate> |
291 AwBrowserContext::CreateZoomLevelDelegate( | 282 AwBrowserContext::CreateZoomLevelDelegate( |
292 const base::FilePath& partition_path) { | 283 const base::FilePath& partition_path) { |
293 return nullptr; | 284 return nullptr; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 const scoped_refptr<URLEnumerator>& enumerator) { | 359 const scoped_refptr<URLEnumerator>& enumerator) { |
369 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client | 360 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client |
370 // can change in the lifetime of this WebView and may not yet be set here. | 361 // can change in the lifetime of this WebView and may not yet be set here. |
371 // Therefore this initialization path is not used. | 362 // Therefore this initialization path is not used. |
372 enumerator->OnComplete(true); | 363 enumerator->OnComplete(true); |
373 } | 364 } |
374 | 365 |
375 void AwBrowserContext::CreateDataReductionProxyStatisticsIfNecessary() { | 366 void AwBrowserContext::CreateDataReductionProxyStatisticsIfNecessary() { |
376 DCHECK(user_pref_service_.get()); | 367 DCHECK(user_pref_service_.get()); |
377 DCHECK(GetDataReductionProxySettings()); | 368 DCHECK(GetDataReductionProxySettings()); |
378 if (GetDataReductionProxySettings()->statistics_prefs()) | 369 DCHECK(GetDataReductionProxySettings()->data_reduction_proxy_service()); |
bengr
2015/02/20 00:00:36
nit: You could introduce a local to hold GetDRPSet
jeremyim
2015/02/20 02:17:16
Done.
| |
370 if (GetDataReductionProxySettings()->data_reduction_proxy_service()-> | |
371 statistics_prefs()) | |
379 return; | 372 return; |
380 // We don't care about commit_delay for now. It is just a dummy value. | 373 // We don't care about commit_delay for now. It is just a dummy value. |
381 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); | 374 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); |
382 GetDataReductionProxySettings()->EnableCompressionStatisticsLogging( | 375 GetDataReductionProxySettings()->data_reduction_proxy_service()-> |
383 user_pref_service_.get(), | 376 EnableCompressionStatisticsLogging( |
384 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 377 user_pref_service_.get(), |
385 commit_delay); | 378 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
386 GetDataReductionProxyIOData()->SetDataReductionProxyStatisticsPrefs( | 379 commit_delay); |
387 GetDataReductionProxySettings()->statistics_prefs()); | |
388 } | 380 } |
389 | 381 |
390 } // namespace android_webview | 382 } // namespace android_webview |
OLD | NEW |