| 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" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 if (context == NULL || context->user_pref_service_.get() == NULL) | 118 if (context == NULL || context->user_pref_service_.get() == NULL) |
| 119 return; | 119 return; |
| 120 data_reduction_proxy::DataReductionProxySettings* proxy_settings = | 120 data_reduction_proxy::DataReductionProxySettings* proxy_settings = |
| 121 context->GetDataReductionProxySettings(); | 121 context->GetDataReductionProxySettings(); |
| 122 if (proxy_settings == NULL) | 122 if (proxy_settings == NULL) |
| 123 return; | 123 return; |
| 124 // At this point, context->PreMainMessageLoopRun() has run, so | 124 // At this point, context->PreMainMessageLoopRun() has run, so |
| 125 // context->data_reduction_proxy_io_data() is valid. | 125 // context->data_reduction_proxy_io_data() is valid. |
| 126 DCHECK(context->GetDataReductionProxyIOData()); | 126 DCHECK(context->GetDataReductionProxyIOData()); |
| 127 context->CreateDataReductionProxyStatisticsIfNecessary(); | 127 context->CreateDataReductionProxyStatisticsIfNecessary(); |
| 128 proxy_settings->SetDataReductionProxyStatisticsPrefs( | |
| 129 context->GetDataReductionProxyIOData()->statistics_prefs()); | |
| 130 proxy_settings->SetDataReductionProxyEnabled(data_reduction_proxy_enabled_); | 128 proxy_settings->SetDataReductionProxyEnabled(data_reduction_proxy_enabled_); |
| 131 } | 129 } |
| 132 | 130 |
| 133 // static | 131 // static |
| 134 void AwBrowserContext::SetLegacyCacheRemovalDelayForTest(int delay_ms) { | 132 void AwBrowserContext::SetLegacyCacheRemovalDelayForTest(int delay_ms) { |
| 135 legacy_cache_removal_delay_ms_ = delay_ms; | 133 legacy_cache_removal_delay_ms_ = delay_ms; |
| 136 } | 134 } |
| 137 | 135 |
| 138 void AwBrowserContext::PreMainMessageLoopRun() { | 136 void AwBrowserContext::PreMainMessageLoopRun() { |
| 139 cookie_store_ = CreateCookieStore(this); | 137 cookie_store_ = CreateCookieStore(this); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 160 | 158 |
| 161 data_reduction_proxy_settings_.reset( | 159 data_reduction_proxy_settings_.reset( |
| 162 new data_reduction_proxy::DataReductionProxySettings( | 160 new data_reduction_proxy::DataReductionProxySettings( |
| 163 scoped_ptr<data_reduction_proxy::DataReductionProxyParams>( | 161 scoped_ptr<data_reduction_proxy::DataReductionProxyParams>( |
| 164 new data_reduction_proxy::DataReductionProxyParams( | 162 new data_reduction_proxy::DataReductionProxyParams( |
| 165 data_reduction_proxy::DataReductionProxyParams::kAllowed)) | 163 data_reduction_proxy::DataReductionProxyParams::kAllowed)) |
| 166 .Pass())); | 164 .Pass())); |
| 167 data_reduction_proxy_io_data_.reset( | 165 data_reduction_proxy_io_data_.reset( |
| 168 new data_reduction_proxy::DataReductionProxyIOData( | 166 new data_reduction_proxy::DataReductionProxyIOData( |
| 169 data_reduction_proxy::Client::WEBVIEW_ANDROID, | 167 data_reduction_proxy::Client::WEBVIEW_ANDROID, |
| 170 scoped_ptr< | 168 scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>(), |
| 171 data_reduction_proxy::DataReductionProxyStatisticsPrefs>(), | |
| 172 data_reduction_proxy_settings_.get(), | 169 data_reduction_proxy_settings_.get(), |
| 173 url_request_context_getter_->GetNetLog(), | 170 url_request_context_getter_->GetNetLog(), |
| 174 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | 171 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |
| 175 BrowserThread::GetMessageLoopProxyForThread( | 172 BrowserThread::GetMessageLoopProxyForThread( |
| 176 BrowserThread::UI))); | 173 BrowserThread::UI))); |
| 177 data_reduction_proxy_settings_->SetProxyConfigurator( | 174 data_reduction_proxy_settings_->SetProxyConfigurator( |
| 178 data_reduction_proxy_io_data_->configurator()); | 175 data_reduction_proxy_io_data_->configurator()); |
| 179 | 176 |
| 180 visitedlink_master_.reset( | 177 visitedlink_master_.reset( |
| 181 new visitedlink::VisitedLinkMaster(this, this, false)); | 178 new visitedlink::VisitedLinkMaster(this, this, false)); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 base::PrefServiceFactory pref_service_factory; | 269 base::PrefServiceFactory pref_service_factory; |
| 273 pref_service_factory.set_user_prefs(make_scoped_refptr(new AwPrefStore())); | 270 pref_service_factory.set_user_prefs(make_scoped_refptr(new AwPrefStore())); |
| 274 pref_service_factory.set_read_error_callback(base::Bind(&HandleReadError)); | 271 pref_service_factory.set_read_error_callback(base::Bind(&HandleReadError)); |
| 275 user_pref_service_ = pref_service_factory.Create(pref_registry).Pass(); | 272 user_pref_service_ = pref_service_factory.Create(pref_registry).Pass(); |
| 276 | 273 |
| 277 user_prefs::UserPrefs::Set(this, user_pref_service_.get()); | 274 user_prefs::UserPrefs::Set(this, user_pref_service_.get()); |
| 278 | 275 |
| 279 if (data_reduction_proxy_settings_) { | 276 if (data_reduction_proxy_settings_) { |
| 280 data_reduction_proxy_settings_->InitDataReductionProxySettings( | 277 data_reduction_proxy_settings_->InitDataReductionProxySettings( |
| 281 user_pref_service_.get(), | 278 user_pref_service_.get(), |
| 279 scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>(), |
| 282 GetRequestContext(), | 280 GetRequestContext(), |
| 283 GetAwURLRequestContext()->GetNetLog(), | 281 GetAwURLRequestContext()->GetNetLog(), |
| 284 data_reduction_proxy_io_data_->event_store()); | 282 data_reduction_proxy_io_data_->event_store()); |
| 285 data_reduction_proxy_settings_->MaybeActivateDataReductionProxy(true); | 283 data_reduction_proxy_settings_->MaybeActivateDataReductionProxy(true); |
| 286 | 284 |
| 287 SetDataReductionProxyEnabled(data_reduction_proxy_enabled_); | 285 SetDataReductionProxyEnabled(data_reduction_proxy_enabled_); |
| 288 } | 286 } |
| 289 } | 287 } |
| 290 | 288 |
| 291 scoped_ptr<content::ZoomLevelDelegate> | 289 scoped_ptr<content::ZoomLevelDelegate> |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 void AwBrowserContext::RebuildTable( | 366 void AwBrowserContext::RebuildTable( |
| 369 const scoped_refptr<URLEnumerator>& enumerator) { | 367 const scoped_refptr<URLEnumerator>& enumerator) { |
| 370 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client | 368 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client |
| 371 // can change in the lifetime of this WebView and may not yet be set here. | 369 // can change in the lifetime of this WebView and may not yet be set here. |
| 372 // Therefore this initialization path is not used. | 370 // Therefore this initialization path is not used. |
| 373 enumerator->OnComplete(true); | 371 enumerator->OnComplete(true); |
| 374 } | 372 } |
| 375 | 373 |
| 376 void AwBrowserContext::CreateDataReductionProxyStatisticsIfNecessary() { | 374 void AwBrowserContext::CreateDataReductionProxyStatisticsIfNecessary() { |
| 377 DCHECK(user_pref_service_.get()); | 375 DCHECK(user_pref_service_.get()); |
| 378 DCHECK(GetDataReductionProxyIOData()); | 376 DCHECK(GetDataReductionProxySettings()); |
| 379 if (GetDataReductionProxyIOData()->statistics_prefs()) | 377 if (GetDataReductionProxySettings()->statistics_prefs()) |
| 380 return; | 378 return; |
| 381 // We don't care about commit_delay for now. It is just a dummy value. | 379 // We don't care about commit_delay for now. It is just a dummy value. |
| 382 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); | 380 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); |
| 383 GetDataReductionProxyIOData()->EnableCompressionStatisticsLogging( | 381 GetDataReductionProxySettings()->EnableCompressionStatisticsLogging( |
| 384 user_pref_service_.get(), commit_delay); | 382 user_pref_service_.get(), |
| 383 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
| 384 commit_delay); |
| 385 GetDataReductionProxyIOData()->SetDataReductionProxyStatisticsPrefs( |
| 386 GetDataReductionProxySettings()->statistics_prefs()); |
| 385 } | 387 } |
| 386 | 388 |
| 387 } // namespace android_webview | 389 } // namespace android_webview |
| OLD | NEW |