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

Unified Diff: chrome/browser/extensions/extension_action.h

Issue 2537263003: [Extensions] Fix lifetime bug in ExtensionAction/IconImage (Closed)
Patch Set: Created 4 years 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_action.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_action.h
diff --git a/chrome/browser/extensions/extension_action.h b/chrome/browser/extensions/extension_action.h
index 393b2c77caa13cabb8f9aa6a4b840f6f9df91fd5..a65ce87e7fdfa87865a2579ee7511a011c6b40ba 100644
--- a/chrome/browser/extensions/extension_action.h
+++ b/chrome/browser/extensions/extension_action.h
@@ -19,10 +19,6 @@
class GURL;
-namespace content {
-class BrowserContext;
-}
-
namespace extensions {
class Extension;
class IconImage;
@@ -51,6 +47,10 @@ class ExtensionAction {
static extension_misc::ExtensionIcons ActionIconSize();
+ // Returns the default icon to use when no other is available (the puzzle
+ // piece).
+ static gfx::Image FallbackIcon();
+
// Use this ID to indicate the default state for properties that take a tab_id
// parameter.
static const int kDefaultTabId;
@@ -181,14 +181,11 @@ class ExtensionAction {
// Remove all tab-specific state.
void ClearAllValuesForTab(int tab_id);
- // Lazily loads and returns the default icon image, if one exists for the
- // action.
- extensions::IconImage* LoadDefaultIconImage(
- const extensions::Extension& extension,
- content::BrowserContext* browser_context);
+ // Sets the default IconImage for this action.
+ void SetDefaultIconImage(std::unique_ptr<extensions::IconImage> icon_image);
// Returns the image to use as the default icon for the action. Can only be
- // called after LoadDefaultIconImage().
+ // called after SetDefaultIconImage().
gfx::Image GetDefaultIconImage() const;
// Determine whether or not the ExtensionAction has a value set for the given
@@ -201,6 +198,10 @@ class ExtensionAction {
bool HasIsVisible(int tab_id) const;
bool HasIcon(int tab_id) const;
+ extensions::IconImage* default_icon_image() {
+ return default_icon_image_.get();
+ }
+
void SetDefaultIconForTest(std::unique_ptr<ExtensionIconSet> default_icon);
private:
@@ -285,8 +286,10 @@ class ExtensionAction {
// image representations will be selected.
std::unique_ptr<ExtensionIconSet> default_icon_;
- // The default icon image, if |default_icon_| exists.
- // Lazily initialized via LoadDefaultIconImage().
+ // The default icon image, if |default_icon_| exists. Set via
+ // SetDefaultIconImage(). Since IconImages depend upon BrowserContexts, we
+ // don't have the ExtensionAction load it directly to keep this class's
+ // knowledge limited.
std::unique_ptr<extensions::IconImage> default_icon_image_;
// The lazily-initialized image for a placeholder icon, in the event that the
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_action.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698