Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5486)

Unified Diff: chrome/browser/extensions/extension_prefs.cc

Issue 10382149: Refactor the various ways to control what users can do to extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extension_prefs.h ('k') | chrome/browser/extensions/extension_prefs_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_prefs.cc
===================================================================
--- chrome/browser/extensions/extension_prefs.cc (revision 140193)
+++ chrome/browser/extensions/extension_prefs.cc (working copy)
@@ -22,6 +22,8 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/notification_service.h"
+#include "grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
using extensions::Extension;
using extensions::ExtensionInfo;
@@ -549,6 +551,24 @@
}
}
+bool ExtensionPrefs::ManagementPolicyImpl(const Extension* extension,
+ string16* error,
+ bool modifiable_value) const {
+ // An extension that is required (by admin policy, for example) cannot be
+ // modified.
+ bool modifiable = !Extension::IsRequired(extension->location());
+ // Some callers equate "no restriction" to true, others to false.
+ if (modifiable)
+ return modifiable_value;
+
+ if (error) {
+ *error = l10n_util::GetStringFUTF16(
+ IDS_EXTENSION_CANT_MODIFY_POLICY_REQUIRED,
+ UTF8ToUTF16(extension->name()));
+ }
+ return !modifiable_value;
+}
+
// static
bool ExtensionPrefs::IsBlacklistBitSet(DictionaryValue* ext) {
return ReadBooleanFromPref(ext, kPrefBlacklist);
@@ -640,15 +660,16 @@
Value::CreateBooleanValue(value));
}
-bool ExtensionPrefs::IsExtensionAllowedByPolicy(
- const std::string& extension_id,
- Extension::Location location) const {
- base::StringValue id_value(extension_id);
+std::string ExtensionPrefs::GetPolicyProviderName() const {
+ return "admin policy black/whitelist, via the ExtensionPrefs";
+}
- if (location == Extension::COMPONENT ||
- location == Extension::EXTERNAL_POLICY_DOWNLOAD) {
+bool ExtensionPrefs::UserMayLoad(const extensions::Extension* extension,
+ string16* error) const {
+ base::StringValue id_value(extension->id());
+
+ if (extensions::Extension::IsRequired(extension->location()))
return true;
- }
const base::ListValue* blacklist =
prefs_->GetList(prefs::kExtensionInstallDenyList);
@@ -662,10 +683,27 @@
return true;
// Then check the blacklist (the admin blacklist, not the Google blacklist).
- return blacklist->Find(id_value) == blacklist->end() &&
- !ExtensionsBlacklistedByDefault();
+ bool result = blacklist->Find(id_value) == blacklist->end() &&
+ !ExtensionsBlacklistedByDefault();
+ if (error && !result) {
+ *error = l10n_util::GetStringFUTF16(
+ IDS_EXTENSION_CANT_INSTALL_POLICY_BLACKLIST,
+ UTF8ToUTF16(extension->name()),
+ UTF8ToUTF16(extension->id()));
+ }
+ return result;
}
+bool ExtensionPrefs::UserMayModifySettings(const Extension* extension,
+ string16* error) const {
+ return ManagementPolicyImpl(extension, error, true);
+}
+
+bool ExtensionPrefs::MustRemainEnabled(const Extension* extension,
+ string16* error) const {
+ return ManagementPolicyImpl(extension, error, false);
+}
+
bool ExtensionPrefs::ExtensionsBlacklistedByDefault() const {
const base::ListValue* blacklist =
prefs_->GetList(prefs::kExtensionInstallDenyList);
« no previous file with comments | « chrome/browser/extensions/extension_prefs.h ('k') | chrome/browser/extensions/extension_prefs_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698