OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/extension_prefs.h" | 5 #include "chrome/browser/extensions/extension_prefs.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 } | 234 } |
235 | 235 |
236 bool ExtensionPrefs::IsExtensionBlacklisted(const std::string& extension_id) { | 236 bool ExtensionPrefs::IsExtensionBlacklisted(const std::string& extension_id) { |
237 return ReadExtensionPrefBoolean(extension_id, kPrefBlacklist); | 237 return ReadExtensionPrefBoolean(extension_id, kPrefBlacklist); |
238 } | 238 } |
239 | 239 |
240 bool ExtensionPrefs::IsExtensionAllowedByPolicy( | 240 bool ExtensionPrefs::IsExtensionAllowedByPolicy( |
241 const std::string& extension_id) { | 241 const std::string& extension_id) { |
242 std::string string_value; | 242 std::string string_value; |
243 | 243 |
| 244 const ListValue* blacklist = prefs_->GetList(kExtensionInstallDenyList); |
| 245 if (!blacklist || blacklist->empty()) |
| 246 return true; |
| 247 |
244 // Check the whitelist first. | 248 // Check the whitelist first. |
245 const ListValue* whitelist = prefs_->GetList(kExtensionInstallAllowList); | 249 const ListValue* whitelist = prefs_->GetList(kExtensionInstallAllowList); |
246 if (whitelist) { | 250 if (whitelist) { |
247 for (ListValue::const_iterator it = whitelist->begin(); | 251 for (ListValue::const_iterator it = whitelist->begin(); |
248 it != whitelist->end(); ++it) { | 252 it != whitelist->end(); ++it) { |
249 if (!(*it)->GetAsString(&string_value)) | 253 if (!(*it)->GetAsString(&string_value)) |
250 LOG(WARNING) << "Failed to read whitelist string."; | 254 LOG(WARNING) << "Failed to read whitelist string."; |
251 else if (string_value == extension_id) | 255 else if (string_value == extension_id) |
252 return true; | 256 return true; |
253 } | 257 } |
254 } | 258 } |
255 | 259 |
256 // Then check the blacklist (the admin blacklist, not the Google blacklist). | 260 // Then check the blacklist (the admin blacklist, not the Google blacklist). |
257 const ListValue* blacklist = prefs_->GetList(kExtensionInstallDenyList); | |
258 if (blacklist) { | 261 if (blacklist) { |
259 for (ListValue::const_iterator it = blacklist->begin(); | 262 for (ListValue::const_iterator it = blacklist->begin(); |
260 it != blacklist->end(); ++it) { | 263 it != blacklist->end(); ++it) { |
261 if (!(*it)->GetAsString(&string_value)) { | 264 if (!(*it)->GetAsString(&string_value)) { |
262 LOG(WARNING) << "Failed to read blacklist string."; | 265 LOG(WARNING) << "Failed to read blacklist string."; |
263 } else { | 266 } else { |
264 if (string_value == "*") | 267 if (string_value == "*") |
265 return false; // Only whitelisted extensions are allowed. | 268 return false; // Only whitelisted extensions are allowed. |
266 if (string_value == extension_id) | 269 if (string_value == extension_id) |
267 return false; | 270 return false; |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 | 796 |
794 // static | 797 // static |
795 void ExtensionPrefs::RegisterUserPrefs(PrefService* prefs) { | 798 void ExtensionPrefs::RegisterUserPrefs(PrefService* prefs) { |
796 prefs->RegisterDictionaryPref(kExtensionsPref); | 799 prefs->RegisterDictionaryPref(kExtensionsPref); |
797 prefs->RegisterListPref(kExtensionToolbar); | 800 prefs->RegisterListPref(kExtensionToolbar); |
798 prefs->RegisterIntegerPref(prefs::kExtensionToolbarSize, -1); | 801 prefs->RegisterIntegerPref(prefs::kExtensionToolbarSize, -1); |
799 prefs->RegisterDictionaryPref(kExtensionsBlacklistUpdate); | 802 prefs->RegisterDictionaryPref(kExtensionsBlacklistUpdate); |
800 prefs->RegisterListPref(kExtensionInstallAllowList); | 803 prefs->RegisterListPref(kExtensionInstallAllowList); |
801 prefs->RegisterListPref(kExtensionInstallDenyList); | 804 prefs->RegisterListPref(kExtensionInstallDenyList); |
802 } | 805 } |
OLD | NEW |