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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 // anonymously identify logs. Every WebView-using app on every device | 258 // 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. | 259 // is given a GUID, stored in this file in the app's data directory. |
258 const FilePath guid_file_path = | 260 const FilePath guid_file_path = |
259 GetPath().Append(FILE_PATH_LITERAL("metrics_guid")); | 261 GetPath().Append(FILE_PATH_LITERAL("metrics_guid")); |
260 | 262 |
261 AwMetricsServiceClient::GetInstance()->Initialize( | 263 AwMetricsServiceClient::GetInstance()->Initialize( |
262 user_pref_service_.get(), | 264 user_pref_service_.get(), |
263 content::BrowserContext::GetDefaultStoragePartition(this)-> | 265 content::BrowserContext::GetDefaultStoragePartition(this)-> |
264 GetURLRequestContext(), | 266 GetURLRequestContext(), |
265 guid_file_path); | 267 guid_file_path); |
| 268 web_restriction_provider_.reset( |
| 269 new web_restrictions::WebRestrictionsClient()); |
| 270 pref_change_registrar_.Add( |
| 271 prefs::kWebRestrictionsAuthority, |
| 272 base::Bind(&AwBrowserContext::OnWebRestrictionsAuthorityChanged, |
| 273 base::Unretained(this))); |
| 274 web_restriction_provider_->SetAuthority( |
| 275 user_pref_service_->GetString(prefs::kWebRestrictionsAuthority)); |
| 276 } |
| 277 |
| 278 void AwBrowserContext::OnWebRestrictionsAuthorityChanged() { |
| 279 web_restriction_provider_->SetAuthority( |
| 280 user_pref_service_->GetString(prefs::kWebRestrictionsAuthority)); |
266 } | 281 } |
267 | 282 |
268 void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) { | 283 void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) { |
269 DCHECK(visitedlink_master_); | 284 DCHECK(visitedlink_master_); |
270 visitedlink_master_->AddURLs(urls); | 285 visitedlink_master_->AddURLs(urls); |
271 } | 286 } |
272 | 287 |
273 AwQuotaManagerBridge* AwBrowserContext::GetQuotaManagerBridge() { | 288 AwQuotaManagerBridge* AwBrowserContext::GetQuotaManagerBridge() { |
274 if (!quota_manager_bridge_.get()) { | 289 if (!quota_manager_bridge_.get()) { |
275 quota_manager_bridge_ = native_factory_->CreateAwQuotaManagerBridge(this); | 290 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 | 326 // the manager_delegate. We don't use the rest of Autofill, which is why it is |
312 // hardcoded as disabled here. | 327 // hardcoded as disabled here. |
313 pref_registry->RegisterBooleanPref(autofill::prefs::kAutofillEnabled, false); | 328 pref_registry->RegisterBooleanPref(autofill::prefs::kAutofillEnabled, false); |
314 pref_registry->RegisterBooleanPref(kDataReductionProxyEnabled, false); | 329 pref_registry->RegisterBooleanPref(kDataReductionProxyEnabled, false); |
315 data_reduction_proxy::RegisterSimpleProfilePrefs(pref_registry); | 330 data_reduction_proxy::RegisterSimpleProfilePrefs(pref_registry); |
316 policy::URLBlacklistManager::RegisterProfilePrefs(pref_registry); | 331 policy::URLBlacklistManager::RegisterProfilePrefs(pref_registry); |
317 | 332 |
318 pref_registry->RegisterStringPref(prefs::kAuthServerWhitelist, std::string()); | 333 pref_registry->RegisterStringPref(prefs::kAuthServerWhitelist, std::string()); |
319 pref_registry->RegisterStringPref(prefs::kAuthAndroidNegotiateAccountType, | 334 pref_registry->RegisterStringPref(prefs::kAuthAndroidNegotiateAccountType, |
320 std::string()); | 335 std::string()); |
| 336 pref_registry->RegisterStringPref(prefs::kWebRestrictionsAuthority, |
| 337 std::string()); |
321 | 338 |
322 metrics::MetricsService::RegisterPrefs(pref_registry); | 339 metrics::MetricsService::RegisterPrefs(pref_registry); |
323 | 340 |
324 PrefServiceFactory pref_service_factory; | 341 PrefServiceFactory pref_service_factory; |
325 pref_service_factory.set_user_prefs(make_scoped_refptr( | 342 pref_service_factory.set_user_prefs(make_scoped_refptr( |
326 new InMemoryPrefStore())); | 343 new InMemoryPrefStore())); |
327 pref_service_factory.set_managed_prefs( | 344 pref_service_factory.set_managed_prefs( |
328 make_scoped_refptr(new policy::ConfigurationPolicyPrefStore( | 345 make_scoped_refptr(new policy::ConfigurationPolicyPrefStore( |
329 browser_policy_connector_->GetPolicyService(), | 346 browser_policy_connector_->GetPolicyService(), |
330 browser_policy_connector_->GetHandlerList(), | 347 browser_policy_connector_->GetHandlerList(), |
331 policy::POLICY_LEVEL_MANDATORY))); | 348 policy::POLICY_LEVEL_MANDATORY))); |
332 pref_service_factory.set_read_error_callback(base::Bind(&HandleReadError)); | 349 pref_service_factory.set_read_error_callback(base::Bind(&HandleReadError)); |
333 user_pref_service_ = pref_service_factory.Create(pref_registry); | 350 user_pref_service_ = pref_service_factory.Create(pref_registry); |
| 351 pref_change_registrar_.Init(user_pref_service_.get()); |
334 | 352 |
335 user_prefs::UserPrefs::Set(this, user_pref_service_.get()); | 353 user_prefs::UserPrefs::Set(this, user_pref_service_.get()); |
336 } | 354 } |
337 | 355 |
338 std::unique_ptr<content::ZoomLevelDelegate> | 356 std::unique_ptr<content::ZoomLevelDelegate> |
339 AwBrowserContext::CreateZoomLevelDelegate( | 357 AwBrowserContext::CreateZoomLevelDelegate( |
340 const base::FilePath& partition_path) { | 358 const base::FilePath& partition_path) { |
341 return nullptr; | 359 return nullptr; |
342 } | 360 } |
343 | 361 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 return NULL; | 449 return NULL; |
432 } | 450 } |
433 | 451 |
434 policy::URLBlacklistManager* AwBrowserContext::GetURLBlacklistManager() { | 452 policy::URLBlacklistManager* AwBrowserContext::GetURLBlacklistManager() { |
435 // Should not be called until the end of PreMainMessageLoopRun, where | 453 // Should not be called until the end of PreMainMessageLoopRun, where |
436 // blacklist_manager_ is initialized. | 454 // blacklist_manager_ is initialized. |
437 DCHECK(blacklist_manager_); | 455 DCHECK(blacklist_manager_); |
438 return blacklist_manager_.get(); | 456 return blacklist_manager_.get(); |
439 } | 457 } |
440 | 458 |
| 459 web_restrictions::WebRestrictionsClient* |
| 460 AwBrowserContext::GetWebRestrictionProvider() { |
| 461 DCHECK(web_restriction_provider_); |
| 462 return web_restriction_provider_.get(); |
| 463 } |
| 464 |
441 void AwBrowserContext::RebuildTable( | 465 void AwBrowserContext::RebuildTable( |
442 const scoped_refptr<URLEnumerator>& enumerator) { | 466 const scoped_refptr<URLEnumerator>& enumerator) { |
443 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client | 467 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client |
444 // can change in the lifetime of this WebView and may not yet be set here. | 468 // can change in the lifetime of this WebView and may not yet be set here. |
445 // Therefore this initialization path is not used. | 469 // Therefore this initialization path is not used. |
446 enumerator->OnComplete(true); | 470 enumerator->OnComplete(true); |
447 } | 471 } |
448 | 472 |
449 void AwBrowserContext::CreateDataReductionProxyStatisticsIfNecessary() { | 473 void AwBrowserContext::CreateDataReductionProxyStatisticsIfNecessary() { |
450 DCHECK(user_pref_service_.get()); | 474 DCHECK(user_pref_service_.get()); |
451 DCHECK(GetDataReductionProxySettings()); | 475 DCHECK(GetDataReductionProxySettings()); |
452 data_reduction_proxy::DataReductionProxyService* | 476 data_reduction_proxy::DataReductionProxyService* |
453 data_reduction_proxy_service = | 477 data_reduction_proxy_service = |
454 GetDataReductionProxySettings()->data_reduction_proxy_service(); | 478 GetDataReductionProxySettings()->data_reduction_proxy_service(); |
455 DCHECK(data_reduction_proxy_service); | 479 DCHECK(data_reduction_proxy_service); |
456 if (data_reduction_proxy_service->compression_stats()) | 480 if (data_reduction_proxy_service->compression_stats()) |
457 return; | 481 return; |
458 // We don't care about commit_delay for now. It is just a dummy value. | 482 // We don't care about commit_delay for now. It is just a dummy value. |
459 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); | 483 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); |
460 data_reduction_proxy_service->EnableCompressionStatisticsLogging( | 484 data_reduction_proxy_service->EnableCompressionStatisticsLogging( |
461 user_pref_service_.get(), | 485 user_pref_service_.get(), |
462 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 486 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
463 commit_delay); | 487 commit_delay); |
464 } | 488 } |
465 | 489 |
466 } // namespace android_webview | 490 } // namespace android_webview |
OLD | NEW |