Chromium Code Reviews| 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_conf ig_service.h" | 21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf igurator.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_sett ings.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_stat istics_prefs.h" | 24 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat istics_prefs.h" |
| 25 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_event _store.h" | 25 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_event _store.h" |
| 26 #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" |
| 27 #include "components/user_prefs/user_prefs.h" | 27 #include "components/user_prefs/user_prefs.h" |
| 28 #include "components/visitedlink/browser/visitedlink_master.h" | 28 #include "components/visitedlink/browser/visitedlink_master.h" |
| 29 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
| 30 #include "content/public/browser/ssl_host_state_delegate.h" | 30 #include "content/public/browser/ssl_host_state_delegate.h" |
| 31 #include "content/public/browser/storage_partition.h" | 31 #include "content/public/browser/storage_partition.h" |
| 32 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" |
| 33 #include "net/cookies/cookie_store.h" | 33 #include "net/cookies/cookie_store.h" |
| 34 #include "net/proxy/proxy_config_service_android.h" | 34 #include "net/proxy/proxy_config_service_android.h" |
| 35 #include "net/proxy/proxy_service.h" | 35 #include "net/proxy/proxy_service.h" |
| 36 | 36 |
| 37 using base::FilePath; | 37 using base::FilePath; |
| 38 using content::BrowserThread; | 38 using content::BrowserThread; |
| 39 using data_reduction_proxy::DataReductionProxyConfigService; | 39 using data_reduction_proxy::DataReductionProxyConfigurator; |
| 40 using data_reduction_proxy::DataReductionProxyEventStore; | 40 using data_reduction_proxy::DataReductionProxyEventStore; |
| 41 using data_reduction_proxy::DataReductionProxySettings; | 41 using data_reduction_proxy::DataReductionProxySettings; |
| 42 | 42 |
| 43 namespace android_webview { | 43 namespace android_webview { |
| 44 | 44 |
| 45 namespace { | 45 namespace { |
| 46 | 46 |
| 47 // Shows notifications which correspond to PersistentPrefStore's reading errors. | 47 // Shows notifications which correspond to PersistentPrefStore's reading errors. |
| 48 void HandleReadError(PersistentPrefStore::PrefReadError error) { | 48 void HandleReadError(PersistentPrefStore::PrefReadError error) { |
| 49 } | 49 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 proxy_settings->SetDataReductionProxyEnabled(data_reduction_proxy_enabled_); | 128 proxy_settings->SetDataReductionProxyEnabled(data_reduction_proxy_enabled_); |
| 129 } | 129 } |
| 130 | 130 |
| 131 // static | 131 // static |
| 132 void AwBrowserContext::SetLegacyCacheRemovalDelayForTest(int delay_ms) { | 132 void AwBrowserContext::SetLegacyCacheRemovalDelayForTest(int delay_ms) { |
| 133 legacy_cache_removal_delay_ms_ = delay_ms; | 133 legacy_cache_removal_delay_ms_ = delay_ms; |
| 134 } | 134 } |
| 135 | 135 |
| 136 void AwBrowserContext::PreMainMessageLoopRun() { | 136 void AwBrowserContext::PreMainMessageLoopRun() { |
| 137 cookie_store_ = CreateCookieStore(this); | 137 cookie_store_ = CreateCookieStore(this); |
| 138 data_reduction_proxy_settings_.reset( | |
| 139 new DataReductionProxySettings( | |
| 140 new data_reduction_proxy::DataReductionProxyParams( | |
| 141 data_reduction_proxy::DataReductionProxyParams::kAllowed))); | |
| 142 data_reduction_proxy_event_store_.reset( | |
| 143 new DataReductionProxyEventStore( | |
| 144 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI))); | |
| 145 scoped_ptr<DataReductionProxyConfigService> | |
| 146 data_reduction_proxy_config_service( | |
| 147 new DataReductionProxyConfigService( | |
| 148 scoped_ptr<net::ProxyConfigService>( | |
| 149 CreateProxyConfigService()).Pass())); | |
| 150 if (data_reduction_proxy_settings_.get()) { | |
| 151 data_reduction_proxy_configurator_.reset( | |
| 152 new data_reduction_proxy::DataReductionProxyConfigTracker( | |
| 153 base::Bind(&DataReductionProxyConfigService::UpdateProxyConfig, | |
| 154 base::Unretained( | |
| 155 data_reduction_proxy_config_service.get())), | |
| 156 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | |
| 157 data_reduction_proxy_settings_->SetProxyConfigurator( | |
| 158 data_reduction_proxy_configurator_.get()); | |
| 159 } | |
| 160 | |
| 161 FilePath cache_path; | 138 FilePath cache_path; |
| 162 const FilePath fallback_cache_dir = | 139 const FilePath fallback_cache_dir = |
| 163 GetPath().Append(FILE_PATH_LITERAL("Cache")); | 140 GetPath().Append(FILE_PATH_LITERAL("Cache")); |
| 164 if (PathService::Get(base::DIR_CACHE, &cache_path)) { | 141 if (PathService::Get(base::DIR_CACHE, &cache_path)) { |
| 165 cache_path = cache_path.Append( | 142 cache_path = cache_path.Append( |
| 166 FILE_PATH_LITERAL("org.chromium.android_webview")); | 143 FILE_PATH_LITERAL("org.chromium.android_webview")); |
| 167 // Delay the legacy dir removal to not impact startup performance. | 144 // Delay the legacy dir removal to not impact startup performance. |
| 168 BrowserThread::PostDelayedTask( | 145 BrowserThread::PostDelayedTask( |
| 169 BrowserThread::FILE, FROM_HERE, | 146 BrowserThread::FILE, FROM_HERE, |
| 170 base::Bind(&DeleteDirRecursively, fallback_cache_dir), | 147 base::Bind(&DeleteDirRecursively, fallback_cache_dir), |
| 171 base::TimeDelta::FromMilliseconds(legacy_cache_removal_delay_ms_)); | 148 base::TimeDelta::FromMilliseconds(legacy_cache_removal_delay_ms_)); |
| 172 } else { | 149 } else { |
| 173 cache_path = fallback_cache_dir; | 150 cache_path = fallback_cache_dir; |
| 174 LOG(WARNING) << "Failed to get cache directory for Android WebView. " | 151 LOG(WARNING) << "Failed to get cache directory for Android WebView. " |
| 175 << "Using app data directory as a fallback."; | 152 << "Using app data directory as a fallback."; |
| 176 } | 153 } |
| 177 url_request_context_getter_ = | 154 url_request_context_getter_ = |
| 178 new AwURLRequestContextGetter(cache_path, | 155 new AwURLRequestContextGetter( |
| 179 cookie_store_.get(), | 156 cache_path, cookie_store_.get(), |
| 180 data_reduction_proxy_config_service.Pass()); | 157 make_scoped_ptr(CreateProxyConfigService()).Pass()); |
| 158 | |
| 159 data_reduction_proxy_settings_.reset( | |
| 160 new DataReductionProxySettings( | |
| 161 new data_reduction_proxy::DataReductionProxyParams( | |
| 162 data_reduction_proxy::DataReductionProxyParams::kAllowed))); | |
| 163 data_reduction_proxy_event_store_.reset( | |
| 164 new DataReductionProxyEventStore( | |
| 165 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI))); | |
| 166 if (data_reduction_proxy_settings_.get()) { | |
|
sgurun-gerrit only
2015/01/06 19:43:57
why do we need this if?
bengr
2015/01/06 21:32:49
You are right. I was carrying over some cruft. Don
| |
| 167 data_reduction_proxy_configurator_.reset( | |
| 168 new data_reduction_proxy::DataReductionProxyConfigurator( | |
| 169 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | |
| 170 url_request_context_getter_->GetNetLog(), | |
| 171 data_reduction_proxy_event_store_.get())); | |
| 172 data_reduction_proxy_settings_->SetProxyConfigurator( | |
| 173 data_reduction_proxy_configurator_.get()); | |
| 174 } | |
| 181 | 175 |
| 182 visitedlink_master_.reset( | 176 visitedlink_master_.reset( |
| 183 new visitedlink::VisitedLinkMaster(this, this, false)); | 177 new visitedlink::VisitedLinkMaster(this, this, false)); |
| 184 visitedlink_master_->Init(); | 178 visitedlink_master_->Init(); |
| 185 | 179 |
| 186 form_database_service_.reset( | 180 form_database_service_.reset( |
| 187 new AwFormDatabaseService(context_storage_path_)); | 181 new AwFormDatabaseService(context_storage_path_)); |
| 188 } | 182 } |
| 189 | 183 |
| 190 void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) { | 184 void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 229 | 223 |
| 230 DataReductionProxySettings* AwBrowserContext::GetDataReductionProxySettings() { | 224 DataReductionProxySettings* AwBrowserContext::GetDataReductionProxySettings() { |
| 231 return data_reduction_proxy_settings_.get(); | 225 return data_reduction_proxy_settings_.get(); |
| 232 } | 226 } |
| 233 | 227 |
| 234 DataReductionProxyEventStore* | 228 DataReductionProxyEventStore* |
| 235 AwBrowserContext::GetDataReductionProxyEventStore() { | 229 AwBrowserContext::GetDataReductionProxyEventStore() { |
| 236 return data_reduction_proxy_event_store_.get(); | 230 return data_reduction_proxy_event_store_.get(); |
| 237 } | 231 } |
| 238 | 232 |
| 233 data_reduction_proxy::DataReductionProxyConfigurator* | |
| 234 AwBrowserContext::GetDataReductionProxyConfigurator() { | |
| 235 return data_reduction_proxy_configurator_.get(); | |
| 236 } | |
| 237 | |
| 239 AwURLRequestContextGetter* AwBrowserContext::GetAwURLRequestContext() { | 238 AwURLRequestContextGetter* AwBrowserContext::GetAwURLRequestContext() { |
| 240 return url_request_context_getter_.get(); | 239 return url_request_context_getter_.get(); |
| 241 } | 240 } |
| 242 | 241 |
| 243 // Create user pref service for autofill functionality. | 242 // Create user pref service for autofill functionality. |
| 244 void AwBrowserContext::CreateUserPrefServiceIfNecessary() { | 243 void AwBrowserContext::CreateUserPrefServiceIfNecessary() { |
| 245 if (user_pref_service_) | 244 if (user_pref_service_) |
| 246 return; | 245 return; |
| 247 | 246 |
| 248 PrefRegistrySimple* pref_registry = new PrefRegistrySimple(); | 247 PrefRegistrySimple* pref_registry = new PrefRegistrySimple(); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 data_reduction_proxy_statistics_ = | 369 data_reduction_proxy_statistics_ = |
| 371 scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>( | 370 scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>( |
| 372 new data_reduction_proxy::DataReductionProxyStatisticsPrefs( | 371 new data_reduction_proxy::DataReductionProxyStatisticsPrefs( |
| 373 user_pref_service_.get(), | 372 user_pref_service_.get(), |
| 374 base::MessageLoopProxy::current(), | 373 base::MessageLoopProxy::current(), |
| 375 commit_delay)); | 374 commit_delay)); |
| 376 } | 375 } |
| 377 } | 376 } |
| 378 | 377 |
| 379 } // namespace android_webview | 378 } // namespace android_webview |
| OLD | NEW |