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/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/common/extensions/extension.h" | 8 #include "chrome/common/extensions/extension.h" |
9 #include "extensions/common/manifest.h" | 9 #include "extensions/common/manifest.h" |
10 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
11 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 bool ManagementPolicyImpl(const extensions::Extension* extension, | 15 bool ManagementPolicyImpl(const extensions::Extension* extension, |
16 string16* error, | 16 string16* error, |
17 bool modifiable_value) { | 17 bool modifiable_value) { |
18 bool modifiable = | 18 bool modifiable = |
19 extension->location() != extensions::Manifest::COMPONENT && | 19 extension->location() != extensions::Manifest::COMPONENT && |
| 20 extension->location() != extensions::Manifest::EXTERNAL_POLICY && |
20 extension->location() != extensions::Manifest::EXTERNAL_POLICY_DOWNLOAD; | 21 extension->location() != extensions::Manifest::EXTERNAL_POLICY_DOWNLOAD; |
21 // Some callers equate "no restriction" to true, others to false. | 22 // Some callers equate "no restriction" to true, others to false. |
22 if (modifiable) | 23 if (modifiable) |
23 return modifiable_value; | 24 return modifiable_value; |
24 | 25 |
25 if (error) { | 26 if (error) { |
26 *error = l10n_util::GetStringFUTF16( | 27 *error = l10n_util::GetStringFUTF16( |
27 IDS_EXTENSION_CANT_MODIFY_POLICY_REQUIRED, | 28 IDS_EXTENSION_CANT_MODIFY_POLICY_REQUIRED, |
28 UTF8ToUTF16(extension->name())); | 29 UTF8ToUTF16(extension->name())); |
29 } | 30 } |
(...skipping 24 matching lines...) Expand all Loading... |
54 const base::ListValue* whitelist, | 55 const base::ListValue* whitelist, |
55 const base::DictionaryValue* forcelist, | 56 const base::DictionaryValue* forcelist, |
56 const base::ListValue* allowed_types, | 57 const base::ListValue* allowed_types, |
57 const Extension* extension, | 58 const Extension* extension, |
58 string16* error) { | 59 string16* error) { |
59 // Component extensions are always allowed. | 60 // Component extensions are always allowed. |
60 if (extension->location() == Manifest::COMPONENT) | 61 if (extension->location() == Manifest::COMPONENT) |
61 return true; | 62 return true; |
62 | 63 |
63 // Forced installed extensions cannot be overwritten manually. | 64 // Forced installed extensions cannot be overwritten manually. |
64 if (extension->location() != Manifest::EXTERNAL_POLICY_DOWNLOAD && | 65 if (extension->location() != Manifest::EXTERNAL_POLICY && |
| 66 extension->location() != Manifest::EXTERNAL_POLICY_DOWNLOAD && |
65 forcelist && forcelist->HasKey(extension->id())) { | 67 forcelist && forcelist->HasKey(extension->id())) { |
66 return ReturnLoadError(extension, error); | 68 return ReturnLoadError(extension, error); |
67 } | 69 } |
68 | 70 |
69 // Early exit for the common case of no policy restrictions. | 71 // Early exit for the common case of no policy restrictions. |
70 if ((!blacklist || blacklist->empty()) && (!allowed_types)) | 72 if ((!blacklist || blacklist->empty()) && (!allowed_types)) |
71 return true; | 73 return true; |
72 | 74 |
73 // Check whether the extension type is allowed. | 75 // Check whether the extension type is allowed. |
74 // | 76 // |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 bool UserMayModifySettings(const Extension* extension, string16* error) { | 113 bool UserMayModifySettings(const Extension* extension, string16* error) { |
112 return ManagementPolicyImpl(extension, error, true); | 114 return ManagementPolicyImpl(extension, error, true); |
113 } | 115 } |
114 | 116 |
115 bool MustRemainEnabled(const Extension* extension, string16* error) { | 117 bool MustRemainEnabled(const Extension* extension, string16* error) { |
116 return ManagementPolicyImpl(extension, error, false); | 118 return ManagementPolicyImpl(extension, error, false); |
117 } | 119 } |
118 | 120 |
119 } // namespace admin_policy | 121 } // namespace admin_policy |
120 } // namespace extensions | 122 } // namespace extensions |
OLD | NEW |