Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(510)

Side by Side Diff: chrome/browser/extensions/policy_handlers.cc

Issue 2509753006: Revert of Plumbing for login apps device policy to extensions. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 92 }
93 filtered_list->AppendString(id); 93 filtered_list->AppendString(id);
94 } 94 }
95 95
96 if (extension_ids) 96 if (extension_ids)
97 *extension_ids = std::move(filtered_list); 97 *extension_ids = std::move(filtered_list);
98 98
99 return true; 99 return true;
100 } 100 }
101 101
102 // ExtensionInstallListPolicyHandler implementation ---------------------------- 102 // ExtensionInstallForcelistPolicyHandler implementation -----------------------
103 103
104 ExtensionInstallListPolicyHandler::ExtensionInstallListPolicyHandler( 104 ExtensionInstallForcelistPolicyHandler::ExtensionInstallForcelistPolicyHandler()
105 const char* policy_name, 105 : policy::TypeCheckingPolicyHandler(policy::key::kExtensionInstallForcelist,
106 const char* pref_name) 106 base::Value::TYPE_LIST) {}
107 : policy::TypeCheckingPolicyHandler(policy_name, base::Value::TYPE_LIST),
108 pref_name_(pref_name) {}
109 107
110 ExtensionInstallListPolicyHandler::~ExtensionInstallListPolicyHandler() {} 108 ExtensionInstallForcelistPolicyHandler::
109 ~ExtensionInstallForcelistPolicyHandler() {}
111 110
112 bool ExtensionInstallListPolicyHandler::CheckPolicySettings( 111 bool ExtensionInstallForcelistPolicyHandler::CheckPolicySettings(
113 const policy::PolicyMap& policies, 112 const policy::PolicyMap& policies,
114 policy::PolicyErrorMap* errors) { 113 policy::PolicyErrorMap* errors) {
115 const base::Value* value; 114 const base::Value* value;
116 return CheckAndGetValue(policies, errors, &value) && 115 return CheckAndGetValue(policies, errors, &value) &&
117 ParseList(value, nullptr, errors); 116 ParseList(value, NULL, errors);
118 } 117 }
119 118
120 void ExtensionInstallListPolicyHandler::ApplyPolicySettings( 119 void ExtensionInstallForcelistPolicyHandler::ApplyPolicySettings(
121 const policy::PolicyMap& policies, 120 const policy::PolicyMap& policies,
122 PrefValueMap* prefs) { 121 PrefValueMap* prefs) {
123 const base::Value* value = nullptr; 122 const base::Value* value = NULL;
124 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 123 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
125 if (CheckAndGetValue(policies, nullptr, &value) && value && 124 if (CheckAndGetValue(policies, NULL, &value) &&
126 ParseList(value, dict.get(), nullptr)) { 125 value &&
127 prefs->SetValue(pref_name(), std::move(dict)); 126 ParseList(value, dict.get(), NULL)) {
127 prefs->SetValue(pref_names::kInstallForceList, std::move(dict));
128 } 128 }
129 } 129 }
130 130
131 bool ExtensionInstallListPolicyHandler::ParseList( 131 bool ExtensionInstallForcelistPolicyHandler::ParseList(
132 const base::Value* policy_value, 132 const base::Value* policy_value,
133 base::DictionaryValue* extension_dict, 133 base::DictionaryValue* extension_dict,
134 policy::PolicyErrorMap* errors) { 134 policy::PolicyErrorMap* errors) {
135 if (!policy_value) 135 if (!policy_value)
136 return true; 136 return true;
137 137
138 const base::ListValue* policy_list_value = nullptr; 138 const base::ListValue* policy_list_value = NULL;
139 if (!policy_value->GetAsList(&policy_list_value)) { 139 if (!policy_value->GetAsList(&policy_list_value)) {
140 // This should have been caught in CheckPolicySettings. 140 // This should have been caught in CheckPolicySettings.
141 NOTREACHED(); 141 NOTREACHED();
142 return false; 142 return false;
143 } 143 }
144 144
145 for (base::ListValue::const_iterator entry(policy_list_value->begin()); 145 for (base::ListValue::const_iterator entry(policy_list_value->begin());
146 entry != policy_list_value->end(); ++entry) { 146 entry != policy_list_value->end(); ++entry) {
147 std::string entry_string; 147 std::string entry_string;
148 if (!(*entry)->GetAsString(&entry_string)) { 148 if (!(*entry)->GetAsString(&entry_string)) {
(...skipping 11 matching lines...) Expand all
160 size_t pos = entry_string.find(';'); 160 size_t pos = entry_string.find(';');
161 if (pos == std::string::npos) { 161 if (pos == std::string::npos) {
162 if (errors) { 162 if (errors) {
163 errors->AddError(policy_name(), 163 errors->AddError(policy_name(),
164 entry - policy_list_value->begin(), 164 entry - policy_list_value->begin(),
165 IDS_POLICY_VALUE_FORMAT_ERROR); 165 IDS_POLICY_VALUE_FORMAT_ERROR);
166 } 166 }
167 continue; 167 continue;
168 } 168 }
169 169
170 const std::string extension_id = entry_string.substr(0, pos); 170 std::string extension_id = entry_string.substr(0, pos);
171 const std::string update_url = entry_string.substr(pos + 1); 171 std::string update_url = entry_string.substr(pos+1);
172 if (!crx_file::id_util::IdIsValid(extension_id) || 172 if (!crx_file::id_util::IdIsValid(extension_id) ||
173 !GURL(update_url).is_valid()) { 173 !GURL(update_url).is_valid()) {
174 if (errors) { 174 if (errors) {
175 errors->AddError(policy_name(), 175 errors->AddError(policy_name(),
176 entry - policy_list_value->begin(), 176 entry - policy_list_value->begin(),
177 IDS_POLICY_VALUE_FORMAT_ERROR); 177 IDS_POLICY_VALUE_FORMAT_ERROR);
178 } 178 }
179 continue; 179 continue;
180 } 180 }
181 181
182 if (extension_dict) { 182 if (extension_dict) {
183 ExternalPolicyLoader::AddExtension(extension_dict, extension_id, 183 extensions::ExternalPolicyLoader::AddExtension(
184 update_url); 184 extension_dict, extension_id, update_url);
185 } 185 }
186 } 186 }
187 187
188 return true; 188 return true;
189 } 189 }
190 190
191 // ExtensionInstallForcelistPolicyHandler implementation -----------------------
192
193 ExtensionInstallForcelistPolicyHandler::ExtensionInstallForcelistPolicyHandler()
194 : ExtensionInstallListPolicyHandler(policy::key::kExtensionInstallForcelist,
195 pref_names::kInstallForceList) {}
196
197 ExtensionInstallForcelistPolicyHandler::
198 ~ExtensionInstallForcelistPolicyHandler() {}
199
200 // ExtensionInstallSigninlistPolicyHandler implementation
201 // -----------------------
202
203 ExtensionInstallSigninListPolicyHandler::
204 ExtensionInstallSigninListPolicyHandler()
205 : ExtensionInstallListPolicyHandler(policy::key::kLoginApps,
206 pref_names::kInstallSigninList) {}
207
208 ExtensionInstallSigninListPolicyHandler::
209 ~ExtensionInstallSigninListPolicyHandler() {}
210
211 // ExtensionURLPatternListPolicyHandler implementation ------------------------- 191 // ExtensionURLPatternListPolicyHandler implementation -------------------------
212 192
213 ExtensionURLPatternListPolicyHandler::ExtensionURLPatternListPolicyHandler( 193 ExtensionURLPatternListPolicyHandler::ExtensionURLPatternListPolicyHandler(
214 const char* policy_name, 194 const char* policy_name,
215 const char* pref_path) 195 const char* pref_path)
216 : policy::TypeCheckingPolicyHandler(policy_name, base::Value::TYPE_LIST), 196 : policy::TypeCheckingPolicyHandler(policy_name, base::Value::TYPE_LIST),
217 pref_path_(pref_path) {} 197 pref_path_(pref_path) {}
218 198
219 ExtensionURLPatternListPolicyHandler::~ExtensionURLPatternListPolicyHandler() {} 199 ExtensionURLPatternListPolicyHandler::~ExtensionURLPatternListPolicyHandler() {}
220 200
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 void ExtensionSettingsPolicyHandler::ApplyPolicySettings( 317 void ExtensionSettingsPolicyHandler::ApplyPolicySettings(
338 const policy::PolicyMap& policies, 318 const policy::PolicyMap& policies,
339 PrefValueMap* prefs) { 319 PrefValueMap* prefs) {
340 std::unique_ptr<base::Value> policy_value; 320 std::unique_ptr<base::Value> policy_value;
341 if (!CheckAndGetValue(policies, NULL, &policy_value) || !policy_value) 321 if (!CheckAndGetValue(policies, NULL, &policy_value) || !policy_value)
342 return; 322 return;
343 prefs->SetValue(pref_names::kExtensionManagement, std::move(policy_value)); 323 prefs->SetValue(pref_names::kExtensionManagement, std::move(policy_value));
344 } 324 }
345 325
346 } // namespace extensions 326 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/policy_handlers.h ('k') | chrome/browser/policy/configuration_policy_handler_list_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698