Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(698)

Unified Diff: chrome/browser/extensions/extension_service.cc

Issue 8333021: Fix a crash in PageActionImageView when extensions are reloaded due to incognito settings changing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_service_unittest.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_service.cc
===================================================================
--- chrome/browser/extensions/extension_service.cc (revision 108847)
+++ chrome/browser/extensions/extension_service.cc (working copy)
@@ -1165,7 +1165,7 @@
namespace {
bool IsSyncableNone(const Extension& extension) { return false; }
-} // namespace
+} // namespace
ExtensionService::SyncBundle::SyncBundle()
: filter(IsSyncableNone),
@@ -1407,11 +1407,18 @@
} else {
DisableExtension(id);
}
+
+ // We need to cache some version information here because setting the
+ // incognito flag invalidates the |extension| pointer (it reloads the
+ // extension).
+ bool extension_installed = extension != NULL;
+ int result = extension ?
+ extension->version()->CompareTo(extension_sync_data.version()) : 0;
SetIsIncognitoEnabled(id, extension_sync_data.incognito_enabled());
+ extension = NULL; // No longer safe to use.
- if (extension) {
+ if (extension_installed) {
// If the extension is already installed, check if it's outdated.
- int result = extension->version()->CompareTo(extension_sync_data.version());
if (result < 0) {
// Extension is outdated.
bundle.pending_sync_data[extension_sync_data.id()] = extension_sync_data;
@@ -1468,15 +1475,13 @@
extension_prefs_->SetIsIncognitoEnabled(extension_id, enabled);
- // If the extension is enabled (and not terminated), unload and
- // reload it to update UI.
- const Extension* enabled_extension = GetExtensionById(extension_id, false);
- if (enabled_extension) {
- NotifyExtensionUnloaded(
- enabled_extension, extension_misc::UNLOAD_REASON_DISABLE);
- NotifyExtensionLoaded(enabled_extension);
- }
+ bool extension_is_enabled = std::find(extensions_.begin(), extensions_.end(),
+ extension) != extensions_.end();
+ if (extension_is_enabled)
+ ReloadExtension(extension->id());
+ // Reloading the extension invalidates the |extension| pointer.
+ extension = GetInstalledExtension(extension_id);
if (extension)
SyncExtensionChangeIfNeeded(*extension);
}
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_service_unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698