Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_EXTENSIONS_POLICY_HANDLERS_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_POLICY_HANDLERS_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_POLICY_HANDLERS_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_POLICY_HANDLERS_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "components/policy/core/browser/configuration_policy_handler.h" | 12 #include "components/policy/core/browser/configuration_policy_handler.h" |
| 13 | 13 |
| 14 namespace policy { | 14 namespace policy { |
| 15 class PolicyMap; | 15 class PolicyMap; |
| 16 class PolicyErrorMap; | 16 class PolicyErrorMap; |
| 17 class Schema; | 17 class Schema; |
| 18 } // namespace policy | 18 } // namespace policy |
| 19 | 19 |
| 20 namespace extensions { | 20 namespace extensions { |
| 21 | 21 |
| 22 // Implements additional checks for policies that are lists of extension IDs. | 22 // Implements additional checks for policies that are lists of extension IDs. |
| 23 class ExtensionListPolicyHandler | 23 class ExtensionListPolicyHandler |
| 24 : public policy::TypeCheckingPolicyHandler { | 24 : public policy::TypeCheckingPolicyHandler { |
| 25 public: | 25 public: |
| 26 ExtensionListPolicyHandler(const char* policy_name, | 26 ExtensionListPolicyHandler(const char* policy_name, |
|
achuithb
2017/02/22 14:39:34
Note policy_name is of type const char* here.
| |
| 27 const char* pref_path, | 27 const char* pref_path, |
| 28 bool allow_wildcards); | 28 bool allow_wildcards); |
| 29 ~ExtensionListPolicyHandler() override; | 29 ~ExtensionListPolicyHandler() override; |
| 30 | 30 |
| 31 // ConfigurationPolicyHandler methods: | 31 // ConfigurationPolicyHandler methods: |
| 32 bool CheckPolicySettings(const policy::PolicyMap& policies, | 32 bool CheckPolicySettings(const policy::PolicyMap& policies, |
| 33 policy::PolicyErrorMap* errors) override; | 33 policy::PolicyErrorMap* errors) override; |
| 34 void ApplyPolicySettings(const policy::PolicyMap& policies, | 34 void ApplyPolicySettings(const policy::PolicyMap& policies, |
| 35 PrefValueMap* prefs) override; | 35 PrefValueMap* prefs) override; |
| 36 | 36 |
| 37 protected: | 37 protected: |
| 38 const char* pref_path() const; | 38 const char* pref_path() const; |
| 39 | 39 |
| 40 // Runs sanity checks on the policy value and returns it in |extension_ids|. | 40 // Runs sanity checks on the policy value and returns it in |extension_ids|. |
| 41 bool CheckAndGetList(const policy::PolicyMap& policies, | 41 bool CheckAndGetList(const policy::PolicyMap& policies, |
| 42 policy::PolicyErrorMap* errors, | 42 policy::PolicyErrorMap* errors, |
| 43 std::unique_ptr<base::ListValue>* extension_ids); | 43 std::unique_ptr<base::ListValue>* extension_ids); |
| 44 | 44 |
| 45 private: | 45 private: |
| 46 const char* pref_path_; | 46 const char* pref_path_; |
| 47 bool allow_wildcards_; | 47 bool allow_wildcards_; |
| 48 | 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(ExtensionListPolicyHandler); | 49 DISALLOW_COPY_AND_ASSIGN(ExtensionListPolicyHandler); |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 class ExtensionInstallForcelistPolicyHandler | 52 class ExtensionInstallListPolicyHandler |
|
emaxx
2017/02/21 19:44:10
nit: Maybe add comments to explain what this class
achuithb
2017/02/22 14:39:34
Done.
| |
| 53 : public policy::TypeCheckingPolicyHandler { | 53 : public policy::TypeCheckingPolicyHandler { |
| 54 public: | 54 public: |
| 55 ExtensionInstallForcelistPolicyHandler(); | |
| 56 ~ExtensionInstallForcelistPolicyHandler() override; | |
| 57 | |
| 58 // ConfigurationPolicyHandler methods: | 55 // ConfigurationPolicyHandler methods: |
| 59 bool CheckPolicySettings(const policy::PolicyMap& policies, | 56 bool CheckPolicySettings(const policy::PolicyMap& policies, |
| 60 policy::PolicyErrorMap* errors) override; | 57 policy::PolicyErrorMap* errors) override; |
| 61 void ApplyPolicySettings(const policy::PolicyMap& policies, | 58 void ApplyPolicySettings(const policy::PolicyMap& policies, |
| 62 PrefValueMap* prefs) override; | 59 PrefValueMap* prefs) override; |
| 63 | 60 |
| 61 protected: | |
| 62 ExtensionInstallListPolicyHandler(const char* policy_name, | |
|
emaxx
2017/02/21 19:44:10
nit: I believe std::string is used much more often
achuithb
2017/02/22 14:39:34
I'm happy to change this if you insist, but this i
emaxx
2017/02/24 04:12:40
Acknowledged.
| |
| 63 const char* pref_name); | |
| 64 | |
| 65 ~ExtensionInstallListPolicyHandler() override = default; | |
| 66 | |
| 67 const char* pref_name() const { return pref_name_; } | |
| 68 | |
| 64 private: | 69 private: |
| 65 // Parses the data in |policy_value| and writes them to |extension_dict|. | 70 // Parses the data in |policy_value| and writes them to |extension_dict|. |
| 66 bool ParseList(const base::Value* policy_value, | 71 bool ParseList(const base::Value* policy_value, |
| 67 base::DictionaryValue* extension_dict, | 72 base::DictionaryValue* extension_dict, |
| 68 policy::PolicyErrorMap* errors); | 73 policy::PolicyErrorMap* errors); |
| 69 | 74 |
| 75 const char* const pref_name_ = nullptr; | |
| 76 | |
| 77 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallListPolicyHandler); | |
| 78 }; | |
| 79 | |
| 80 class ExtensionInstallForcelistPolicyHandler | |
| 81 : public ExtensionInstallListPolicyHandler { | |
| 82 public: | |
| 83 ExtensionInstallForcelistPolicyHandler(); | |
| 84 ~ExtensionInstallForcelistPolicyHandler() override = default; | |
| 85 | |
| 86 private: | |
| 70 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallForcelistPolicyHandler); | 87 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallForcelistPolicyHandler); |
| 71 }; | 88 }; |
| 72 | 89 |
| 90 class ExtensionInstallLoginlistPolicyHandler | |
| 91 : public ExtensionInstallListPolicyHandler { | |
| 92 public: | |
| 93 ExtensionInstallLoginlistPolicyHandler(); | |
| 94 ~ExtensionInstallLoginlistPolicyHandler() override = default; | |
| 95 | |
| 96 private: | |
| 97 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallLoginlistPolicyHandler); | |
| 98 }; | |
| 99 | |
| 73 // Implements additional checks for policies that are lists of extension | 100 // Implements additional checks for policies that are lists of extension |
| 74 // URLPatterns. | 101 // URLPatterns. |
| 75 class ExtensionURLPatternListPolicyHandler | 102 class ExtensionURLPatternListPolicyHandler |
| 76 : public policy::TypeCheckingPolicyHandler { | 103 : public policy::TypeCheckingPolicyHandler { |
| 77 public: | 104 public: |
| 78 ExtensionURLPatternListPolicyHandler(const char* policy_name, | 105 ExtensionURLPatternListPolicyHandler(const char* policy_name, |
| 79 const char* pref_path); | 106 const char* pref_path); |
| 80 ~ExtensionURLPatternListPolicyHandler() override; | 107 ~ExtensionURLPatternListPolicyHandler() override; |
| 81 | 108 |
| 82 // ConfigurationPolicyHandler methods: | 109 // ConfigurationPolicyHandler methods: |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 103 void ApplyPolicySettings(const policy::PolicyMap& policies, | 130 void ApplyPolicySettings(const policy::PolicyMap& policies, |
| 104 PrefValueMap* prefs) override; | 131 PrefValueMap* prefs) override; |
| 105 | 132 |
| 106 private: | 133 private: |
| 107 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsPolicyHandler); | 134 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsPolicyHandler); |
| 108 }; | 135 }; |
| 109 | 136 |
| 110 } // namespace extensions | 137 } // namespace extensions |
| 111 | 138 |
| 112 #endif // CHROME_BROWSER_EXTENSIONS_POLICY_HANDLERS_H_ | 139 #endif // CHROME_BROWSER_EXTENSIONS_POLICY_HANDLERS_H_ |
| OLD | NEW |