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

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

Issue 2506273002: [Extensions] Fix lifetime bug in ExtensionAction/IconImage (Closed)
Patch Set: missingfile 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 6d197c9046067590785fb780f6053df66dd2aa7f..30b5c7605f84c95024634cef18c0ac2a316c22b6 100644
--- a/chrome/browser/extensions/extension_action_manager.cc
+++ b/chrome/browser/extensions/extension_action_manager.cc
@@ -4,14 +4,17 @@
#include "chrome/browser/extensions/extension_action_manager.h"
+#include "base/memory/ptr_util.h"
#include "chrome/browser/extensions/api/system_indicator/system_indicator_manager_factory.h"
#include "chrome/browser/extensions/extension_action.h"
#include "chrome/browser/profiles/profile.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
+#include "extensions/browser/extension_icon_image.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/common/constants.h"
+#include "ui/gfx/image/image_skia.h"
namespace extensions {
@@ -107,8 +110,16 @@ ExtensionAction* GetOrCreateOrNull(
return nullptr;
}
- std::unique_ptr<ExtensionAction> action(
- new ExtensionAction(extension, action_type, *action_info));
+ auto action =
+ base::MakeUnique<ExtensionAction>(extension, action_type, *action_info);
+
+ if (action->default_icon()) {
+ action->SetDefaultIconImage(base::MakeUnique<IconImage>(
+ profile, &extension, *action->default_icon(),
+ ExtensionAction::ActionIconSize(),
+ ExtensionAction::DefaultIcon().AsImageSkia(), nullptr));
asargent_no_longer_on_chrome 2016/11/18 00:55:27 The naming here is pretty confusing and I really h
Devlin 2016/11/18 01:56:47 Rename DefaultIcon() to FallbackIcon() - I agree t
asargent_no_longer_on_chrome 2016/11/18 18:29:33 Yeah, agreed. I guess to complete the thought, I w
+ }
+
ExtensionAction* raw_action = action.get();
(*map)[extension.id()] = std::move(action);
return raw_action;

Powered by Google App Engine
This is Rietveld 408576698