Chromium Code Reviews| Index: chrome/browser/extensions/extension_service.cc |
| diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc |
| index bd34f2459719d93512c939efb3f673a149347912..7bf9a02fc73dc75122cff2c19cf8acae43dc3b00 100644 |
| --- a/chrome/browser/extensions/extension_service.cc |
| +++ b/chrome/browser/extensions/extension_service.cc |
| @@ -1458,7 +1458,11 @@ bool ExtensionService::IsIncognitoEnabled( |
| void ExtensionService::SetIsIncognitoEnabled( |
| const std::string& extension_id, bool enabled) { |
| - const Extension* extension = GetInstalledExtension(extension_id); |
| + // When we reload the extension the ID may be invalidated if we've passed it |
| + // by const ref everywhere. Make a copy to be safe. |
| + std::string id = extension_id; |
|
Finnur
2011/11/11 16:01:07
nit: It would have been enough to make the copy ri
jstritar
2011/11/11 16:31:37
Done.
|
| + |
| + const Extension* extension = GetInstalledExtension(id); |
| if (extension && extension->location() == Extension::COMPONENT) { |
| // This shouldn't be called for component extensions. |
| NOTREACHED(); |
| @@ -1468,19 +1472,19 @@ void ExtensionService::SetIsIncognitoEnabled( |
| // Broadcast unloaded and loaded events to update browser state. Only bother |
| // if the value changed and the extension is actually enabled, since there is |
| // no UI otherwise. |
| - bool old_enabled = extension_prefs_->IsIncognitoEnabled(extension_id); |
| + bool old_enabled = extension_prefs_->IsIncognitoEnabled(id); |
| if (enabled == old_enabled) |
| return; |
| - extension_prefs_->SetIsIncognitoEnabled(extension_id, enabled); |
| + extension_prefs_->SetIsIncognitoEnabled(id, enabled); |
| bool extension_is_enabled = std::find(extensions_.begin(), extensions_.end(), |
| extension) != extensions_.end(); |
| if (extension_is_enabled) |
| - ReloadExtension(extension->id()); |
| + ReloadExtension(id); |
| // Reloading the extension invalidates the |extension| pointer. |
| - extension = GetInstalledExtension(extension_id); |
| + extension = GetInstalledExtension(id); |
| if (extension) |
| SyncExtensionChangeIfNeeded(*extension); |
| } |