| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 } | 131 } |
| 132 | 132 |
| 133 bool StandardManagementPolicyProvider::MustRemainEnabled( | 133 bool StandardManagementPolicyProvider::MustRemainEnabled( |
| 134 const Extension* extension, | 134 const Extension* extension, |
| 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::MustRemainDisabled( |
| 142 const Extension* extension, |
| 143 Extension::DisableReason* reason, |
| 144 base::string16* error) const { |
| 145 std::string required_version; |
| 146 if (!settings_->CheckMinimumVersion(extension, &required_version)) { |
| 147 if (reason) |
| 148 *reason = Extension::DISABLE_UPDATE_REQUIRED_BY_POLICY; |
| 149 if (error) { |
| 150 *error = l10n_util::GetStringFUTF16( |
| 151 IDS_EXTENSION_DISABLED_UPDATE_REQUIRED_BY_POLICY, |
| 152 base::UTF8ToUTF16(extension->name()), |
| 153 base::ASCIIToUTF16(required_version)); |
| 154 } |
| 155 return true; |
| 156 } |
| 157 return false; |
| 158 } |
| 159 |
| 141 bool StandardManagementPolicyProvider::MustRemainInstalled( | 160 bool StandardManagementPolicyProvider::MustRemainInstalled( |
| 142 const Extension* extension, | 161 const Extension* extension, |
| 143 base::string16* error) const { | 162 base::string16* error) const { |
| 144 ExtensionManagement::InstallationMode mode = | 163 ExtensionManagement::InstallationMode mode = |
| 145 settings_->GetInstallationMode(extension); | 164 settings_->GetInstallationMode(extension); |
| 146 // Disallow removing of recommended extension, to avoid re-install it | 165 // Disallow removing of recommended extension, to avoid re-install it |
| 147 // again while policy is reload. But disabling of recommended extension is | 166 // again while policy is reload. But disabling of recommended extension is |
| 148 // allowed. | 167 // allowed. |
| 149 if (mode == ExtensionManagement::INSTALLATION_FORCED || | 168 if (mode == ExtensionManagement::INSTALLATION_FORCED || |
| 150 mode == ExtensionManagement::INSTALLATION_RECOMMENDED) { | 169 mode == ExtensionManagement::INSTALLATION_RECOMMENDED) { |
| 151 if (error) { | 170 if (error) { |
| 152 *error = l10n_util::GetStringFUTF16( | 171 *error = l10n_util::GetStringFUTF16( |
| 153 IDS_EXTENSION_CANT_UNINSTALL_POLICY_REQUIRED, | 172 IDS_EXTENSION_CANT_UNINSTALL_POLICY_REQUIRED, |
| 154 base::UTF8ToUTF16(extension->name())); | 173 base::UTF8ToUTF16(extension->name())); |
| 155 } | 174 } |
| 156 return true; | 175 return true; |
| 157 } | 176 } |
| 158 return false; | 177 return false; |
| 159 } | 178 } |
| 160 | 179 |
| 161 } // namespace extensions | 180 } // namespace extensions |
| OLD | NEW |