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 { | |
Mattias Nissler (ping if slow)
2015/04/16 13:10:47
What you have works. However, I think an easier-to
Marc Treib
2015/04/16 13:18:23
I considered that, and I actually prefer the way i
Mattias Nissler (ping if slow)
2015/04/16 13:27:56
I suppose somebody trying to understand how these
| |
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 if (policies.GetValue(key::kForceGoogleSafeSearch) || | |
517 policies.GetValue(key::kForceYouTubeSafetyMode)) { | |
518 return; | |
519 } | |
520 const base::Value* value = policies.GetValue(policy_name()); | |
521 if (value) { | |
522 prefs->SetValue(prefs::kForceGoogleSafeSearch, value->DeepCopy()); | |
523 prefs->SetValue(prefs::kForceYouTubeSafetyMode, value->DeepCopy()); | |
524 } | |
525 } | |
526 | |
527 private: | |
528 DISALLOW_COPY_AND_ASSIGN(ForceSafeSearchPolicyHandler); | |
529 }; | |
530 | |
506 #if defined(ENABLE_EXTENSIONS) | 531 #if defined(ENABLE_EXTENSIONS) |
507 void GetExtensionAllowedTypesMap( | 532 void GetExtensionAllowedTypesMap( |
508 ScopedVector<StringMappingListPolicyHandler::MappingEntry>* result) { | 533 ScopedVector<StringMappingListPolicyHandler::MappingEntry>* result) { |
509 // Mapping from extension type names to Manifest::Type. | 534 // Mapping from extension type names to Manifest::Type. |
510 for (size_t index = 0; | 535 for (size_t index = 0; |
511 index < extensions::schema_constants::kAllowedTypesMapSize; | 536 index < extensions::schema_constants::kAllowedTypesMapSize; |
512 ++index) { | 537 ++index) { |
513 const extensions::schema_constants::AllowedTypesMapEntry& entry = | 538 const extensions::schema_constants::AllowedTypesMapEntry& entry = |
514 extensions::schema_constants::kAllowedTypesMap[index]; | 539 extensions::schema_constants::kAllowedTypesMap[index]; |
515 result->push_back(new StringMappingListPolicyHandler::MappingEntry( | 540 result->push_back(new StringMappingListPolicyHandler::MappingEntry( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
548 base::Bind(&PopulatePolicyHandlerParameters), | 573 base::Bind(&PopulatePolicyHandlerParameters), |
549 base::Bind(&GetChromePolicyDetails))); | 574 base::Bind(&GetChromePolicyDetails))); |
550 for (size_t i = 0; i < arraysize(kSimplePolicyMap); ++i) { | 575 for (size_t i = 0; i < arraysize(kSimplePolicyMap); ++i) { |
551 handlers->AddHandler(make_scoped_ptr(new SimplePolicyHandler( | 576 handlers->AddHandler(make_scoped_ptr(new SimplePolicyHandler( |
552 kSimplePolicyMap[i].policy_name, kSimplePolicyMap[i].preference_path, | 577 kSimplePolicyMap[i].policy_name, kSimplePolicyMap[i].preference_path, |
553 kSimplePolicyMap[i].value_type))); | 578 kSimplePolicyMap[i].value_type))); |
554 } | 579 } |
555 | 580 |
556 handlers->AddHandler(make_scoped_ptr(new AutofillPolicyHandler())); | 581 handlers->AddHandler(make_scoped_ptr(new AutofillPolicyHandler())); |
557 handlers->AddHandler(make_scoped_ptr(new DefaultSearchPolicyHandler())); | 582 handlers->AddHandler(make_scoped_ptr(new DefaultSearchPolicyHandler())); |
583 handlers->AddHandler(make_scoped_ptr(new ForceSafeSearchPolicyHandler())); | |
558 handlers->AddHandler(make_scoped_ptr(new IncognitoModePolicyHandler())); | 584 handlers->AddHandler(make_scoped_ptr(new IncognitoModePolicyHandler())); |
559 handlers->AddHandler( | 585 handlers->AddHandler( |
560 make_scoped_ptr(new ManagedBookmarksPolicyHandler(chrome_schema))); | 586 make_scoped_ptr(new ManagedBookmarksPolicyHandler(chrome_schema))); |
561 handlers->AddHandler(make_scoped_ptr(new ProxyPolicyHandler())); | 587 handlers->AddHandler(make_scoped_ptr(new ProxyPolicyHandler())); |
562 handlers->AddHandler(make_scoped_ptr(new URLBlacklistPolicyHandler())); | 588 handlers->AddHandler(make_scoped_ptr(new URLBlacklistPolicyHandler())); |
563 | 589 |
564 #if defined(OS_ANDROID) | 590 #if defined(OS_ANDROID) |
565 handlers->AddHandler( | 591 handlers->AddHandler( |
566 make_scoped_ptr(new ContextualSearchPolicyHandlerAndroid())); | 592 make_scoped_ptr(new ContextualSearchPolicyHandlerAndroid())); |
567 #endif | 593 #endif |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
755 handlers->AddHandler(make_scoped_ptr(new SimpleSchemaValidatingPolicyHandler( | 781 handlers->AddHandler(make_scoped_ptr(new SimpleSchemaValidatingPolicyHandler( |
756 key::kSessionLocales, NULL, chrome_schema, SCHEMA_STRICT, | 782 key::kSessionLocales, NULL, chrome_schema, SCHEMA_STRICT, |
757 SimpleSchemaValidatingPolicyHandler::RECOMMENDED_ALLOWED, | 783 SimpleSchemaValidatingPolicyHandler::RECOMMENDED_ALLOWED, |
758 SimpleSchemaValidatingPolicyHandler::MANDATORY_PROHIBITED))); | 784 SimpleSchemaValidatingPolicyHandler::MANDATORY_PROHIBITED))); |
759 #endif // defined(OS_CHROMEOS) | 785 #endif // defined(OS_CHROMEOS) |
760 | 786 |
761 return handlers.Pass(); | 787 return handlers.Pass(); |
762 } | 788 } |
763 | 789 |
764 } // namespace policy | 790 } // namespace policy |
OLD | NEW |