OLD | NEW |
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 "extensions/browser/admin_policy.h" | 5 #include "extensions/browser/admin_policy.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "extensions/common/extension.h" | 8 #include "extensions/common/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 base::string16* error, | 16 base::string16* error, |
17 bool modifiable_value) { | 17 bool modifiable_value) { |
| 18 // Note that COMPONENT and EXTERNAL_COMPONENT are treated differently |
| 19 // below. EXTERNAL_COMPONENT extensions can be modified including |
| 20 // enabled, disabled, uninstalled while COMPONENT extensions cannot. |
| 21 // However, those options are only available for EXTERNAL_COMPONENT |
| 22 // extensions when the proper command line flag is passed. |
18 bool modifiable = | 23 bool modifiable = |
19 !extensions::Manifest::IsComponentLocation(extension->location()) && | 24 extension->location() != extensions::Manifest::COMPONENT && |
20 !extensions::Manifest::IsPolicyLocation(extension->location()); | 25 !extensions::Manifest::IsPolicyLocation(extension->location()); |
21 // Some callers equate "no restriction" to true, others to false. | 26 // Some callers equate "no restriction" to true, others to false. |
22 if (modifiable) | 27 if (modifiable) |
23 return modifiable_value; | 28 return modifiable_value; |
24 | 29 |
25 if (error) { | 30 if (error) { |
26 *error = l10n_util::GetStringFUTF16( | 31 *error = l10n_util::GetStringFUTF16( |
27 IDS_EXTENSION_CANT_MODIFY_POLICY_REQUIRED, | 32 IDS_EXTENSION_CANT_MODIFY_POLICY_REQUIRED, |
28 base::UTF8ToUTF16(extension->name())); | 33 base::UTF8ToUTF16(extension->name())); |
29 } | 34 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 bool UserMayModifySettings(const Extension* extension, base::string16* error) { | 118 bool UserMayModifySettings(const Extension* extension, base::string16* error) { |
114 return ManagementPolicyImpl(extension, error, true); | 119 return ManagementPolicyImpl(extension, error, true); |
115 } | 120 } |
116 | 121 |
117 bool MustRemainEnabled(const Extension* extension, base::string16* error) { | 122 bool MustRemainEnabled(const Extension* extension, base::string16* error) { |
118 return ManagementPolicyImpl(extension, error, false); | 123 return ManagementPolicyImpl(extension, error, false); |
119 } | 124 } |
120 | 125 |
121 } // namespace admin_policy | 126 } // namespace admin_policy |
122 } // namespace extensions | 127 } // namespace extensions |
OLD | NEW |