| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/admin_policy.h" | 5 #include "chrome/browser/extensions/admin_policy.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/common/extensions/extension.h" | 8 #include "chrome/common/extensions/extension.h" |
| 9 #include "grit/generated_resources.h" | 9 #include "grit/generated_resources.h" |
| 10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 } // namespace | 34 } // namespace |
| 35 | 35 |
| 36 namespace extensions { | 36 namespace extensions { |
| 37 namespace admin_policy { | 37 namespace admin_policy { |
| 38 | 38 |
| 39 bool BlacklistedByDefault(const base::ListValue* blacklist) { | 39 bool BlacklistedByDefault(const base::ListValue* blacklist) { |
| 40 base::StringValue wildcard("*"); | 40 base::StringValue wildcard("*"); |
| 41 return blacklist && blacklist->Find(wildcard) != blacklist->end(); | 41 return blacklist && blacklist->Find(wildcard) != blacklist->end(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 bool UserMayLoad(bool is_google_blacklisted, | 44 bool UserMayLoad(const base::ListValue* blacklist, |
| 45 const base::ListValue* blacklist, | |
| 46 const base::ListValue* whitelist, | 45 const base::ListValue* whitelist, |
| 47 const base::ListValue* forcelist, | 46 const base::ListValue* forcelist, |
| 48 const Extension* extension, | 47 const Extension* extension, |
| 49 string16* error) { | 48 string16* error) { |
| 50 if (IsRequired(extension)) | 49 if (IsRequired(extension)) |
| 51 return true; | 50 return true; |
| 52 | 51 |
| 53 if ((!blacklist || blacklist->empty()) && !is_google_blacklisted) | 52 if (!blacklist || blacklist->empty()) |
| 54 return true; | 53 return true; |
| 55 | 54 |
| 56 // Check the whitelist/forcelist first (takes precedence over Google | 55 // Check the whitelist/forcelist first. |
| 57 // blacklist). | |
| 58 base::StringValue id_value(extension->id()); | 56 base::StringValue id_value(extension->id()); |
| 59 if ((whitelist && whitelist->Find(id_value) != whitelist->end()) || | 57 if ((whitelist && whitelist->Find(id_value) != whitelist->end()) || |
| 60 (forcelist && forcelist->Find(id_value) != forcelist->end())) | 58 (forcelist && forcelist->Find(id_value) != forcelist->end())) |
| 61 return true; | 59 return true; |
| 62 | 60 |
| 63 // Then check both admin and Google blacklists. | 61 // Then check the admin blacklist. |
| 64 bool result = !is_google_blacklisted && | 62 bool result = (!blacklist || blacklist->Find(id_value) == blacklist->end()) && |
| 65 (!blacklist || blacklist->Find(id_value) == blacklist->end()) && | |
| 66 !BlacklistedByDefault(blacklist); | 63 !BlacklistedByDefault(blacklist); |
| 67 if (error && !result) { | 64 if (error && !result) { |
| 68 *error = l10n_util::GetStringFUTF16( | 65 *error = l10n_util::GetStringFUTF16( |
| 69 IDS_EXTENSION_CANT_INSTALL_POLICY_BLACKLIST, | 66 IDS_EXTENSION_CANT_INSTALL_POLICY_BLACKLIST, |
| 70 UTF8ToUTF16(extension->name()), | 67 UTF8ToUTF16(extension->name()), |
| 71 UTF8ToUTF16(extension->id())); | 68 UTF8ToUTF16(extension->id())); |
| 72 } | 69 } |
| 73 return result; | 70 return result; |
| 74 } | 71 } |
| 75 | 72 |
| 76 bool UserMayModifySettings(const Extension* extension, string16* error) { | 73 bool UserMayModifySettings(const Extension* extension, string16* error) { |
| 77 return ManagementPolicyImpl(extension, error, true); | 74 return ManagementPolicyImpl(extension, error, true); |
| 78 } | 75 } |
| 79 | 76 |
| 80 bool MustRemainEnabled(const Extension* extension, string16* error) { | 77 bool MustRemainEnabled(const Extension* extension, string16* error) { |
| 81 return ManagementPolicyImpl(extension, error, false); | 78 return ManagementPolicyImpl(extension, error, false); |
| 82 } | 79 } |
| 83 | 80 |
| 84 } // namespace | 81 } // namespace |
| 85 } // namespace | 82 } // namespace |
| OLD | NEW |