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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 namespace prefs { | 52 namespace prefs { |
53 | 53 |
54 // String that specifies the Android account type to use for Negotiate | 54 // String that specifies the Android account type to use for Negotiate |
55 // authentication. | 55 // authentication. |
56 const char kAuthAndroidNegotiateAccountType[] = | 56 const char kAuthAndroidNegotiateAccountType[] = |
57 "auth.android_negotiate_account_type"; | 57 "auth.android_negotiate_account_type"; |
58 | 58 |
59 // Whitelist containing servers for which Integrated Authentication is enabled. | 59 // Whitelist containing servers for which Integrated Authentication is enabled. |
60 const char kAuthServerWhitelist[] = "auth.server_whitelist"; | 60 const char kAuthServerWhitelist[] = "auth.server_whitelist"; |
61 | 61 |
| 62 const char kWebRestrictionsAuthority[] = "web_restrictions_authority"; |
| 63 |
62 } // namespace prefs | 64 } // namespace prefs |
63 | 65 |
64 namespace { | 66 namespace { |
65 // Name of the preference that governs enabling the Data Reduction Proxy. | 67 // Name of the preference that governs enabling the Data Reduction Proxy. |
66 const char kDataReductionProxyEnabled[] = "data_reduction_proxy.enabled"; | 68 const char kDataReductionProxyEnabled[] = "data_reduction_proxy.enabled"; |
67 | 69 |
68 // Shows notifications which correspond to PersistentPrefStore's reading errors. | 70 // Shows notifications which correspond to PersistentPrefStore's reading errors. |
69 void HandleReadError(PersistentPrefStore::PrefReadError error) { | 71 void HandleReadError(PersistentPrefStore::PrefReadError error) { |
70 } | 72 } |
71 | 73 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 | 257 |
256 // UMA uses randomly-generated GUIDs (globally unique identifiers) to | 258 // UMA uses randomly-generated GUIDs (globally unique identifiers) to |
257 // anonymously identify logs. Every WebView-using app on every device | 259 // anonymously identify logs. Every WebView-using app on every device |
258 // 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. |
259 const FilePath guid_file_path = | 261 const FilePath guid_file_path = |
260 GetPath().Append(FILE_PATH_LITERAL("metrics_guid")); | 262 GetPath().Append(FILE_PATH_LITERAL("metrics_guid")); |
261 | 263 |
262 AwMetricsServiceClient::GetInstance()->Initialize(user_pref_service_.get(), | 264 AwMetricsServiceClient::GetInstance()->Initialize(user_pref_service_.get(), |
263 GetRequestContext(), | 265 GetRequestContext(), |
264 guid_file_path); | 266 guid_file_path); |
| 267 web_restriction_provider_.reset( |
| 268 new web_restrictions::WebRestrictionsClient()); |
| 269 web_restrictions_authority_.Init( |
| 270 prefs::kWebRestrictionsAuthority, user_pref_service_.get(), |
| 271 base::Bind(&AwBrowserContext::OnWebRestrictionsAuthorityChanged, |
| 272 base::Unretained(this))); |
| 273 web_restriction_provider_->SetAuthority( |
| 274 web_restrictions_authority_.GetValue()); |
| 275 } |
| 276 |
| 277 void AwBrowserContext::OnWebRestrictionsAuthorityChanged() { |
| 278 web_restriction_provider_->SetAuthority( |
| 279 web_restrictions_authority_.GetValue()); |
265 } | 280 } |
266 | 281 |
267 void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) { | 282 void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) { |
268 DCHECK(visitedlink_master_); | 283 DCHECK(visitedlink_master_); |
269 visitedlink_master_->AddURLs(urls); | 284 visitedlink_master_->AddURLs(urls); |
270 } | 285 } |
271 | 286 |
272 AwQuotaManagerBridge* AwBrowserContext::GetQuotaManagerBridge() { | 287 AwQuotaManagerBridge* AwBrowserContext::GetQuotaManagerBridge() { |
273 if (!quota_manager_bridge_.get()) { | 288 if (!quota_manager_bridge_.get()) { |
274 quota_manager_bridge_ = native_factory_->CreateAwQuotaManagerBridge(this); | 289 quota_manager_bridge_ = native_factory_->CreateAwQuotaManagerBridge(this); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 // the manager_delegate. We don't use the rest of Autofill, which is why it is | 325 // the manager_delegate. We don't use the rest of Autofill, which is why it is |
311 // hardcoded as disabled here. | 326 // hardcoded as disabled here. |
312 pref_registry->RegisterBooleanPref(autofill::prefs::kAutofillEnabled, false); | 327 pref_registry->RegisterBooleanPref(autofill::prefs::kAutofillEnabled, false); |
313 pref_registry->RegisterBooleanPref(kDataReductionProxyEnabled, false); | 328 pref_registry->RegisterBooleanPref(kDataReductionProxyEnabled, false); |
314 data_reduction_proxy::RegisterSimpleProfilePrefs(pref_registry); | 329 data_reduction_proxy::RegisterSimpleProfilePrefs(pref_registry); |
315 policy::URLBlacklistManager::RegisterProfilePrefs(pref_registry); | 330 policy::URLBlacklistManager::RegisterProfilePrefs(pref_registry); |
316 | 331 |
317 pref_registry->RegisterStringPref(prefs::kAuthServerWhitelist, std::string()); | 332 pref_registry->RegisterStringPref(prefs::kAuthServerWhitelist, std::string()); |
318 pref_registry->RegisterStringPref(prefs::kAuthAndroidNegotiateAccountType, | 333 pref_registry->RegisterStringPref(prefs::kAuthAndroidNegotiateAccountType, |
319 std::string()); | 334 std::string()); |
| 335 pref_registry->RegisterStringPref(prefs::kWebRestrictionsAuthority, |
| 336 std::string()); |
320 | 337 |
321 metrics::MetricsService::RegisterPrefs(pref_registry); | 338 metrics::MetricsService::RegisterPrefs(pref_registry); |
322 | 339 |
323 PrefServiceFactory pref_service_factory; | 340 PrefServiceFactory pref_service_factory; |
324 pref_service_factory.set_user_prefs(make_scoped_refptr(new AwPrefStore())); | 341 pref_service_factory.set_user_prefs(make_scoped_refptr(new AwPrefStore())); |
325 pref_service_factory.set_managed_prefs( | 342 pref_service_factory.set_managed_prefs( |
326 make_scoped_refptr(new policy::ConfigurationPolicyPrefStore( | 343 make_scoped_refptr(new policy::ConfigurationPolicyPrefStore( |
327 browser_policy_connector_->GetPolicyService(), | 344 browser_policy_connector_->GetPolicyService(), |
328 browser_policy_connector_->GetHandlerList(), | 345 browser_policy_connector_->GetHandlerList(), |
329 policy::POLICY_LEVEL_MANDATORY))); | 346 policy::POLICY_LEVEL_MANDATORY))); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 return NULL; | 456 return NULL; |
440 } | 457 } |
441 | 458 |
442 policy::URLBlacklistManager* AwBrowserContext::GetURLBlacklistManager() { | 459 policy::URLBlacklistManager* AwBrowserContext::GetURLBlacklistManager() { |
443 // Should not be called until the end of PreMainMessageLoopRun, where | 460 // Should not be called until the end of PreMainMessageLoopRun, where |
444 // blacklist_manager_ is initialized. | 461 // blacklist_manager_ is initialized. |
445 DCHECK(blacklist_manager_); | 462 DCHECK(blacklist_manager_); |
446 return blacklist_manager_.get(); | 463 return blacklist_manager_.get(); |
447 } | 464 } |
448 | 465 |
| 466 web_restrictions::WebRestrictionsClient* |
| 467 AwBrowserContext::GetWebRestrictionProvider() { |
| 468 DCHECK(web_restriction_provider_); |
| 469 return web_restriction_provider_.get(); |
| 470 } |
| 471 |
449 void AwBrowserContext::RebuildTable( | 472 void AwBrowserContext::RebuildTable( |
450 const scoped_refptr<URLEnumerator>& enumerator) { | 473 const scoped_refptr<URLEnumerator>& enumerator) { |
451 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client | 474 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client |
452 // can change in the lifetime of this WebView and may not yet be set here. | 475 // can change in the lifetime of this WebView and may not yet be set here. |
453 // Therefore this initialization path is not used. | 476 // Therefore this initialization path is not used. |
454 enumerator->OnComplete(true); | 477 enumerator->OnComplete(true); |
455 } | 478 } |
456 | 479 |
457 void AwBrowserContext::CreateDataReductionProxyStatisticsIfNecessary() { | 480 void AwBrowserContext::CreateDataReductionProxyStatisticsIfNecessary() { |
458 DCHECK(user_pref_service_.get()); | 481 DCHECK(user_pref_service_.get()); |
459 DCHECK(GetDataReductionProxySettings()); | 482 DCHECK(GetDataReductionProxySettings()); |
460 data_reduction_proxy::DataReductionProxyService* | 483 data_reduction_proxy::DataReductionProxyService* |
461 data_reduction_proxy_service = | 484 data_reduction_proxy_service = |
462 GetDataReductionProxySettings()->data_reduction_proxy_service(); | 485 GetDataReductionProxySettings()->data_reduction_proxy_service(); |
463 DCHECK(data_reduction_proxy_service); | 486 DCHECK(data_reduction_proxy_service); |
464 if (data_reduction_proxy_service->compression_stats()) | 487 if (data_reduction_proxy_service->compression_stats()) |
465 return; | 488 return; |
466 // We don't care about commit_delay for now. It is just a dummy value. | 489 // We don't care about commit_delay for now. It is just a dummy value. |
467 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); | 490 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); |
468 data_reduction_proxy_service->EnableCompressionStatisticsLogging( | 491 data_reduction_proxy_service->EnableCompressionStatisticsLogging( |
469 user_pref_service_.get(), | 492 user_pref_service_.get(), |
470 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 493 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
471 commit_delay); | 494 commit_delay); |
472 } | 495 } |
473 | 496 |
474 } // namespace android_webview | 497 } // namespace android_webview |
OLD | NEW |