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

Side by Side Diff: chrome/browser/extensions/extension_action.h

Issue 882243002: [Extensions] Make extension actions use gfx::Image over gfx::ImageSkia. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 5 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 // Set this action's icon bitmap on a specific tab. 98 // Set this action's icon bitmap on a specific tab.
99 void SetIcon(int tab_id, const gfx::Image& image); 99 void SetIcon(int tab_id, const gfx::Image& image);
100 100
101 // Tries to parse |*icon| from a dictionary {"19": imageData19, "38": 101 // Tries to parse |*icon| from a dictionary {"19": imageData19, "38":
102 // imageData38}, returning false if a value is corrupt. 102 // imageData38}, returning false if a value is corrupt.
103 static bool ParseIconFromCanvasDictionary(const base::DictionaryValue& dict, 103 static bool ParseIconFromCanvasDictionary(const base::DictionaryValue& dict,
104 gfx::ImageSkia* icon); 104 gfx::ImageSkia* icon);
105 105
106 // Gets the icon that has been set using |SetIcon| for the tab. 106 // Gets the icon that has been set using |SetIcon| for the tab.
107 gfx::ImageSkia GetExplicitlySetIcon(int tab_id) const; 107 gfx::Image GetExplicitlySetIcon(int tab_id) const;
108 108
109 // Sets the icon for a tab, in a way that can't be read by the extension's 109 // Sets the icon for a tab, in a way that can't be read by the extension's
110 // javascript. Multiple icons can be set at the same time; some icon with the 110 // javascript. Multiple icons can be set at the same time; some icon with the
111 // highest priority will be used. 111 // highest priority will be used.
112 void DeclarativeSetIcon(int tab_id, int priority, const gfx::Image& icon); 112 void DeclarativeSetIcon(int tab_id, int priority, const gfx::Image& icon);
113 void UndoDeclarativeSetIcon(int tab_id, int priority, const gfx::Image& icon); 113 void UndoDeclarativeSetIcon(int tab_id, int priority, const gfx::Image& icon);
114 114
115 const ExtensionIconSet* default_icon() const { 115 const ExtensionIconSet* default_icon() const {
116 return default_icon_.get(); 116 return default_icon_.get();
117 } 117 }
(...skipping 27 matching lines...) Expand all
145 return GetValue(&badge_background_color_, tab_id); 145 return GetValue(&badge_background_color_, tab_id);
146 } 146 }
147 147
148 // Set this action's badge visibility on a specific tab. Returns true if 148 // Set this action's badge visibility on a specific tab. Returns true if
149 // the visibility has changed. 149 // the visibility has changed.
150 bool SetIsVisible(int tab_id, bool value); 150 bool SetIsVisible(int tab_id, bool value);
151 // The declarative appearance overrides a default appearance but is overridden 151 // The declarative appearance overrides a default appearance but is overridden
152 // by an appearance set directly on the tab. 152 // by an appearance set directly on the tab.
153 void DeclarativeShow(int tab_id); 153 void DeclarativeShow(int tab_id);
154 void UndoDeclarativeShow(int tab_id); 154 void UndoDeclarativeShow(int tab_id);
155 const gfx::ImageSkia GetDeclarativeIcon(int tab_id) const; 155 const gfx::Image GetDeclarativeIcon(int tab_id) const;
156 156
157 // Get the badge visibility for a tab, or the default badge visibility 157 // Get the badge visibility for a tab, or the default badge visibility
158 // if none was set. 158 // if none was set.
159 // Gets the visibility of |tab_id|. Returns the first of: a specific 159 // Gets the visibility of |tab_id|. Returns the first of: a specific
160 // visibility set on the tab; a declarative visibility set on the tab; the 160 // visibility set on the tab; a declarative visibility set on the tab; the
161 // default visibility set for all tabs; or |false|. Don't return this 161 // default visibility set for all tabs; or |false|. Don't return this
162 // result to an extension's background page because the declarative state can 162 // result to an extension's background page because the declarative state can
163 // leak information about hosts the extension doesn't have permission to 163 // leak information about hosts the extension doesn't have permission to
164 // access. 164 // access.
165 bool GetIsVisible(int tab_id) const { 165 bool GetIsVisible(int tab_id) const {
(...skipping 22 matching lines...) Expand all
188 const gfx::Size& spacing) const; 188 const gfx::Size& spacing) const;
189 189
190 // Lazily loads and returns the default icon image, if one exists for the 190 // Lazily loads and returns the default icon image, if one exists for the
191 // action. 191 // action.
192 extensions::IconImage* LoadDefaultIconImage( 192 extensions::IconImage* LoadDefaultIconImage(
193 const extensions::Extension& extension, 193 const extensions::Extension& extension,
194 content::BrowserContext* browser_context); 194 content::BrowserContext* browser_context);
195 195
196 // Returns the image to use as the default icon for the action. Can only be 196 // Returns the image to use as the default icon for the action. Can only be
197 // called after LoadDefaultIconImage(). 197 // called after LoadDefaultIconImage().
198 gfx::ImageSkia GetDefaultIconImage() const; 198 gfx::Image GetDefaultIconImage() const;
199 199
200 // Determine whether or not the ExtensionAction has a value set for the given 200 // Determine whether or not the ExtensionAction has a value set for the given
201 // |tab_id| for each property. 201 // |tab_id| for each property.
202 bool HasPopupUrl(int tab_id) const; 202 bool HasPopupUrl(int tab_id) const;
203 bool HasTitle(int tab_id) const; 203 bool HasTitle(int tab_id) const;
204 bool HasBadgeText(int tab_id) const; 204 bool HasBadgeText(int tab_id) const;
205 bool HasBadgeBackgroundColor(int tab_id) const; 205 bool HasBadgeBackgroundColor(int tab_id) const;
206 bool HasBadgeTextColor(int tab_id) const; 206 bool HasBadgeTextColor(int tab_id) const;
207 bool HasIsVisible(int tab_id) const; 207 bool HasIsVisible(int tab_id) const;
208 bool HasIcon(int tab_id) const; 208 bool HasIcon(int tab_id) const;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 // The id for the extension this action belongs to (as defined in the 256 // The id for the extension this action belongs to (as defined in the
257 // extension manifest). 257 // extension manifest).
258 const std::string extension_id_; 258 const std::string extension_id_;
259 259
260 const extensions::ActionInfo::Type action_type_; 260 const extensions::ActionInfo::Type action_type_;
261 261
262 // Each of these data items can have both a global state (stored with the key 262 // Each of these data items can have both a global state (stored with the key
263 // kDefaultTabId), or tab-specific state (stored with the tab_id as the key). 263 // kDefaultTabId), or tab-specific state (stored with the tab_id as the key).
264 std::map<int, GURL> popup_url_; 264 std::map<int, GURL> popup_url_;
265 std::map<int, std::string> title_; 265 std::map<int, std::string> title_;
266 std::map<int, gfx::ImageSkia> icon_; 266 std::map<int, gfx::Image> icon_;
267 std::map<int, std::string> badge_text_; 267 std::map<int, std::string> badge_text_;
268 std::map<int, SkColor> badge_background_color_; 268 std::map<int, SkColor> badge_background_color_;
269 std::map<int, SkColor> badge_text_color_; 269 std::map<int, SkColor> badge_text_color_;
270 std::map<int, bool> is_visible_; 270 std::map<int, bool> is_visible_;
271 271
272 // Declarative state exists for two reasons: First, we need to hide it from 272 // Declarative state exists for two reasons: First, we need to hide it from
273 // the extension's background/event page to avoid leaking data from hosts the 273 // the extension's background/event page to avoid leaking data from hosts the
274 // extension doesn't have permission to access. Second, the action's state 274 // extension doesn't have permission to access. Second, the action's state
275 // gets both reset and given its declarative values in response to a 275 // gets both reset and given its declarative values in response to a
276 // WebContentsObserver::DidNavigateMainFrame event, and there's no way to set 276 // WebContentsObserver::DidNavigateMainFrame event, and there's no way to set
(...skipping 23 matching lines...) Expand all
300 }; 300 };
301 301
302 template<> 302 template<>
303 struct ExtensionAction::ValueTraits<int> { 303 struct ExtensionAction::ValueTraits<int> {
304 static int CreateEmpty() { 304 static int CreateEmpty() {
305 return -1; 305 return -1;
306 } 306 }
307 }; 307 };
308 308
309 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_H_ 309 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/declarative_content/set_icon_apitest.cc ('k') | chrome/browser/extensions/extension_action.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698