diff options
author | jstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-28 02:32:03 +0000 |
---|---|---|
committer | jstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-28 02:32:03 +0000 |
commit | 353853301c360c31da37d0c860a7ef1087bf8681 (patch) | |
tree | 11898aaf129bfebebbec82dc195c290ae89df5de /chrome | |
parent | 8ec9e52ddca20b7241deaff1e61b52392c87e336 (diff) | |
download | chromium_src-353853301c360c31da37d0c860a7ef1087bf8681.zip chromium_src-353853301c360c31da37d0c860a7ef1087bf8681.tar.gz chromium_src-353853301c360c31da37d0c860a7ef1087bf8681.tar.bz2 |
Remove CrxInstaller::SetWhitelistedInstallId and related code.
This has been deprecated by CrxInstaller::WhitelistEntry, which includes additional checks like the extension's parsed manifest.
BUG=100584
TEST=existing
Review URL: https://chromiumcodereview.appspot.com/9802008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129349 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/extensions/crx_installer.cc | 28 | ||||
-rw-r--r-- | chrome/browser/extensions/crx_installer.h | 19 | ||||
-rw-r--r-- | chrome/browser/extensions/crx_installer_browsertest.cc | 24 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_webstore_private_api.cc | 6 | ||||
-rw-r--r-- | chrome/test/data/extensions/uitest/plugins.crx | bin | 145386 -> 0 bytes | |||
-rw-r--r-- | chrome/test/data/extensions/uitest/plugins/manifest.json | 3 |
6 files changed, 21 insertions, 59 deletions
diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc index 17f6e82..19c38d8 100644 --- a/chrome/browser/extensions/crx_installer.cc +++ b/chrome/browser/extensions/crx_installer.cc @@ -54,7 +54,6 @@ namespace { // TODO(jstritar): this whitelist is not profile aware. struct Whitelist { Whitelist() {} - std::set<std::string> ids; std::map<std::string, linked_ptr<CrxInstaller::WhitelistEntry> > entries; }; @@ -76,12 +75,6 @@ scoped_refptr<CrxInstaller> CrxInstaller::Create( } // static -void CrxInstaller::SetWhitelistedInstallId(const std::string& id) { - CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - g_whitelisted_install_data.Get().ids.insert(id); -} - -// static void CrxInstaller::SetWhitelistEntry(const std::string& id, CrxInstaller::WhitelistEntry* entry) { CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -113,24 +106,6 @@ CrxInstaller::WhitelistEntry* CrxInstaller::RemoveWhitelistEntry( return NULL; } -// static -bool CrxInstaller::IsIdWhitelisted(const std::string& id) { - CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - std::set<std::string>& ids = g_whitelisted_install_data.Get().ids; - return ContainsKey(ids, id); -} - -// static -bool CrxInstaller::ClearWhitelistedInstallId(const std::string& id) { - CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - std::set<std::string>& ids = g_whitelisted_install_data.Get().ids; - if (ContainsKey(ids, id)) { - ids.erase(id); - return true; - } - return false; -} - CrxInstaller::CrxInstaller(base::WeakPtr<ExtensionService> frontend_weak, ExtensionInstallUI* client) : install_directory_(frontend_weak->install_directory()), @@ -410,9 +385,6 @@ void CrxInstaller::ConfirmInstall() { current_version_ = frontend_weak_->extension_prefs()->GetVersionString(extension_->id()); - // TODO(asargent) - remove this when we fully deprecate the old install api. - ClearWhitelistedInstallId(extension_->id()); - bool whitelisted = false; scoped_ptr<CrxInstaller::WhitelistEntry> entry( RemoveWhitelistEntry(extension_->id())); diff --git a/chrome/browser/extensions/crx_installer.h b/chrome/browser/extensions/crx_installer.h index f35cb0c..7431d6e9 100644 --- a/chrome/browser/extensions/crx_installer.h +++ b/chrome/browser/extensions/crx_installer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -60,16 +60,6 @@ class CrxInstaller ExtensionService* frontend, ExtensionInstallUI* client); - // This is pretty lame, but given the difficulty of connecting a particular - // ExtensionFunction to a resulting download in the download manager, it's - // currently necessary. This is the |id| of an extension to be installed - // *by the web store only* which should not get the permissions install - // prompt. This should only be called on the UI thread. - // crbug.com/54916 - // TODO(asargent): This should be removed now that SetWhitelistEntry exists - // http://crbug.com/100584 - static void SetWhitelistedInstallId(const std::string& id); - struct WhitelistEntry { WhitelistEntry(); ~WhitelistEntry(); @@ -100,13 +90,6 @@ class CrxInstaller // the return value and is responsible for deleting it. static WhitelistEntry* RemoveWhitelistEntry(const std::string& id); - // Returns whether |id| is whitelisted - only call this on the UI thread. - static bool IsIdWhitelisted(const std::string& id); - - // Returns whether |id| was found and removed (was whitelisted). This should - // only be called on the UI thread. - static bool ClearWhitelistedInstallId(const std::string& id); - // Install the crx in |source_file|. void InstallCrx(const FilePath& source_file); diff --git a/chrome/browser/extensions/crx_installer_browsertest.cc b/chrome/browser/extensions/crx_installer_browsertest.cc index c3aa49c..20e9e59 100644 --- a/chrome/browser/extensions/crx_installer_browsertest.cc +++ b/chrome/browser/extensions/crx_installer_browsertest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,6 +9,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/extensions/extension_file_util.h" #include "chrome/test/base/ui_test_utils.h" class SkBitmap; @@ -47,21 +48,28 @@ class ExtensionCrxInstallerTest : public ExtensionBrowserTest { // Installs a crx from |crx_relpath| (a path relative to the extension test // data dir) with expected id |id|. Returns whether a confirmation prompt // happened or not. - bool DidWhitelistInstallPrompt(const std::string& crx_relpath, + bool DidWhitelistInstallPrompt(const std::string& ext_relpath, const std::string& id) { ExtensionService* service = browser()->profile()->GetExtensionService(); MockInstallUI* mock_install_ui = new MockInstallUI(browser()->profile()); + FilePath ext_path = test_data_dir_.AppendASCII(ext_relpath); + + std::string error; + base::DictionaryValue* parsed_manifest = + extension_file_util::LoadManifest(ext_path, &error); + if (!parsed_manifest) + return false; + + CrxInstaller::WhitelistEntry* entry = new CrxInstaller::WhitelistEntry; + entry->parsed_manifest.reset(parsed_manifest); + CrxInstaller::SetWhitelistEntry(id, entry); scoped_refptr<CrxInstaller> installer( CrxInstaller::Create(service, mock_install_ui /* ownership transferred */)); - installer->set_allow_silent_install(true); installer->set_is_gallery_install(true); - CrxInstaller::SetWhitelistedInstallId(id); - - FilePath crx_path = test_data_dir_.AppendASCII(crx_relpath); - installer->InstallCrx(crx_path); + installer->InstallCrx(PackExtension(ext_path)); ui_test_utils::RunMessageLoop(); return mock_install_ui->confirmation_requested(); @@ -71,7 +79,7 @@ class ExtensionCrxInstallerTest : public ExtensionBrowserTest { IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, Whitelisting) { #if !defined(OS_CHROMEOS) // An extension with NPAPI should give a prompt. - EXPECT_TRUE(DidWhitelistInstallPrompt("uitest/plugins.crx", + EXPECT_TRUE(DidWhitelistInstallPrompt("uitest/plugins", "hdgllgikmikobbofgnabhfimcfoopgnd")); #endif // !defined(OS_CHROMEOS) } diff --git a/chrome/browser/extensions/extension_webstore_private_api.cc b/chrome/browser/extensions/extension_webstore_private_api.cc index 50c13a9..33c76d0 100644 --- a/chrome/browser/extensions/extension_webstore_private_api.cc +++ b/chrome/browser/extensions/extension_webstore_private_api.cc @@ -411,16 +411,14 @@ bool CompleteInstallFunction::RunImpl() { return false; } - if (!CrxInstaller::IsIdWhitelisted(id) && - !CrxInstaller::GetWhitelistEntry(id)) { + if (!CrxInstaller::GetWhitelistEntry(id)) { error_ = ExtensionErrorUtils::FormatErrorMessage( kNoPreviousBeginInstallWithManifestError, id); return false; } // The extension will install through the normal extension install flow, but - // the above call to SetWhitelistedInstallId will bypass the normal - // permissions install dialog. + // the whitelist entry will bypass the normal permissions install dialog. scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( profile(), test_webstore_installer_delegate, &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), diff --git a/chrome/test/data/extensions/uitest/plugins.crx b/chrome/test/data/extensions/uitest/plugins.crx Binary files differdeleted file mode 100644 index acd205ab..0000000 --- a/chrome/test/data/extensions/uitest/plugins.crx +++ /dev/null diff --git a/chrome/test/data/extensions/uitest/plugins/manifest.json b/chrome/test/data/extensions/uitest/plugins/manifest.json index 4cdfd5d..c9ee2fe 100644 --- a/chrome/test/data/extensions/uitest/plugins/manifest.json +++ b/chrome/test/data/extensions/uitest/plugins/manifest.json @@ -7,5 +7,6 @@ {"path": "plugin.dll", "public": true}, {"path": "plugin32.so", "public": true}, {"path": "plugin64.so", "public": true} - ] + ], + "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDj9LZkfWJsVHxsiciugy+jRvNZxg+OXdTL6KZknEUZ9T1cAkeAHiIsedp2ltg/pLnpFx8U7YUG88W4p+PSSkmqMHKPOzav9hIfwTi3FHZUEqWaTs76UUegefdZtZsCA1omSDP7tIClsyWVSnv92njT1FZV/zHj9AmxtinaheQ2WQIDAQAB" } |