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/extensions/policy_handlers.h" | 5 #include "chrome/browser/extensions/policy_handlers.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 #include "base/prefs/pref_value_map.h" | 11 #include "base/prefs/pref_value_map.h" |
11 #include "chrome/browser/extensions/extension_management_constants.h" | 12 #include "chrome/browser/extensions/extension_management_constants.h" |
12 #include "chrome/browser/extensions/external_policy_loader.h" | 13 #include "chrome/browser/extensions/external_policy_loader.h" |
13 #include "components/crx_file/id_util.h" | 14 #include "components/crx_file/id_util.h" |
14 #include "components/policy/core/browser/policy_error_map.h" | 15 #include "components/policy/core/browser/policy_error_map.h" |
15 #include "components/policy/core/common/policy_map.h" | 16 #include "components/policy/core/common/policy_map.h" |
16 #include "components/policy/core/common/schema.h" | 17 #include "components/policy/core/common/schema.h" |
17 #include "extensions/browser/pref_names.h" | 18 #include "extensions/browser/pref_names.h" |
(...skipping 20 matching lines...) Expand all Loading... |
38 policy::PolicyErrorMap* errors) { | 39 policy::PolicyErrorMap* errors) { |
39 return CheckAndGetList(policies, errors, NULL); | 40 return CheckAndGetList(policies, errors, NULL); |
40 } | 41 } |
41 | 42 |
42 void ExtensionListPolicyHandler::ApplyPolicySettings( | 43 void ExtensionListPolicyHandler::ApplyPolicySettings( |
43 const policy::PolicyMap& policies, | 44 const policy::PolicyMap& policies, |
44 PrefValueMap* prefs) { | 45 PrefValueMap* prefs) { |
45 scoped_ptr<base::ListValue> list; | 46 scoped_ptr<base::ListValue> list; |
46 policy::PolicyErrorMap errors; | 47 policy::PolicyErrorMap errors; |
47 if (CheckAndGetList(policies, &errors, &list) && list) | 48 if (CheckAndGetList(policies, &errors, &list) && list) |
48 prefs->SetValue(pref_path(), list.Pass()); | 49 prefs->SetValue(pref_path(), std::move(list)); |
49 } | 50 } |
50 | 51 |
51 const char* ExtensionListPolicyHandler::pref_path() const { | 52 const char* ExtensionListPolicyHandler::pref_path() const { |
52 return pref_path_; | 53 return pref_path_; |
53 } | 54 } |
54 | 55 |
55 bool ExtensionListPolicyHandler::CheckAndGetList( | 56 bool ExtensionListPolicyHandler::CheckAndGetList( |
56 const policy::PolicyMap& policies, | 57 const policy::PolicyMap& policies, |
57 policy::PolicyErrorMap* errors, | 58 policy::PolicyErrorMap* errors, |
58 scoped_ptr<base::ListValue>* extension_ids) { | 59 scoped_ptr<base::ListValue>* extension_ids) { |
(...skipping 28 matching lines...) Expand all Loading... |
87 if (!(allow_wildcards_ && id == "*") && !crx_file::id_util::IdIsValid(id)) { | 88 if (!(allow_wildcards_ && id == "*") && !crx_file::id_util::IdIsValid(id)) { |
88 errors->AddError(policy_name(), | 89 errors->AddError(policy_name(), |
89 entry - list_value->begin(), | 90 entry - list_value->begin(), |
90 IDS_POLICY_VALUE_FORMAT_ERROR); | 91 IDS_POLICY_VALUE_FORMAT_ERROR); |
91 continue; | 92 continue; |
92 } | 93 } |
93 filtered_list->Append(new base::StringValue(id)); | 94 filtered_list->Append(new base::StringValue(id)); |
94 } | 95 } |
95 | 96 |
96 if (extension_ids) | 97 if (extension_ids) |
97 *extension_ids = filtered_list.Pass(); | 98 *extension_ids = std::move(filtered_list); |
98 | 99 |
99 return true; | 100 return true; |
100 } | 101 } |
101 | 102 |
102 // ExtensionInstallForcelistPolicyHandler implementation ----------------------- | 103 // ExtensionInstallForcelistPolicyHandler implementation ----------------------- |
103 | 104 |
104 ExtensionInstallForcelistPolicyHandler::ExtensionInstallForcelistPolicyHandler() | 105 ExtensionInstallForcelistPolicyHandler::ExtensionInstallForcelistPolicyHandler() |
105 : policy::TypeCheckingPolicyHandler(policy::key::kExtensionInstallForcelist, | 106 : policy::TypeCheckingPolicyHandler(policy::key::kExtensionInstallForcelist, |
106 base::Value::TYPE_LIST) {} | 107 base::Value::TYPE_LIST) {} |
107 | 108 |
108 ExtensionInstallForcelistPolicyHandler:: | 109 ExtensionInstallForcelistPolicyHandler:: |
109 ~ExtensionInstallForcelistPolicyHandler() {} | 110 ~ExtensionInstallForcelistPolicyHandler() {} |
110 | 111 |
111 bool ExtensionInstallForcelistPolicyHandler::CheckPolicySettings( | 112 bool ExtensionInstallForcelistPolicyHandler::CheckPolicySettings( |
112 const policy::PolicyMap& policies, | 113 const policy::PolicyMap& policies, |
113 policy::PolicyErrorMap* errors) { | 114 policy::PolicyErrorMap* errors) { |
114 const base::Value* value; | 115 const base::Value* value; |
115 return CheckAndGetValue(policies, errors, &value) && | 116 return CheckAndGetValue(policies, errors, &value) && |
116 ParseList(value, NULL, errors); | 117 ParseList(value, NULL, errors); |
117 } | 118 } |
118 | 119 |
119 void ExtensionInstallForcelistPolicyHandler::ApplyPolicySettings( | 120 void ExtensionInstallForcelistPolicyHandler::ApplyPolicySettings( |
120 const policy::PolicyMap& policies, | 121 const policy::PolicyMap& policies, |
121 PrefValueMap* prefs) { | 122 PrefValueMap* prefs) { |
122 const base::Value* value = NULL; | 123 const base::Value* value = NULL; |
123 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 124 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
124 if (CheckAndGetValue(policies, NULL, &value) && | 125 if (CheckAndGetValue(policies, NULL, &value) && |
125 value && | 126 value && |
126 ParseList(value, dict.get(), NULL)) { | 127 ParseList(value, dict.get(), NULL)) { |
127 prefs->SetValue(pref_names::kInstallForceList, dict.Pass()); | 128 prefs->SetValue(pref_names::kInstallForceList, std::move(dict)); |
128 } | 129 } |
129 } | 130 } |
130 | 131 |
131 bool ExtensionInstallForcelistPolicyHandler::ParseList( | 132 bool ExtensionInstallForcelistPolicyHandler::ParseList( |
132 const base::Value* policy_value, | 133 const base::Value* policy_value, |
133 base::DictionaryValue* extension_dict, | 134 base::DictionaryValue* extension_dict, |
134 policy::PolicyErrorMap* errors) { | 135 policy::PolicyErrorMap* errors) { |
135 if (!policy_value) | 136 if (!policy_value) |
136 return true; | 137 return true; |
137 | 138 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 | 316 |
316 return true; | 317 return true; |
317 } | 318 } |
318 | 319 |
319 void ExtensionSettingsPolicyHandler::ApplyPolicySettings( | 320 void ExtensionSettingsPolicyHandler::ApplyPolicySettings( |
320 const policy::PolicyMap& policies, | 321 const policy::PolicyMap& policies, |
321 PrefValueMap* prefs) { | 322 PrefValueMap* prefs) { |
322 scoped_ptr<base::Value> policy_value; | 323 scoped_ptr<base::Value> policy_value; |
323 if (!CheckAndGetValue(policies, NULL, &policy_value) || !policy_value) | 324 if (!CheckAndGetValue(policies, NULL, &policy_value) || !policy_value) |
324 return; | 325 return; |
325 prefs->SetValue(pref_names::kExtensionManagement, policy_value.Pass()); | 326 prefs->SetValue(pref_names::kExtensionManagement, std::move(policy_value)); |
326 } | 327 } |
327 | 328 |
328 } // namespace extensions | 329 } // namespace extensions |
OLD | NEW |