| 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(const base::ListValue* blacklist, | 44 bool UserMayLoad(bool is_google_blacklisted, |
| 45 const base::ListValue* blacklist, |
| 45 const base::ListValue* whitelist, | 46 const base::ListValue* whitelist, |
| 47 const base::ListValue* forcelist, |
| 46 const Extension* extension, | 48 const Extension* extension, |
| 47 string16* error) { | 49 string16* error) { |
| 48 if (IsRequired(extension)) | 50 if (IsRequired(extension)) |
| 49 return true; | 51 return true; |
| 50 | 52 |
| 51 if (!blacklist || blacklist->empty()) | 53 if ((!blacklist || blacklist->empty()) && !is_google_blacklisted) |
| 52 return true; | 54 return true; |
| 53 | 55 |
| 54 // Check the whitelist first. | 56 // Check the whitelist/forcelist first (takes precedence over Google |
| 57 // blacklist). |
| 55 base::StringValue id_value(extension->id()); | 58 base::StringValue id_value(extension->id()); |
| 56 if (whitelist && whitelist->Find(id_value) != whitelist->end()) | 59 if ((whitelist && whitelist->Find(id_value) != whitelist->end()) || |
| 60 (forcelist && forcelist->Find(id_value) != forcelist->end())) |
| 57 return true; | 61 return true; |
| 58 | 62 |
| 59 // Then check the blacklist (the admin blacklist, not the Google blacklist). | 63 // Then check both admin and Google blacklists. |
| 60 bool result = blacklist->Find(id_value) == blacklist->end() && | 64 bool result = !is_google_blacklisted && |
| 61 !BlacklistedByDefault(blacklist); | 65 (!blacklist || blacklist->Find(id_value) == blacklist->end()) && |
| 66 !BlacklistedByDefault(blacklist); |
| 62 if (error && !result) { | 67 if (error && !result) { |
| 63 *error = l10n_util::GetStringFUTF16( | 68 *error = l10n_util::GetStringFUTF16( |
| 64 IDS_EXTENSION_CANT_INSTALL_POLICY_BLACKLIST, | 69 IDS_EXTENSION_CANT_INSTALL_POLICY_BLACKLIST, |
| 65 UTF8ToUTF16(extension->name()), | 70 UTF8ToUTF16(extension->name()), |
| 66 UTF8ToUTF16(extension->id())); | 71 UTF8ToUTF16(extension->id())); |
| 67 } | 72 } |
| 68 return result; | 73 return result; |
| 69 } | 74 } |
| 70 | 75 |
| 71 bool UserMayModifySettings(const Extension* extension, string16* error) { | 76 bool UserMayModifySettings(const Extension* extension, string16* error) { |
| 72 return ManagementPolicyImpl(extension, error, true); | 77 return ManagementPolicyImpl(extension, error, true); |
| 73 } | 78 } |
| 74 | 79 |
| 75 bool MustRemainEnabled(const Extension* extension, string16* error) { | 80 bool MustRemainEnabled(const Extension* extension, string16* error) { |
| 76 return ManagementPolicyImpl(extension, error, false); | 81 return ManagementPolicyImpl(extension, error, false); |
| 77 } | 82 } |
| 78 | 83 |
| 79 } // namespace | 84 } // namespace |
| 80 } // namespace | 85 } // namespace |
| OLD | NEW |