Commit 533a6247 authored by asargent@chromium.org's avatar asargent@chromium.org

Fix crash when you uninstall a permissions-upgrade disabled extension.

When an extension is disabled because a newer version requires higher
permissions, if you then uninstall the extension while the infobar warning
is still up, you'll get a crash if you switch to the tab that had the infobar.
This patch makes the infobar notice the extension uninstall and remove itself.

BUG=84826
TEST=As detailed in description above (and outlined in bug report too).


Review URL: http://codereview.chromium.org/7003068

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88458 0039d316-1c4b-4281-b951-d872f2087c98
parent 50454621
......@@ -152,14 +152,15 @@ void ExtensionDisabledInfobarDelegate::Observe(
const NotificationDetails& details) {
// TODO(mpcomplete): RemoveInfoBar doesn't seem to always result in us getting
// deleted.
const Extension* extension;
const Extension* extension = NULL;
if (type.value == NotificationType::EXTENSION_LOADED) {
extension = Details<const Extension>(details).ptr();
} else {
DCHECK_EQ(NotificationType::EXTENSION_UNLOADED, type.value);
UnloadedExtensionInfo* info = Details<UnloadedExtensionInfo>(details).ptr();
extension = (info->reason == UnloadedExtensionInfo::DISABLE) ?
info->extension : NULL;
if (info->reason == UnloadedExtensionInfo::DISABLE ||
info->reason == UnloadedExtensionInfo::UNINSTALL)
extension = info->extension;
}
if (extension == extension_)
tab_contents_->RemoveInfoBar(this);
......
......@@ -14,6 +14,7 @@
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/ui_test_utils.h"
......@@ -149,6 +150,31 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, UpdatePermissions) {
EXPECT_EQ(0u, service->disabled_extensions()->size());
}
// Tests uninstalling an extension that was disabled due to higher permissions.
IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, UpdatePermissionsAndUninstall) {
ASSERT_TRUE(InstallAndUpdateIncreasingPermissionsExtension());
// Make sure the "disable extension" infobar is present.
ASSERT_EQ(0, browser()->active_index());
TabContentsWrapper* wrapper = browser()->GetTabContentsWrapperAt(0);
ASSERT_EQ(1U, wrapper->infobar_count());
// Uninstall, and check that the infobar went away.
ExtensionService* service = browser()->profile()->GetExtensionService();
std::string id = service->disabled_extensions()->at(0)->id();
UninstallExtension(id);
ASSERT_EQ(0U, wrapper->infobar_count());
// Now select a new tab, and switch back to the first tab which had the
// infobar. We should not crash.
ASSERT_EQ(1, browser()->tab_count());
ASSERT_EQ(0, browser()->active_index());
browser()->NewTab();
ASSERT_EQ(2, browser()->tab_count());
ASSERT_EQ(1, browser()->active_index());
browser()->ActivateTabAt(0, true);
}
// Tests that we can uninstall a disabled extension.
IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, UninstallDisabled) {
ExtensionService* service = browser()->profile()->GetExtensionService();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment