summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_prefs.cc
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-04 21:28:57 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-04 21:28:57 +0000
commit7d84586758336eb12b77bfc9d1a3f0e07a351a6d (patch)
tree827d3ceeb826d153ad2217651ac62c2f362ff5c4 /chrome/browser/extensions/extension_prefs.cc
parent97c6401de6a70293b8c6506408934d9f15749cfb (diff)
downloadchromium_src-7d84586758336eb12b77bfc9d1a3f0e07a351a6d.zip
chromium_src-7d84586758336eb12b77bfc9d1a3f0e07a351a6d.tar.gz
chromium_src-7d84586758336eb12b77bfc9d1a3f0e07a351a6d.tar.bz2
Permission escalation when extension updates should trigger the install warning
when enabling the extension through the Extensions Management UI. TBR=mpcomplete BUG=http://crbug.com/30752 TEST=This requires an extension that autoupdates _and_ increases its permissions. If you ignore the infobar that says it has been disabled, you should still get the Install Warning dialog when you try to enable the extension. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35480 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_prefs.cc')
-rw-r--r--chrome/browser/extensions/extension_prefs.cc44
1 files changed, 34 insertions, 10 deletions
diff --git a/chrome/browser/extensions/extension_prefs.cc b/chrome/browser/extensions/extension_prefs.cc
index d3d8b87..bc01719 100644
--- a/chrome/browser/extensions/extension_prefs.cc
+++ b/chrome/browser/extensions/extension_prefs.cc
@@ -33,6 +33,9 @@ const wchar_t kPrefVersion[] = L"manifest.version";
// Indicates if an extension is blacklisted:
const wchar_t kPrefBlacklist[] = L"blacklist";
+// Indicates whether to show an install warning when the user enables.
+const wchar_t kShowInstallWarning[] = L"install_warning_on_enable";
+
// A preference that tracks extension shelf configuration. This is a list
// object read from the Preferences file, containing a list of toolstrip URLs.
const wchar_t kExtensionShelf[] = L"extensions.shelf";
@@ -133,19 +136,20 @@ DictionaryValue* ExtensionPrefs::CopyCurrentExtensions() {
return new DictionaryValue;
}
-bool ExtensionPrefs::IsBlacklistBitSet(DictionaryValue* ext) {
- if (!ext->HasKey(kPrefBlacklist)) return false;
- bool is_blacklisted = false;
- if (!ext->GetBoolean(kPrefBlacklist, &is_blacklisted)) {
- NOTREACHED() << "Failed to fetch blacklist flag.";
- // In case we could not fetch the flag, we consider the extension
- // is NOT blacklisted.
+bool ExtensionPrefs::ReadBooleanFromPref(
+ DictionaryValue* ext, const std::wstring& pref_key) {
+ if (!ext->HasKey(pref_key)) return false;
+ bool bool_value = false;
+ if (!ext->GetBoolean(pref_key, &bool_value)) {
+ NOTREACHED() << "Failed to fetch " << pref_key << " flag.";
+ // In case we could not fetch the flag, we treat it as false.
return false;
}
- return is_blacklisted;
+ return bool_value;
}
-bool ExtensionPrefs::IsExtensionBlacklisted(const std::string& extension_id) {
+bool ExtensionPrefs::ReadExtensionPrefBoolean(
+ const std::string& extension_id, const std::wstring& pref_key) {
const DictionaryValue* extensions = prefs_->GetDictionary(kExtensionsPref);
DCHECK(extensions);
@@ -159,7 +163,20 @@ bool ExtensionPrefs::IsExtensionBlacklisted(const std::string& extension_id) {
// No such extension yet.
return false;
}
- return IsBlacklistBitSet(ext);
+ return ReadBooleanFromPref(ext, pref_key);
+}
+
+bool ExtensionPrefs::IsBlacklistBitSet(DictionaryValue* ext) {
+ return ReadBooleanFromPref(ext, kPrefBlacklist);
+}
+
+bool ExtensionPrefs::IsExtensionBlacklisted(const std::string& extension_id) {
+ return ReadExtensionPrefBoolean(extension_id, kPrefBlacklist);
+}
+
+bool ExtensionPrefs::DidExtensionEscalatePermissions(
+ const std::string& extension_id) {
+ return ReadExtensionPrefBoolean(extension_id, kShowInstallWarning);
}
void ExtensionPrefs::UpdateBlacklist(
@@ -351,6 +368,13 @@ void ExtensionPrefs::SetExtensionState(Extension* extension,
prefs_->SavePersistentPrefs();
}
+void ExtensionPrefs::SetShowInstallWarningOnEnable(
+ Extension* extension, bool require) {
+ UpdateExtensionPref(extension->id(), kShowInstallWarning,
+ Value::CreateBooleanValue(require));
+ prefs_->SavePersistentPrefs();
+}
+
std::string ExtensionPrefs::GetVersionString(const std::string& extension_id) {
DictionaryValue* extension = GetExtensionPref(extension_id);
if (!extension)