Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(822)

Side by Side Diff: android_webview/browser/aw_browser_context.cc

Issue 1890203002: Implement Web Restrictions in WebView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Manual rebase, no other changes Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
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( 264 AwMetricsServiceClient::GetInstance()->Initialize(
263 user_pref_service_.get(), 265 user_pref_service_.get(),
264 content::BrowserContext::GetDefaultStoragePartition(this)-> 266 content::BrowserContext::GetDefaultStoragePartition(this)->
265 GetURLRequestContext(), 267 GetURLRequestContext(),
266 guid_file_path); 268 guid_file_path);
269 web_restriction_provider_.reset(
270 new web_restrictions::WebRestrictionsClient());
271 web_restrictions_authority_.Init(
272 prefs::kWebRestrictionsAuthority, user_pref_service_.get(),
273 base::Bind(&AwBrowserContext::OnWebRestrictionsAuthorityChanged,
274 base::Unretained(this)));
275 web_restriction_provider_->SetAuthority(
276 web_restrictions_authority_.GetValue());
277 }
278
279 void AwBrowserContext::OnWebRestrictionsAuthorityChanged() {
280 web_restriction_provider_->SetAuthority(
281 web_restrictions_authority_.GetValue());
267 } 282 }
268 283
269 void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) { 284 void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) {
270 DCHECK(visitedlink_master_); 285 DCHECK(visitedlink_master_);
271 visitedlink_master_->AddURLs(urls); 286 visitedlink_master_->AddURLs(urls);
272 } 287 }
273 288
274 AwQuotaManagerBridge* AwBrowserContext::GetQuotaManagerBridge() { 289 AwQuotaManagerBridge* AwBrowserContext::GetQuotaManagerBridge() {
275 if (!quota_manager_bridge_.get()) { 290 if (!quota_manager_bridge_.get()) {
276 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
312 // 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
313 // hardcoded as disabled here. 328 // hardcoded as disabled here.
314 pref_registry->RegisterBooleanPref(autofill::prefs::kAutofillEnabled, false); 329 pref_registry->RegisterBooleanPref(autofill::prefs::kAutofillEnabled, false);
315 pref_registry->RegisterBooleanPref(kDataReductionProxyEnabled, false); 330 pref_registry->RegisterBooleanPref(kDataReductionProxyEnabled, false);
316 data_reduction_proxy::RegisterSimpleProfilePrefs(pref_registry); 331 data_reduction_proxy::RegisterSimpleProfilePrefs(pref_registry);
317 policy::URLBlacklistManager::RegisterProfilePrefs(pref_registry); 332 policy::URLBlacklistManager::RegisterProfilePrefs(pref_registry);
318 333
319 pref_registry->RegisterStringPref(prefs::kAuthServerWhitelist, std::string()); 334 pref_registry->RegisterStringPref(prefs::kAuthServerWhitelist, std::string());
320 pref_registry->RegisterStringPref(prefs::kAuthAndroidNegotiateAccountType, 335 pref_registry->RegisterStringPref(prefs::kAuthAndroidNegotiateAccountType,
321 std::string()); 336 std::string());
337 pref_registry->RegisterStringPref(prefs::kWebRestrictionsAuthority,
338 std::string());
322 339
323 metrics::MetricsService::RegisterPrefs(pref_registry); 340 metrics::MetricsService::RegisterPrefs(pref_registry);
324 341
325 PrefServiceFactory pref_service_factory; 342 PrefServiceFactory pref_service_factory;
326 pref_service_factory.set_user_prefs(make_scoped_refptr(new AwPrefStore())); 343 pref_service_factory.set_user_prefs(make_scoped_refptr(new AwPrefStore()));
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)));
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 return NULL; 448 return NULL;
432 } 449 }
433 450
434 policy::URLBlacklistManager* AwBrowserContext::GetURLBlacklistManager() { 451 policy::URLBlacklistManager* AwBrowserContext::GetURLBlacklistManager() {
435 // Should not be called until the end of PreMainMessageLoopRun, where 452 // Should not be called until the end of PreMainMessageLoopRun, where
436 // blacklist_manager_ is initialized. 453 // blacklist_manager_ is initialized.
437 DCHECK(blacklist_manager_); 454 DCHECK(blacklist_manager_);
438 return blacklist_manager_.get(); 455 return blacklist_manager_.get();
439 } 456 }
440 457
458 web_restrictions::WebRestrictionsClient*
459 AwBrowserContext::GetWebRestrictionProvider() {
460 DCHECK(web_restriction_provider_);
461 return web_restriction_provider_.get();
462 }
463
441 void AwBrowserContext::RebuildTable( 464 void AwBrowserContext::RebuildTable(
442 const scoped_refptr<URLEnumerator>& enumerator) { 465 const scoped_refptr<URLEnumerator>& enumerator) {
443 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client 466 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client
444 // can change in the lifetime of this WebView and may not yet be set here. 467 // can change in the lifetime of this WebView and may not yet be set here.
445 // Therefore this initialization path is not used. 468 // Therefore this initialization path is not used.
446 enumerator->OnComplete(true); 469 enumerator->OnComplete(true);
447 } 470 }
448 471
449 void AwBrowserContext::CreateDataReductionProxyStatisticsIfNecessary() { 472 void AwBrowserContext::CreateDataReductionProxyStatisticsIfNecessary() {
450 DCHECK(user_pref_service_.get()); 473 DCHECK(user_pref_service_.get());
451 DCHECK(GetDataReductionProxySettings()); 474 DCHECK(GetDataReductionProxySettings());
452 data_reduction_proxy::DataReductionProxyService* 475 data_reduction_proxy::DataReductionProxyService*
453 data_reduction_proxy_service = 476 data_reduction_proxy_service =
454 GetDataReductionProxySettings()->data_reduction_proxy_service(); 477 GetDataReductionProxySettings()->data_reduction_proxy_service();
455 DCHECK(data_reduction_proxy_service); 478 DCHECK(data_reduction_proxy_service);
456 if (data_reduction_proxy_service->compression_stats()) 479 if (data_reduction_proxy_service->compression_stats())
457 return; 480 return;
458 // We don't care about commit_delay for now. It is just a dummy value. 481 // We don't care about commit_delay for now. It is just a dummy value.
459 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); 482 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60);
460 data_reduction_proxy_service->EnableCompressionStatisticsLogging( 483 data_reduction_proxy_service->EnableCompressionStatisticsLogging(
461 user_pref_service_.get(), 484 user_pref_service_.get(),
462 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), 485 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
463 commit_delay); 486 commit_delay);
464 } 487 }
465 488
466 } // namespace android_webview 489 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698