OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/policy/configuration_policy_handler_list_factory.h" | 5 #include "chrome/browser/policy/configuration_policy_handler_list_factory.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/prefs/pref_value_map.h" |
10 #include "base/values.h" | 11 #include "base/values.h" |
11 #include "chrome/browser/net/proxy_policy_handler.h" | 12 #include "chrome/browser/net/proxy_policy_handler.h" |
12 #include "chrome/browser/policy/managed_bookmarks_policy_handler.h" | 13 #include "chrome/browser/policy/managed_bookmarks_policy_handler.h" |
13 #include "chrome/browser/profiles/incognito_mode_policy_handler.h" | 14 #include "chrome/browser/profiles/incognito_mode_policy_handler.h" |
14 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
16 #include "components/password_manager/core/common/password_manager_pref_names.h" | 17 #include "components/password_manager/core/common/password_manager_pref_names.h" |
17 #include "components/policy/core/browser/autofill_policy_handler.h" | 18 #include "components/policy/core/browser/autofill_policy_handler.h" |
18 #include "components/policy/core/browser/configuration_policy_handler.h" | 19 #include "components/policy/core/browser/configuration_policy_handler.h" |
19 #include "components/policy/core/browser/configuration_policy_handler_list.h" | 20 #include "components/policy/core/browser/configuration_policy_handler_list.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 base::Value::TYPE_BOOLEAN }, | 93 base::Value::TYPE_BOOLEAN }, |
93 { key::kWPADQuickCheckEnabled, | 94 { key::kWPADQuickCheckEnabled, |
94 prefs::kQuickCheckEnabled, | 95 prefs::kQuickCheckEnabled, |
95 base::Value::TYPE_BOOLEAN }, | 96 base::Value::TYPE_BOOLEAN }, |
96 { key::kDisableSpdy, | 97 { key::kDisableSpdy, |
97 prefs::kDisableSpdy, | 98 prefs::kDisableSpdy, |
98 base::Value::TYPE_BOOLEAN }, | 99 base::Value::TYPE_BOOLEAN }, |
99 { key::kSafeBrowsingEnabled, | 100 { key::kSafeBrowsingEnabled, |
100 prefs::kSafeBrowsingEnabled, | 101 prefs::kSafeBrowsingEnabled, |
101 base::Value::TYPE_BOOLEAN }, | 102 base::Value::TYPE_BOOLEAN }, |
102 { key::kForceSafeSearch, | |
103 prefs::kForceSafeSearch, | |
104 base::Value::TYPE_BOOLEAN }, | |
105 { key::kForceGoogleSafeSearch, | 103 { key::kForceGoogleSafeSearch, |
106 prefs::kForceGoogleSafeSearch, | 104 prefs::kForceGoogleSafeSearch, |
107 base::Value::TYPE_BOOLEAN }, | 105 base::Value::TYPE_BOOLEAN }, |
108 { key::kForceYouTubeSafetyMode, | 106 { key::kForceYouTubeSafetyMode, |
109 prefs::kForceYouTubeSafetyMode, | 107 prefs::kForceYouTubeSafetyMode, |
110 base::Value::TYPE_BOOLEAN }, | 108 base::Value::TYPE_BOOLEAN }, |
111 { key::kPasswordManagerEnabled, | 109 { key::kPasswordManagerEnabled, |
112 password_manager::prefs::kPasswordManagerSavingEnabled, | 110 password_manager::prefs::kPasswordManagerSavingEnabled, |
113 base::Value::TYPE_BOOLEAN }, | 111 base::Value::TYPE_BOOLEAN }, |
114 { key::kPasswordManagerAllowShowPasswords, | 112 { key::kPasswordManagerAllowShowPasswords, |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 base::Value::TYPE_BOOLEAN }, | 494 base::Value::TYPE_BOOLEAN }, |
497 { key::kBrowserGuestModeEnabled, | 495 { key::kBrowserGuestModeEnabled, |
498 prefs::kBrowserGuestModeEnabled, | 496 prefs::kBrowserGuestModeEnabled, |
499 base::Value::TYPE_BOOLEAN }, | 497 base::Value::TYPE_BOOLEAN }, |
500 { key::kBrowserAddPersonEnabled, | 498 { key::kBrowserAddPersonEnabled, |
501 prefs::kBrowserAddPersonEnabled, | 499 prefs::kBrowserAddPersonEnabled, |
502 base::Value::TYPE_BOOLEAN }, | 500 base::Value::TYPE_BOOLEAN }, |
503 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS) | 501 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS) |
504 }; | 502 }; |
505 | 503 |
| 504 class ForceSafeSearchPolicyHandler : public TypeCheckingPolicyHandler { |
| 505 public: |
| 506 ForceSafeSearchPolicyHandler() |
| 507 : TypeCheckingPolicyHandler(key::kForceSafeSearch, |
| 508 base::Value::TYPE_BOOLEAN) {} |
| 509 ~ForceSafeSearchPolicyHandler() override {} |
| 510 |
| 511 // ConfigurationPolicyHandler implementation: |
| 512 void ApplyPolicySettings(const PolicyMap& policies, |
| 513 PrefValueMap* prefs) override { |
| 514 // If either of the new GoogleSafeSearch or YouTubeSafetyMode policies is |
| 515 // defined, then this one should be ignored. crbug.com/476908 |
| 516 // Note: Those policies are declared in kSimplePolicyMap above. |
| 517 if (policies.GetValue(key::kForceGoogleSafeSearch) || |
| 518 policies.GetValue(key::kForceYouTubeSafetyMode)) { |
| 519 return; |
| 520 } |
| 521 const base::Value* value = policies.GetValue(policy_name()); |
| 522 if (value) { |
| 523 prefs->SetValue(prefs::kForceGoogleSafeSearch, value->DeepCopy()); |
| 524 prefs->SetValue(prefs::kForceYouTubeSafetyMode, value->DeepCopy()); |
| 525 } |
| 526 } |
| 527 |
| 528 private: |
| 529 DISALLOW_COPY_AND_ASSIGN(ForceSafeSearchPolicyHandler); |
| 530 }; |
| 531 |
506 #if defined(ENABLE_EXTENSIONS) | 532 #if defined(ENABLE_EXTENSIONS) |
507 void GetExtensionAllowedTypesMap( | 533 void GetExtensionAllowedTypesMap( |
508 ScopedVector<StringMappingListPolicyHandler::MappingEntry>* result) { | 534 ScopedVector<StringMappingListPolicyHandler::MappingEntry>* result) { |
509 // Mapping from extension type names to Manifest::Type. | 535 // Mapping from extension type names to Manifest::Type. |
510 for (size_t index = 0; | 536 for (size_t index = 0; |
511 index < extensions::schema_constants::kAllowedTypesMapSize; | 537 index < extensions::schema_constants::kAllowedTypesMapSize; |
512 ++index) { | 538 ++index) { |
513 const extensions::schema_constants::AllowedTypesMapEntry& entry = | 539 const extensions::schema_constants::AllowedTypesMapEntry& entry = |
514 extensions::schema_constants::kAllowedTypesMap[index]; | 540 extensions::schema_constants::kAllowedTypesMap[index]; |
515 result->push_back(new StringMappingListPolicyHandler::MappingEntry( | 541 result->push_back(new StringMappingListPolicyHandler::MappingEntry( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 base::Bind(&PopulatePolicyHandlerParameters), | 574 base::Bind(&PopulatePolicyHandlerParameters), |
549 base::Bind(&GetChromePolicyDetails))); | 575 base::Bind(&GetChromePolicyDetails))); |
550 for (size_t i = 0; i < arraysize(kSimplePolicyMap); ++i) { | 576 for (size_t i = 0; i < arraysize(kSimplePolicyMap); ++i) { |
551 handlers->AddHandler(make_scoped_ptr(new SimplePolicyHandler( | 577 handlers->AddHandler(make_scoped_ptr(new SimplePolicyHandler( |
552 kSimplePolicyMap[i].policy_name, kSimplePolicyMap[i].preference_path, | 578 kSimplePolicyMap[i].policy_name, kSimplePolicyMap[i].preference_path, |
553 kSimplePolicyMap[i].value_type))); | 579 kSimplePolicyMap[i].value_type))); |
554 } | 580 } |
555 | 581 |
556 handlers->AddHandler(make_scoped_ptr(new AutofillPolicyHandler())); | 582 handlers->AddHandler(make_scoped_ptr(new AutofillPolicyHandler())); |
557 handlers->AddHandler(make_scoped_ptr(new DefaultSearchPolicyHandler())); | 583 handlers->AddHandler(make_scoped_ptr(new DefaultSearchPolicyHandler())); |
| 584 handlers->AddHandler(make_scoped_ptr(new ForceSafeSearchPolicyHandler())); |
558 handlers->AddHandler(make_scoped_ptr(new IncognitoModePolicyHandler())); | 585 handlers->AddHandler(make_scoped_ptr(new IncognitoModePolicyHandler())); |
559 handlers->AddHandler( | 586 handlers->AddHandler( |
560 make_scoped_ptr(new ManagedBookmarksPolicyHandler(chrome_schema))); | 587 make_scoped_ptr(new ManagedBookmarksPolicyHandler(chrome_schema))); |
561 handlers->AddHandler(make_scoped_ptr(new ProxyPolicyHandler())); | 588 handlers->AddHandler(make_scoped_ptr(new ProxyPolicyHandler())); |
562 handlers->AddHandler(make_scoped_ptr(new URLBlacklistPolicyHandler())); | 589 handlers->AddHandler(make_scoped_ptr(new URLBlacklistPolicyHandler())); |
563 | 590 |
564 #if defined(OS_ANDROID) | 591 #if defined(OS_ANDROID) |
565 handlers->AddHandler( | 592 handlers->AddHandler( |
566 make_scoped_ptr(new ContextualSearchPolicyHandlerAndroid())); | 593 make_scoped_ptr(new ContextualSearchPolicyHandlerAndroid())); |
567 #endif | 594 #endif |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 handlers->AddHandler(make_scoped_ptr(new SimpleSchemaValidatingPolicyHandler( | 782 handlers->AddHandler(make_scoped_ptr(new SimpleSchemaValidatingPolicyHandler( |
756 key::kSessionLocales, NULL, chrome_schema, SCHEMA_STRICT, | 783 key::kSessionLocales, NULL, chrome_schema, SCHEMA_STRICT, |
757 SimpleSchemaValidatingPolicyHandler::RECOMMENDED_ALLOWED, | 784 SimpleSchemaValidatingPolicyHandler::RECOMMENDED_ALLOWED, |
758 SimpleSchemaValidatingPolicyHandler::MANDATORY_PROHIBITED))); | 785 SimpleSchemaValidatingPolicyHandler::MANDATORY_PROHIBITED))); |
759 #endif // defined(OS_CHROMEOS) | 786 #endif // defined(OS_CHROMEOS) |
760 | 787 |
761 return handlers.Pass(); | 788 return handlers.Pass(); |
762 } | 789 } |
763 | 790 |
764 } // namespace policy | 791 } // namespace policy |
OLD | NEW |