| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "android_webview/browser/aw_browser_policy_connector.h" | 9 #include "android_webview/browser/aw_browser_policy_connector.h" |
| 10 #include "android_webview/browser/aw_form_database_service.h" | 10 #include "android_webview/browser/aw_form_database_service.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv
ice.h" | 25 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv
ice.h" |
| 26 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" | 26 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" |
| 27 #include "components/data_reduction_proxy/core/browser/data_store.h" | 27 #include "components/data_reduction_proxy/core/browser/data_store.h" |
| 28 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" | 28 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" |
| 29 #include "components/metrics/metrics_service.h" | 29 #include "components/metrics/metrics_service.h" |
| 30 #include "components/policy/core/browser/browser_policy_connector_base.h" | 30 #include "components/policy/core/browser/browser_policy_connector_base.h" |
| 31 #include "components/policy/core/browser/configuration_policy_pref_store.h" | 31 #include "components/policy/core/browser/configuration_policy_pref_store.h" |
| 32 #include "components/policy/core/browser/url_blacklist_manager.h" | 32 #include "components/policy/core/browser/url_blacklist_manager.h" |
| 33 #include "components/pref_registry/pref_registry_syncable.h" | 33 #include "components/pref_registry/pref_registry_syncable.h" |
| 34 #include "components/prefs/in_memory_pref_store.h" | 34 #include "components/prefs/in_memory_pref_store.h" |
| 35 #include "components/prefs/pref_change_registrar.h" |
| 35 #include "components/prefs/pref_service.h" | 36 #include "components/prefs/pref_service.h" |
| 36 #include "components/prefs/pref_service_factory.h" | 37 #include "components/prefs/pref_service_factory.h" |
| 37 #include "components/url_formatter/url_fixer.h" | 38 #include "components/url_formatter/url_fixer.h" |
| 38 #include "components/user_prefs/user_prefs.h" | 39 #include "components/user_prefs/user_prefs.h" |
| 39 #include "components/visitedlink/browser/visitedlink_master.h" | 40 #include "components/visitedlink/browser/visitedlink_master.h" |
| 40 #include "content/public/browser/browser_thread.h" | 41 #include "content/public/browser/browser_thread.h" |
| 41 #include "content/public/browser/ssl_host_state_delegate.h" | 42 #include "content/public/browser/ssl_host_state_delegate.h" |
| 42 #include "content/public/browser/storage_partition.h" | 43 #include "content/public/browser/storage_partition.h" |
| 43 #include "content/public/browser/web_contents.h" | 44 #include "content/public/browser/web_contents.h" |
| 44 #include "net/proxy/proxy_config_service_android.h" | 45 #include "net/proxy/proxy_config_service_android.h" |
| 45 #include "net/proxy/proxy_service.h" | 46 #include "net/proxy/proxy_service.h" |
| 46 | 47 |
| 47 using base::FilePath; | 48 using base::FilePath; |
| 48 using content::BrowserThread; | 49 using content::BrowserThread; |
| 49 | 50 |
| 50 namespace android_webview { | 51 namespace android_webview { |
| 51 | 52 |
| 52 namespace prefs { | 53 namespace prefs { |
| 53 | 54 |
| 54 // String that specifies the Android account type to use for Negotiate | 55 // String that specifies the Android account type to use for Negotiate |
| 55 // authentication. | 56 // authentication. |
| 56 const char kAuthAndroidNegotiateAccountType[] = | 57 const char kAuthAndroidNegotiateAccountType[] = |
| 57 "auth.android_negotiate_account_type"; | 58 "auth.android_negotiate_account_type"; |
| 58 | 59 |
| 59 // Whitelist containing servers for which Integrated Authentication is enabled. | 60 // Whitelist containing servers for which Integrated Authentication is enabled. |
| 60 const char kAuthServerWhitelist[] = "auth.server_whitelist"; | 61 const char kAuthServerWhitelist[] = "auth.server_whitelist"; |
| 61 | 62 |
| 63 const char kWebRestrictionsAuthority[] = "web_restrictions_authority"; |
| 64 |
| 62 } // namespace prefs | 65 } // namespace prefs |
| 63 | 66 |
| 64 namespace { | 67 namespace { |
| 65 // Name of the preference that governs enabling the Data Reduction Proxy. | 68 // Name of the preference that governs enabling the Data Reduction Proxy. |
| 66 const char kDataReductionProxyEnabled[] = "data_reduction_proxy.enabled"; | 69 const char kDataReductionProxyEnabled[] = "data_reduction_proxy.enabled"; |
| 67 | 70 |
| 68 // Shows notifications which correspond to PersistentPrefStore's reading errors. | 71 // Shows notifications which correspond to PersistentPrefStore's reading errors. |
| 69 void HandleReadError(PersistentPrefStore::PrefReadError error) { | 72 void HandleReadError(PersistentPrefStore::PrefReadError error) { |
| 70 } | 73 } |
| 71 | 74 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 // anonymously identify logs. Every WebView-using app on every device | 259 // anonymously identify logs. Every WebView-using app on every device |
| 257 // is given a GUID, stored in this file in the app's data directory. | 260 // is given a GUID, stored in this file in the app's data directory. |
| 258 const FilePath guid_file_path = | 261 const FilePath guid_file_path = |
| 259 GetPath().Append(FILE_PATH_LITERAL("metrics_guid")); | 262 GetPath().Append(FILE_PATH_LITERAL("metrics_guid")); |
| 260 | 263 |
| 261 AwMetricsServiceClient::GetInstance()->Initialize( | 264 AwMetricsServiceClient::GetInstance()->Initialize( |
| 262 user_pref_service_.get(), | 265 user_pref_service_.get(), |
| 263 content::BrowserContext::GetDefaultStoragePartition(this)-> | 266 content::BrowserContext::GetDefaultStoragePartition(this)-> |
| 264 GetURLRequestContext(), | 267 GetURLRequestContext(), |
| 265 guid_file_path); | 268 guid_file_path); |
| 269 web_restriction_provider_.reset( |
| 270 new web_restrictions::WebRestrictionsClient()); |
| 271 pref_change_registrar_->Add( |
| 272 prefs::kWebRestrictionsAuthority, |
| 273 base::Bind(&AwBrowserContext::OnWebRestrictionsAuthorityChanged, |
| 274 base::Unretained(this))); |
| 275 web_restriction_provider_->SetAuthority( |
| 276 user_pref_service_->GetString(prefs::kWebRestrictionsAuthority)); |
| 277 } |
| 278 |
| 279 void AwBrowserContext::OnWebRestrictionsAuthorityChanged() { |
| 280 web_restriction_provider_->SetAuthority( |
| 281 user_pref_service_->GetString(prefs::kWebRestrictionsAuthority)); |
| 266 } | 282 } |
| 267 | 283 |
| 268 void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) { | 284 void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) { |
| 269 DCHECK(visitedlink_master_); | 285 DCHECK(visitedlink_master_); |
| 270 visitedlink_master_->AddURLs(urls); | 286 visitedlink_master_->AddURLs(urls); |
| 271 } | 287 } |
| 272 | 288 |
| 273 AwQuotaManagerBridge* AwBrowserContext::GetQuotaManagerBridge() { | 289 AwQuotaManagerBridge* AwBrowserContext::GetQuotaManagerBridge() { |
| 274 if (!quota_manager_bridge_.get()) { | 290 if (!quota_manager_bridge_.get()) { |
| 275 quota_manager_bridge_ = native_factory_->CreateAwQuotaManagerBridge(this); | 291 quota_manager_bridge_ = native_factory_->CreateAwQuotaManagerBridge(this); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 // the manager_delegate. We don't use the rest of Autofill, which is why it is | 327 // the manager_delegate. We don't use the rest of Autofill, which is why it is |
| 312 // hardcoded as disabled here. | 328 // hardcoded as disabled here. |
| 313 pref_registry->RegisterBooleanPref(autofill::prefs::kAutofillEnabled, false); | 329 pref_registry->RegisterBooleanPref(autofill::prefs::kAutofillEnabled, false); |
| 314 pref_registry->RegisterBooleanPref(kDataReductionProxyEnabled, false); | 330 pref_registry->RegisterBooleanPref(kDataReductionProxyEnabled, false); |
| 315 data_reduction_proxy::RegisterSimpleProfilePrefs(pref_registry); | 331 data_reduction_proxy::RegisterSimpleProfilePrefs(pref_registry); |
| 316 policy::URLBlacklistManager::RegisterProfilePrefs(pref_registry); | 332 policy::URLBlacklistManager::RegisterProfilePrefs(pref_registry); |
| 317 | 333 |
| 318 pref_registry->RegisterStringPref(prefs::kAuthServerWhitelist, std::string()); | 334 pref_registry->RegisterStringPref(prefs::kAuthServerWhitelist, std::string()); |
| 319 pref_registry->RegisterStringPref(prefs::kAuthAndroidNegotiateAccountType, | 335 pref_registry->RegisterStringPref(prefs::kAuthAndroidNegotiateAccountType, |
| 320 std::string()); | 336 std::string()); |
| 337 pref_registry->RegisterStringPref(prefs::kWebRestrictionsAuthority, |
| 338 std::string()); |
| 321 | 339 |
| 322 metrics::MetricsService::RegisterPrefs(pref_registry); | 340 metrics::MetricsService::RegisterPrefs(pref_registry); |
| 323 | 341 |
| 324 PrefServiceFactory pref_service_factory; | 342 PrefServiceFactory pref_service_factory; |
| 325 pref_service_factory.set_user_prefs(make_scoped_refptr( | 343 pref_service_factory.set_user_prefs(make_scoped_refptr( |
| 326 new InMemoryPrefStore())); | 344 new InMemoryPrefStore())); |
| 327 pref_service_factory.set_managed_prefs( | 345 pref_service_factory.set_managed_prefs( |
| 328 make_scoped_refptr(new policy::ConfigurationPolicyPrefStore( | 346 make_scoped_refptr(new policy::ConfigurationPolicyPrefStore( |
| 329 browser_policy_connector_->GetPolicyService(), | 347 browser_policy_connector_->GetPolicyService(), |
| 330 browser_policy_connector_->GetHandlerList(), | 348 browser_policy_connector_->GetHandlerList(), |
| 331 policy::POLICY_LEVEL_MANDATORY))); | 349 policy::POLICY_LEVEL_MANDATORY))); |
| 332 pref_service_factory.set_read_error_callback(base::Bind(&HandleReadError)); | 350 pref_service_factory.set_read_error_callback(base::Bind(&HandleReadError)); |
| 333 user_pref_service_ = pref_service_factory.Create(pref_registry); | 351 user_pref_service_ = pref_service_factory.Create(pref_registry); |
| 352 pref_change_registrar_.reset(new PrefChangeRegistrar); |
| 353 pref_change_registrar_->Init(user_pref_service_.get()); |
| 334 | 354 |
| 335 user_prefs::UserPrefs::Set(this, user_pref_service_.get()); | 355 user_prefs::UserPrefs::Set(this, user_pref_service_.get()); |
| 336 } | 356 } |
| 337 | 357 |
| 338 std::unique_ptr<content::ZoomLevelDelegate> | 358 std::unique_ptr<content::ZoomLevelDelegate> |
| 339 AwBrowserContext::CreateZoomLevelDelegate( | 359 AwBrowserContext::CreateZoomLevelDelegate( |
| 340 const base::FilePath& partition_path) { | 360 const base::FilePath& partition_path) { |
| 341 return nullptr; | 361 return nullptr; |
| 342 } | 362 } |
| 343 | 363 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 return NULL; | 451 return NULL; |
| 432 } | 452 } |
| 433 | 453 |
| 434 policy::URLBlacklistManager* AwBrowserContext::GetURLBlacklistManager() { | 454 policy::URLBlacklistManager* AwBrowserContext::GetURLBlacklistManager() { |
| 435 // Should not be called until the end of PreMainMessageLoopRun, where | 455 // Should not be called until the end of PreMainMessageLoopRun, where |
| 436 // blacklist_manager_ is initialized. | 456 // blacklist_manager_ is initialized. |
| 437 DCHECK(blacklist_manager_); | 457 DCHECK(blacklist_manager_); |
| 438 return blacklist_manager_.get(); | 458 return blacklist_manager_.get(); |
| 439 } | 459 } |
| 440 | 460 |
| 461 web_restrictions::WebRestrictionsClient* |
| 462 AwBrowserContext::GetWebRestrictionProvider() { |
| 463 DCHECK(web_restriction_provider_); |
| 464 return web_restriction_provider_.get(); |
| 465 } |
| 466 |
| 441 void AwBrowserContext::RebuildTable( | 467 void AwBrowserContext::RebuildTable( |
| 442 const scoped_refptr<URLEnumerator>& enumerator) { | 468 const scoped_refptr<URLEnumerator>& enumerator) { |
| 443 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client | 469 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client |
| 444 // can change in the lifetime of this WebView and may not yet be set here. | 470 // can change in the lifetime of this WebView and may not yet be set here. |
| 445 // Therefore this initialization path is not used. | 471 // Therefore this initialization path is not used. |
| 446 enumerator->OnComplete(true); | 472 enumerator->OnComplete(true); |
| 447 } | 473 } |
| 448 | 474 |
| 449 void AwBrowserContext::CreateDataReductionProxyStatisticsIfNecessary() { | 475 void AwBrowserContext::CreateDataReductionProxyStatisticsIfNecessary() { |
| 450 DCHECK(user_pref_service_.get()); | 476 DCHECK(user_pref_service_.get()); |
| 451 DCHECK(GetDataReductionProxySettings()); | 477 DCHECK(GetDataReductionProxySettings()); |
| 452 data_reduction_proxy::DataReductionProxyService* | 478 data_reduction_proxy::DataReductionProxyService* |
| 453 data_reduction_proxy_service = | 479 data_reduction_proxy_service = |
| 454 GetDataReductionProxySettings()->data_reduction_proxy_service(); | 480 GetDataReductionProxySettings()->data_reduction_proxy_service(); |
| 455 DCHECK(data_reduction_proxy_service); | 481 DCHECK(data_reduction_proxy_service); |
| 456 if (data_reduction_proxy_service->compression_stats()) | 482 if (data_reduction_proxy_service->compression_stats()) |
| 457 return; | 483 return; |
| 458 // We don't care about commit_delay for now. It is just a dummy value. | 484 // We don't care about commit_delay for now. It is just a dummy value. |
| 459 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); | 485 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); |
| 460 data_reduction_proxy_service->EnableCompressionStatisticsLogging( | 486 data_reduction_proxy_service->EnableCompressionStatisticsLogging( |
| 461 user_pref_service_.get(), | 487 user_pref_service_.get(), |
| 462 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 488 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
| 463 commit_delay); | 489 commit_delay); |
| 464 } | 490 } |
| 465 | 491 |
| 466 } // namespace android_webview | 492 } // namespace android_webview |
| OLD | NEW |