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

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

Issue 186013003: Persist browseraction properties across restarts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Jeffrey's Created 6 years, 9 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 // What kind of action is this? 62 // What kind of action is this?
63 extensions::ActionInfo::Type action_type() const { 63 extensions::ActionInfo::Type action_type() const {
64 return action_type_; 64 return action_type_;
65 } 65 }
66 66
67 // action id -- only used with legacy page actions API 67 // action id -- only used with legacy page actions API
68 std::string id() const { return id_; } 68 std::string id() const { return id_; }
69 void set_id(const std::string& id) { id_ = id; } 69 void set_id(const std::string& id) { id_ = id; }
70 70
71 bool has_changed() const { return has_changed_; }
72 void set_has_changed(bool value) { has_changed_ = value; }
73
74 // Set the url which the popup will load when the user clicks this action's 71 // Set the url which the popup will load when the user clicks this action's
75 // icon. Setting an empty URL will disable the popup for a given tab. 72 // icon. Setting an empty URL will disable the popup for a given tab.
76 void SetPopupUrl(int tab_id, const GURL& url); 73 void SetPopupUrl(int tab_id, const GURL& url);
77 74
78 // Use HasPopup() to see if a popup should be displayed. 75 // Use HasPopup() to see if a popup should be displayed.
79 bool HasPopup(int tab_id) const; 76 bool HasPopup(int tab_id) const;
80 77
81 // Get the URL to display in a popup. 78 // Get the URL to display in a popup.
82 GURL GetPopupUrl(int tab_id) const; 79 GURL GetPopupUrl(int tab_id) const;
83 80
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 void ClearAllValuesForTab(int tab_id); 172 void ClearAllValuesForTab(int tab_id);
176 173
177 // If the specified tab has a badge, paint it into the provided bounds. 174 // If the specified tab has a badge, paint it into the provided bounds.
178 void PaintBadge(gfx::Canvas* canvas, const gfx::Rect& bounds, int tab_id); 175 void PaintBadge(gfx::Canvas* canvas, const gfx::Rect& bounds, int tab_id);
179 176
180 // Returns icon image with badge for specified tab. 177 // Returns icon image with badge for specified tab.
181 gfx::ImageSkia GetIconWithBadge(const gfx::ImageSkia& icon, 178 gfx::ImageSkia GetIconWithBadge(const gfx::ImageSkia& icon,
182 int tab_id, 179 int tab_id,
183 const gfx::Size& spacing) const; 180 const gfx::Size& spacing) const;
184 181
182 // Determine whether or not the ExtensionAction has default values for each
183 // property.
184 bool HasPopupUrl() const;
Jeffrey Yasskin 2014/03/05 20:23:33 These need to take a tab_id, like the Get* functio
Devlin 2014/03/05 23:04:31 Whoops, misunderstood earlier. Done.
185 bool HasTitle() const;
186 bool HasBadgeText() const;
187 bool HasBadgeBackgroundColor() const;
188 bool HasBadgeTextColor() const;
189 bool HasIsVisible() const;
190 bool HasIcon() const;
191
185 private: 192 private:
186 // Returns width of the current icon for tab_id. 193 // Returns width of the current icon for tab_id.
187 // TODO(tbarzic): The icon selection is done in ExtensionActionIconFactory. 194 // TODO(tbarzic): The icon selection is done in ExtensionActionIconFactory.
188 // We should probably move this there too. 195 // We should probably move this there too.
189 int GetIconWidth(int tab_id) const; 196 int GetIconWidth(int tab_id) const;
190 197
191 template <class T> 198 template <class T>
192 struct ValueTraits { 199 struct ValueTraits {
193 static T CreateEmpty() { 200 static T CreateEmpty() {
194 return T(); 201 return T();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 std::map<int, int> declarative_show_count_; 256 std::map<int, int> declarative_show_count_;
250 257
251 // ExtensionIconSet containing paths to bitmaps from which default icon's 258 // ExtensionIconSet containing paths to bitmaps from which default icon's
252 // image representations will be selected. 259 // image representations will be selected.
253 scoped_ptr<const ExtensionIconSet> default_icon_; 260 scoped_ptr<const ExtensionIconSet> default_icon_;
254 261
255 // The id for the ExtensionAction, for example: "RssPageAction". This is 262 // The id for the ExtensionAction, for example: "RssPageAction". This is
256 // needed for compat with an older version of the page actions API. 263 // needed for compat with an older version of the page actions API.
257 std::string id_; 264 std::string id_;
258 265
259 // True if the ExtensionAction's settings have changed from what was
260 // specified in the manifest.
261 bool has_changed_;
262
263 DISALLOW_COPY_AND_ASSIGN(ExtensionAction); 266 DISALLOW_COPY_AND_ASSIGN(ExtensionAction);
264 }; 267 };
265 268
266 template<> 269 template<>
267 struct ExtensionAction::ValueTraits<int> { 270 struct ExtensionAction::ValueTraits<int> {
268 static int CreateEmpty() { 271 static int CreateEmpty() {
269 return -1; 272 return -1;
270 } 273 }
271 }; 274 };
272 275
273 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_H_ 276 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698