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

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

Issue 2466523002: Remove some linked_ptr c/b/extension (Closed)
Patch Set: Created 4 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
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 fe476fadb4c0237af5395422bd78da5d36fc842f..f2aeb07e46deb2bbfe93876ed2c2dcd53e41c720 100644
--- a/chrome/browser/extensions/extension_action_manager.cc
+++ b/chrome/browser/extensions/extension_action_manager.cc
@@ -85,33 +85,32 @@ void ExtensionActionManager::OnExtensionUnloaded(
namespace {
// Returns map[extension_id] if that entry exists. Otherwise, if
-// action_info!=NULL, creates an ExtensionAction from it, fills in the map, and
-// returns that. Otherwise (action_info==NULL), returns NULL.
+// action_info!=nullptr, creates an ExtensionAction from it, fills in the map,
+// and returns that. Otherwise (action_info==nullptr), returns nullptr.
ExtensionAction* GetOrCreateOrNull(
- std::map<std::string, linked_ptr<ExtensionAction> >* map,
+ std::map<std::string, std::unique_ptr<ExtensionAction>>* map,
const Extension& extension,
ActionInfo::Type action_type,
const ActionInfo* action_info,
Profile* profile) {
- std::map<std::string, linked_ptr<ExtensionAction> >::const_iterator it =
- map->find(extension.id());
+ auto it = map->find(extension.id());
if (it != map->end())
return it->second.get();
if (!action_info)
- return NULL;
+ return nullptr;
// Only create action info for enabled extensions.
// This avoids bugs where actions are recreated just after being removed
// in response to OnExtensionUnloaded().
if (!ExtensionRegistry::Get(profile)
->enabled_extensions().Contains(extension.id())) {
- return NULL;
+ return nullptr;
}
- linked_ptr<ExtensionAction> action(new ExtensionAction(
- extension, action_type, *action_info));
- (*map)[extension.id()] = action;
- return action.get();
+ std::unique_ptr<ExtensionAction> action(
+ new ExtensionAction(extension, action_type, *action_info));
+ (*map)[extension.id()] = std::move(action);
+ return ((*map)[extension.id()]).get();
Devlin 2016/11/02 22:25:33 ditto
limasdf 2016/11/03 15:29:23 Done.
}
} // namespace
@@ -143,9 +142,8 @@ std::unique_ptr<ExtensionAction> ExtensionActionManager::GetBestFitAction(
// If no ActionInfo exists for |extension|, create and return a new action
// with a blank ActionInfo.
// Populate any missing values from |extension|'s manifest.
- std::unique_ptr<ExtensionAction> new_action(
- new ExtensionAction(extension, type, info ? *info : ActionInfo()));
- return new_action;
+ return base::MakeUnique<ExtensionAction>(extension, type,
+ info ? *info : ActionInfo());
}
ExtensionAction* ExtensionActionManager::GetSystemIndicator(
@@ -155,7 +153,7 @@ ExtensionAction* ExtensionActionManager::GetSystemIndicator(
// unavailable on the current system. If so, return NULL to signal that
// the system indicator area is unusable.
if (!SystemIndicatorManagerFactory::GetForProfile(profile_))
- return NULL;
+ return nullptr;
return GetOrCreateOrNull(&system_indicators_, extension,
ActionInfo::TYPE_SYSTEM_INDICATOR,

Powered by Google App Engine
This is Rietveld 408576698