| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/standard_management_policy_provider.h" | 5 #include "chrome/browser/extensions/standard_management_policy_provider.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 if (Manifest::IsComponentLocation(extension->location())) | 76 if (Manifest::IsComponentLocation(extension->location())) |
| 77 return true; | 77 return true; |
| 78 | 78 |
| 79 // Shared modules are always allowed too: they only contain resources that | 79 // Shared modules are always allowed too: they only contain resources that |
| 80 // are used by other extensions. The extension that depends on the shared | 80 // are used by other extensions. The extension that depends on the shared |
| 81 // module may be filtered by policy. | 81 // module may be filtered by policy. |
| 82 if (extension->is_shared_module()) | 82 if (extension->is_shared_module()) |
| 83 return true; | 83 return true; |
| 84 | 84 |
| 85 ExtensionManagement::InstallationMode installation_mode = | 85 ExtensionManagement::InstallationMode installation_mode = |
| 86 settings_->GetInstallationMode(extension->id()); | 86 settings_->GetInstallationMode(extension); |
| 87 | 87 |
| 88 // Force-installed extensions cannot be overwritten manually. | 88 // Force-installed extensions cannot be overwritten manually. |
| 89 if (!Manifest::IsPolicyLocation(extension->location()) && | 89 if (!Manifest::IsPolicyLocation(extension->location()) && |
| 90 installation_mode == ExtensionManagement::INSTALLATION_FORCED) { | 90 installation_mode == ExtensionManagement::INSTALLATION_FORCED) { |
| 91 return ReturnLoadError(extension, error); | 91 return ReturnLoadError(extension, error); |
| 92 } | 92 } |
| 93 | 93 |
| 94 // Check whether the extension type is allowed. | 94 // Check whether the extension type is allowed. |
| 95 // | 95 // |
| 96 // If you get a compile error here saying that the type you added is not | 96 // If you get a compile error here saying that the type you added is not |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 base::string16* error) const { | 135 base::string16* error) const { |
| 136 return !AdminPolicyIsModifiable(extension, error) || | 136 return !AdminPolicyIsModifiable(extension, error) || |
| 137 (extension->location() == extensions::Manifest::EXTERNAL_COMPONENT && | 137 (extension->location() == extensions::Manifest::EXTERNAL_COMPONENT && |
| 138 ExternalComponentLoader::IsModifiable(extension)); | 138 ExternalComponentLoader::IsModifiable(extension)); |
| 139 } | 139 } |
| 140 | 140 |
| 141 bool StandardManagementPolicyProvider::MustRemainInstalled( | 141 bool StandardManagementPolicyProvider::MustRemainInstalled( |
| 142 const Extension* extension, | 142 const Extension* extension, |
| 143 base::string16* error) const { | 143 base::string16* error) const { |
| 144 ExtensionManagement::InstallationMode mode = | 144 ExtensionManagement::InstallationMode mode = |
| 145 settings_->GetInstallationMode(extension->id()); | 145 settings_->GetInstallationMode(extension); |
| 146 // Disallow removing of recommended extension, to avoid re-install it | 146 // Disallow removing of recommended extension, to avoid re-install it |
| 147 // again while policy is reload. But disabling of recommended extension is | 147 // again while policy is reload. But disabling of recommended extension is |
| 148 // allowed. | 148 // allowed. |
| 149 if (mode == ExtensionManagement::INSTALLATION_FORCED || | 149 if (mode == ExtensionManagement::INSTALLATION_FORCED || |
| 150 mode == ExtensionManagement::INSTALLATION_RECOMMENDED) { | 150 mode == ExtensionManagement::INSTALLATION_RECOMMENDED) { |
| 151 if (error) { | 151 if (error) { |
| 152 *error = l10n_util::GetStringFUTF16( | 152 *error = l10n_util::GetStringFUTF16( |
| 153 IDS_EXTENSION_CANT_UNINSTALL_POLICY_REQUIRED, | 153 IDS_EXTENSION_CANT_UNINSTALL_POLICY_REQUIRED, |
| 154 base::UTF8ToUTF16(extension->name())); | 154 base::UTF8ToUTF16(extension->name())); |
| 155 } | 155 } |
| 156 return true; | 156 return true; |
| 157 } | 157 } |
| 158 return false; | 158 return false; |
| 159 } | 159 } |
| 160 | 160 |
| 161 } // namespace extensions | 161 } // namespace extensions |
| OLD | NEW |