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

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

Issue 20304002: Don't create extension actions for disabled extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 5 months 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_action_manager.cc
diff --git a/chrome/browser/extensions/extension_action_manager.cc b/chrome/browser/extensions/extension_action_manager.cc
index c92cad2015c047e9ffc311ba5c7ca548e73e4707..ade5095fde7ca2eed6585bfb2959f8f474523de6 100644
--- a/chrome/browser/extensions/extension_action_manager.cc
+++ b/chrome/browser/extensions/extension_action_manager.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/extensions/api/system_indicator/system_indicator_manager.h"
#include "chrome/browser/extensions/api/system_indicator/system_indicator_manager_factory.h"
#include "chrome/browser/extensions/extension_action.h"
+#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
@@ -106,13 +107,24 @@ ExtensionAction* GetOrCreateOrNull(
std::map<std::string, linked_ptr<ExtensionAction> >* map,
const std::string& extension_id,
ActionInfo::Type action_type,
- const ActionInfo* action_info) {
+ const ActionInfo* action_info,
+ Profile* profile) {
std::map<std::string, linked_ptr<ExtensionAction> >::const_iterator it =
map->find(extension_id);
if (it != map->end())
return it->second.get();
if (!action_info)
return NULL;
+
+ // Only create action info for enabled extensions.
+ // This avoids bugs where actions are recreated just after being removed
Jeffrey Yasskin 2013/07/30 00:25:22 Argh, use after free. :( Do you know which code pa
+ // in response to NOTIFICATION_EXTENSION_UNLOADED in
+ // ExtensionActionManager::Observe()
+ ExtensionService* service =
+ ExtensionSystem::Get(profile)->extension_service();
+ if (!service->GetExtensionById(extension_id, false))
+ return NULL;
+
linked_ptr<ExtensionAction> action(new ExtensionAction(
extension_id, action_type, *action_info));
(*map)[extension_id] = action;
@@ -129,7 +141,8 @@ ExtensionAction* ExtensionActionManager::GetPageAction(
return NULL;
return GetOrCreateOrNull(&page_actions_, extension.id(),
ActionInfo::TYPE_PAGE,
- ActionInfo::GetPageActionInfo(&extension));
+ ActionInfo::GetPageActionInfo(&extension),
+ profile_);
}
ExtensionAction* ExtensionActionManager::GetBrowserAction(
@@ -144,7 +157,7 @@ ExtensionAction* ExtensionActionManager::GetBrowserAction(
action_type = ActionInfo::TYPE_PAGE;
}
return GetOrCreateOrNull(&browser_actions_, extension.id(),
- action_type, action_info);
+ action_type, action_info, profile_);
}
ExtensionAction* ExtensionActionManager::GetSystemIndicator(
@@ -158,14 +171,16 @@ ExtensionAction* ExtensionActionManager::GetSystemIndicator(
return GetOrCreateOrNull(&system_indicators_, extension.id(),
ActionInfo::TYPE_SYSTEM_INDICATOR,
- ActionInfo::GetSystemIndicatorInfo(&extension));
+ ActionInfo::GetSystemIndicatorInfo(&extension),
+ profile_);
}
ExtensionAction* ExtensionActionManager::GetScriptBadge(
const extensions::Extension& extension) const {
return GetOrCreateOrNull(&script_badges_, extension.id(),
ActionInfo::TYPE_SCRIPT_BADGE,
- ActionInfo::GetScriptBadgeInfo(&extension));
+ ActionInfo::GetScriptBadgeInfo(&extension),
+ profile_);
}
} // namespace extensions
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698