diff options
author | levin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-22 23:47:33 +0000 |
---|---|---|
committer | levin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-22 23:47:33 +0000 |
commit | 27c6f11bfc8bf73d364fac6878f3ca27a92ae2e1 (patch) | |
tree | e6a22271fa57e164db621dc1e7454b6c81ff8b19 | |
parent | d3a2cefb1df16176943e1cb14d01a761d7398eea (diff) | |
download | chromium_src-27c6f11bfc8bf73d364fac6878f3ca27a92ae2e1.zip chromium_src-27c6f11bfc8bf73d364fac6878f3ca27a92ae2e1.tar.gz chromium_src-27c6f11bfc8bf73d364fac6878f3ca27a92ae2e1.tar.bz2 |
Revert 35184 - This seemed to cause BlacklistedExtensionWillNotInstall
to fail.
TBR=finnur@chromium.org
TEST=BlacklistedExtensionWillNotInstall
Review URL: http://codereview.chromium.org/514001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35187 0039d316-1c4b-4281-b951-d872f2087c98
6 files changed, 11 insertions, 72 deletions
diff --git a/chrome/browser/extensions/extension_disabled_infobar_delegate.cc b/chrome/browser/extensions/extension_disabled_infobar_delegate.cc index c95c2bb..feaa264 100644 --- a/chrome/browser/extensions/extension_disabled_infobar_delegate.cc +++ b/chrome/browser/extensions/extension_disabled_infobar_delegate.cc @@ -38,8 +38,6 @@ class ExtensionDisabledDialogDelegate // ExtensionInstallUI::Delegate virtual void InstallUIProceed() { - ExtensionPrefs* prefs = service_->extension_prefs(); - prefs->SetShowInstallWarningOnEnable(extension_, false); service_->EnableExtension(extension_->id()); Release(); } @@ -159,9 +157,3 @@ void ShowExtensionDisabledUI(ExtensionsService* service, Profile* profile, tab_contents->AddInfoBar(new ExtensionDisabledInfobarDelegate( tab_contents, service, extension)); } - -void ShowExtensionDisabledDialog(ExtensionsService* service, Profile* profile, - Extension* extension) { - // This object manages its own lifetime. - new ExtensionDisabledDialogDelegate(profile, service, extension); -} diff --git a/chrome/browser/extensions/extension_disabled_infobar_delegate.h b/chrome/browser/extensions/extension_disabled_infobar_delegate.h index 25efd3f..0c66ce9 100644 --- a/chrome/browser/extensions/extension_disabled_infobar_delegate.h +++ b/chrome/browser/extensions/extension_disabled_infobar_delegate.h @@ -16,8 +16,4 @@ class Profile; void ShowExtensionDisabledUI(ExtensionsService* service, Profile* profile, Extension* extension); -// Shows the extension install dialog. -void ShowExtensionDisabledDialog(ExtensionsService* service, Profile* profile, - Extension* extension); - #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_DISABLED_INFOBAR_DELEGATE_H_ diff --git a/chrome/browser/extensions/extension_prefs.cc b/chrome/browser/extensions/extension_prefs.cc index e835f32..d3d8b87 100644 --- a/chrome/browser/extensions/extension_prefs.cc +++ b/chrome/browser/extensions/extension_prefs.cc @@ -33,9 +33,6 @@ 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"; @@ -136,20 +133,19 @@ DictionaryValue* ExtensionPrefs::CopyCurrentExtensions() { return new DictionaryValue; } -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. +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. return false; } - return bool_value; + return is_blacklisted; } -bool ExtensionPrefs::ReadExtensionPrefBoolean( - const std::string& extension_id, const std::wstring& pref_key) { +bool ExtensionPrefs::IsExtensionBlacklisted(const std::string& extension_id) { const DictionaryValue* extensions = prefs_->GetDictionary(kExtensionsPref); DCHECK(extensions); @@ -163,20 +159,7 @@ bool ExtensionPrefs::ReadExtensionPrefBoolean( // No such extension yet. return false; } - 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, kExtensionsPref); -} - -bool ExtensionPrefs::DidExtensionEscalatePermissions( - const std::string& extension_id) { - return ReadExtensionPrefBoolean(extension_id, kShowInstallWarning); + return IsBlacklistBitSet(ext); } void ExtensionPrefs::UpdateBlacklist( @@ -368,13 +351,6 @@ 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) diff --git a/chrome/browser/extensions/extension_prefs.h b/chrome/browser/extensions/extension_prefs.h index e976b53..0488545 100644 --- a/chrome/browser/extensions/extension_prefs.h +++ b/chrome/browser/extensions/extension_prefs.h @@ -58,10 +58,6 @@ class ExtensionPrefs { // Called to change the extension's state when it is enabled/disabled. void SetExtensionState(Extension* extension, Extension::State); - // If |require| is true, the preferences for |extension| will be set to - // require the install warning when the user tries to enable. - void SetShowInstallWarningOnEnable(Extension* extension, bool require); - // Returns the version string for the currently installed extension, or // the empty string if not found. std::string GetVersionString(const std::string& extension_id); @@ -82,9 +78,6 @@ class ExtensionPrefs { // Based on extension id, checks prefs to see if it is blacklisted. bool IsExtensionBlacklisted(const std::string& id); - // Did the extension ask to escalate its permission during an upgrade? - bool DidExtensionEscalatePermissions(const std::string& id); - // Saves ExtensionInfo for each installed extension with the path to the // version directory and the location. Blacklisted extensions won't be saved // and neither will external extensions the user has explicitly uninstalled. @@ -109,14 +102,6 @@ class ExtensionPrefs { // Deletes the pref dictionary for extension |id|. void DeleteExtensionPrefs(const std::string& id); - // Reads a boolean pref from |ext| with key |pref_key|. - // Return false if the value is false or kPrefBlacklist does not exist. - bool ReadBooleanFromPref(DictionaryValue* ext, const std::wstring& pref_key); - - // Reads a boolean pref |pref_key| from extension with id |extension_id|. - bool ReadExtensionPrefBoolean(const std::string& extension_id, - const std::wstring& pref_key); - // Ensures and returns a mutable dictionary for extension |id|'s prefs. DictionaryValue* GetOrCreateExtensionPref(const std::string& id); diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc index e64956a..ae251f7 100644 --- a/chrome/browser/extensions/extensions_service.cc +++ b/chrome/browser/extensions/extensions_service.cc @@ -620,7 +620,6 @@ void ExtensionsService::OnExtensionLoaded(Extension* extension, // Extension has changed permissions significantly. Disable it. We // send a notification below. extension_prefs_->SetExtensionState(extension, Extension::DISABLED); - extension_prefs_->SetShowInstallWarningOnEnable(extension, true); } } else { // We already have the extension of the same or older version. diff --git a/chrome/browser/extensions/extensions_ui.cc b/chrome/browser/extensions/extensions_ui.cc index eadeafe..950b9b4 100644 --- a/chrome/browser/extensions/extensions_ui.cc +++ b/chrome/browser/extensions/extensions_ui.cc @@ -17,7 +17,6 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/debugger/devtools_manager.h" #include "chrome/browser/extensions/crx_installer.h" -#include "chrome/browser/extensions/extension_disabled_infobar_delegate.h" #include "chrome/browser/extensions/extension_function_dispatcher.h" #include "chrome/browser/extensions/extension_message_service.h" #include "chrome/browser/extensions/extensions_service.h" @@ -387,15 +386,7 @@ void ExtensionsDOMHandler::HandleEnableMessage(const Value* value) { CHECK(list->GetString(0, &extension_id)); CHECK(list->GetString(1, &enable_str)); if (enable_str == "true") { - ExtensionPrefs* prefs = extensions_service_->extension_prefs(); - if (prefs->DidExtensionEscalatePermissions(extension_id)) { - Extension* extension = - extensions_service_->GetExtensionById(extension_id, true); - ShowExtensionDisabledDialog(extensions_service_, - dom_ui_->GetProfile(), extension); - } else { - extensions_service_->EnableExtension(extension_id); - } + extensions_service_->EnableExtension(extension_id); } else { extensions_service_->DisableExtension(extension_id); } |