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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/prefs/pref_value_map.h" | 8 #include "base/prefs/pref_value_map.h" |
9 #include "chrome/browser/extensions/external_policy_loader.h" | 9 #include "chrome/browser/extensions/external_policy_loader.h" |
10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| 11 #include "components/crx_file/id_util.h" |
11 #include "components/policy/core/browser/policy_error_map.h" | 12 #include "components/policy/core/browser/policy_error_map.h" |
12 #include "components/policy/core/common/policy_map.h" | 13 #include "components/policy/core/common/policy_map.h" |
13 #include "extensions/browser/pref_names.h" | 14 #include "extensions/browser/pref_names.h" |
14 #include "extensions/common/extension.h" | 15 #include "extensions/common/extension.h" |
15 #include "grit/components_strings.h" | 16 #include "grit/components_strings.h" |
16 #include "policy/policy_constants.h" | 17 #include "policy/policy_constants.h" |
17 | 18 |
18 namespace extensions { | 19 namespace extensions { |
19 | 20 |
20 // ExtensionListPolicyHandler implementation ----------------------------------- | 21 // ExtensionListPolicyHandler implementation ----------------------------------- |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 for (base::ListValue::const_iterator entry(list_value->begin()); | 73 for (base::ListValue::const_iterator entry(list_value->begin()); |
73 entry != list_value->end(); ++entry) { | 74 entry != list_value->end(); ++entry) { |
74 std::string id; | 75 std::string id; |
75 if (!(*entry)->GetAsString(&id)) { | 76 if (!(*entry)->GetAsString(&id)) { |
76 errors->AddError(policy_name(), | 77 errors->AddError(policy_name(), |
77 entry - list_value->begin(), | 78 entry - list_value->begin(), |
78 IDS_POLICY_TYPE_ERROR, | 79 IDS_POLICY_TYPE_ERROR, |
79 ValueTypeToString(base::Value::TYPE_STRING)); | 80 ValueTypeToString(base::Value::TYPE_STRING)); |
80 continue; | 81 continue; |
81 } | 82 } |
82 if (!(allow_wildcards_ && id == "*") && | 83 if (!(allow_wildcards_ && id == "*") && !crx_file::id_util::IdIsValid(id)) { |
83 !extensions::Extension::IdIsValid(id)) { | |
84 errors->AddError(policy_name(), | 84 errors->AddError(policy_name(), |
85 entry - list_value->begin(), | 85 entry - list_value->begin(), |
86 IDS_POLICY_VALUE_FORMAT_ERROR); | 86 IDS_POLICY_VALUE_FORMAT_ERROR); |
87 continue; | 87 continue; |
88 } | 88 } |
89 filtered_list->Append(new base::StringValue(id)); | 89 filtered_list->Append(new base::StringValue(id)); |
90 } | 90 } |
91 | 91 |
92 if (extension_ids) | 92 if (extension_ids) |
93 *extension_ids = filtered_list.Pass(); | 93 *extension_ids = filtered_list.Pass(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 if (errors) { | 159 if (errors) { |
160 errors->AddError(policy_name(), | 160 errors->AddError(policy_name(), |
161 entry - policy_list_value->begin(), | 161 entry - policy_list_value->begin(), |
162 IDS_POLICY_VALUE_FORMAT_ERROR); | 162 IDS_POLICY_VALUE_FORMAT_ERROR); |
163 } | 163 } |
164 continue; | 164 continue; |
165 } | 165 } |
166 | 166 |
167 std::string extension_id = entry_string.substr(0, pos); | 167 std::string extension_id = entry_string.substr(0, pos); |
168 std::string update_url = entry_string.substr(pos+1); | 168 std::string update_url = entry_string.substr(pos+1); |
169 if (!extensions::Extension::IdIsValid(extension_id) || | 169 if (!crx_file::id_util::IdIsValid(extension_id) || |
170 !GURL(update_url).is_valid()) { | 170 !GURL(update_url).is_valid()) { |
171 if (errors) { | 171 if (errors) { |
172 errors->AddError(policy_name(), | 172 errors->AddError(policy_name(), |
173 entry - policy_list_value->begin(), | 173 entry - policy_list_value->begin(), |
174 IDS_POLICY_VALUE_FORMAT_ERROR); | 174 IDS_POLICY_VALUE_FORMAT_ERROR); |
175 } | 175 } |
176 continue; | 176 continue; |
177 } | 177 } |
178 | 178 |
179 if (extension_dict) { | 179 if (extension_dict) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 const policy::PolicyMap& policies, | 239 const policy::PolicyMap& policies, |
240 PrefValueMap* prefs) { | 240 PrefValueMap* prefs) { |
241 if (!pref_path_) | 241 if (!pref_path_) |
242 return; | 242 return; |
243 const base::Value* value = policies.GetValue(policy_name()); | 243 const base::Value* value = policies.GetValue(policy_name()); |
244 if (value) | 244 if (value) |
245 prefs->SetValue(pref_path_, value->DeepCopy()); | 245 prefs->SetValue(pref_path_, value->DeepCopy()); |
246 } | 246 } |
247 | 247 |
248 } // namespace extensions | 248 } // namespace extensions |
OLD | NEW |