diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-10 23:52:02 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-10 23:52:02 +0000 |
commit | 6de0b5a0775d6b22d2a65d258199e877916ff120 (patch) | |
tree | 4474a1f805985c5f0fda142c61d0b7a497ad247f /chrome/browser/extensions/extension_disabled_ui_browsertest.cc | |
parent | 3e011d80be8aef1a3cc3779c3fe8f04a394f3aff (diff) | |
download | chromium_src-6de0b5a0775d6b22d2a65d258199e877916ff120.zip chromium_src-6de0b5a0775d6b22d2a65d258199e877916ff120.tar.gz chromium_src-6de0b5a0775d6b22d2a65d258199e877916ff120.tar.bz2 |
Revert 131665 - Add a preference for why an extension is disabled.
Broke linux browser_tests ExtensionManagementApiEscalationTest.DisabledReason,ReEnable
Don't show the permissions upgrade alert for extensions disabled by the user.
For existing disabled extensions, guess the disabling reason from whether they exceed their granted permissions.
BUG=121436
TEST=ExtensionDisabledGlobalErrorTest.*
TBR=csilv@chromium.org,jianli@chromium.org,mark@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10014005
TBR=yoz@chromium.org
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131676 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_disabled_ui_browsertest.cc')
-rw-r--r-- | chrome/browser/extensions/extension_disabled_ui_browsertest.cc | 106 |
1 files changed, 13 insertions, 93 deletions
diff --git a/chrome/browser/extensions/extension_disabled_ui_browsertest.cc b/chrome/browser/extensions/extension_disabled_ui_browsertest.cc index 8d30040..d908fa0 100644 --- a/chrome/browser/extensions/extension_disabled_ui_browsertest.cc +++ b/chrome/browser/extensions/extension_disabled_ui_browsertest.cc @@ -2,15 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/file_path.h" -#include "base/scoped_temp_dir.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/extensions/extension_browsertest.h" -#include "chrome/browser/extensions/extension_prefs.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/global_error.h" #include "chrome/browser/ui/global_error_service.h" #include "chrome/browser/ui/global_error_service_factory.h" #include "chrome/common/extensions/extension.h" @@ -18,25 +14,7 @@ class ExtensionDisabledGlobalErrorTest : public ExtensionBrowserTest { protected: void SetUpOnMainThread() { - EXPECT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); service_ = browser()->profile()->GetExtensionService(); - FilePath pem_path = test_data_dir_. - AppendASCII("permissions_increase").AppendASCII("permissions.pem"); - path_v1_ = PackExtensionWithOptions( - test_data_dir_.AppendASCII("permissions_increase").AppendASCII("v1"), - scoped_temp_dir_.path().AppendASCII("permissions1.crx"), - pem_path, - FilePath()); - path_v2_ = PackExtensionWithOptions( - test_data_dir_.AppendASCII("permissions_increase").AppendASCII("v2"), - scoped_temp_dir_.path().AppendASCII("permissions2.crx"), - pem_path, - FilePath()); - path_v3_ = PackExtensionWithOptions( - test_data_dir_.AppendASCII("permissions_increase").AppendASCII("v3"), - scoped_temp_dir_.path().AppendASCII("permissions3.crx"), - pem_path, - FilePath()); } // Returns the ExtensionDisabledGlobalError, if present. @@ -46,46 +24,33 @@ class ExtensionDisabledGlobalErrorTest : public ExtensionBrowserTest { GetGlobalErrorByMenuItemCommandID(IDC_EXTENSION_DISABLED_FIRST); } - // Install the initial version, which should happen just fine. - const Extension* InstallIncreasingPermissionExtensionV1() { + // Helper function to install an extension and upgrade it to a version + // requiring additional permissions. Returns the new disabled Extension. + const Extension* InstallAndUpdateIncreasingPermissionsExtension() { size_t size_before = service_->extensions()->size(); - const Extension* extension = InstallExtension(path_v1_, 1); + + // Install the initial version, which should happen just fine. + const Extension* extension = InstallExtension( + test_data_dir_.AppendASCII("permissions-low-v1.crx"), 1); if (!extension) return NULL; if (service_->extensions()->size() != size_before + 1) return NULL; - return extension; - } - // Upgrade to a version that wants more permissions. We should disable the - // extension and prompt the user to reenable. - const Extension* UpdateIncreasingPermissionExtension( - const Extension* extension, - const FilePath& crx_path, - int expected_change) { - size_t size_before = service_->extensions()->size(); - if (UpdateExtension(extension->id(), crx_path, expected_change)) + // Upgrade to a version that wants more permissions. We should disable the + // extension and prompt the user to reenable. + if (UpdateExtension( + extension->id(), + test_data_dir_.AppendASCII("permissions-high-v2.crx"), -1)) return NULL; - EXPECT_EQ(size_before + expected_change, service_->extensions()->size()); + EXPECT_EQ(size_before, service_->extensions()->size()); if (service_->disabled_extensions()->size() != 1u) return NULL; return *service_->disabled_extensions()->begin(); } - // Helper function to install an extension and upgrade it to a version - // requiring additional permissions. Returns the new disabled Extension. - const Extension* InstallAndUpdateIncreasingPermissionsExtension() { - const Extension* extension = InstallIncreasingPermissionExtensionV1(); - extension = UpdateIncreasingPermissionExtension(extension, path_v2_, -1); - return extension; - } - ExtensionService* service_; - ScopedTempDir scoped_temp_dir_; - FilePath path_v1_; - FilePath path_v2_; - FilePath path_v3_; }; // Tests the process of updating an extension to one that requires higher @@ -114,48 +79,3 @@ IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, Uninstall) { EXPECT_EQ(0u, service_->disabled_extensions()->size()); ASSERT_FALSE(GetExtensionDisabledGlobalError()); } - -// Tests that no error appears if the user disabled the extension. -IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, UserDisabled) { - const Extension* extension = InstallIncreasingPermissionExtensionV1(); - DisableExtension(extension->id()); - extension = UpdateIncreasingPermissionExtension(extension, path_v2_, 0); - ASSERT_FALSE(GetExtensionDisabledGlobalError()); -} - -// Test that no error appears if the disable reason is unknown -// (but probably was by the user). -IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, - UnknownReasonSamePermissions) { - const Extension* extension = InstallIncreasingPermissionExtensionV1(); - DisableExtension(extension->id()); - // Clear disable reason to simulate legacy disables. - service_->extension_prefs()->RemoveDisableReason(extension->id()); - // Upgrade to version 2. Infer from version 1 having the same permissions - // granted by the user that it was disabled by the user. - extension = UpdateIncreasingPermissionExtension(extension, path_v2_, 0); - ASSERT_TRUE(extension); - ASSERT_FALSE(GetExtensionDisabledGlobalError()); -} - -// Test that an error appears if the disable reason is unknown -// (but probably was for increased permissions). -IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, - UnknownReasonHigherPermissions) { - const Extension* extension = InstallAndUpdateIncreasingPermissionsExtension(); - // Clear disable reason to simulate legacy disables. - service_->extension_prefs()->RemoveDisableReason(extension->id()); - // We now have version 2 but only accepted permissions for version 1. - GlobalError* error = GetExtensionDisabledGlobalError(); - ASSERT_TRUE(error); - // Also, remove the upgrade error for version 2. - GlobalErrorServiceFactory::GetForProfile(browser()->profile())-> - RemoveGlobalError(error); - delete error; - // Upgrade to version 3, with even higher permissions. Infer from - // version 2 having higher-than-granted permissions that it was disabled - // for permissions increase. - extension = UpdateIncreasingPermissionExtension(extension, path_v3_, 0); - ASSERT_TRUE(extension); - ASSERT_TRUE(GetExtensionDisabledGlobalError()); -} |