| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 a value set for the given |
| 183 // |tab_id| for each property. |
| 184 bool HasPopupUrl(int tab_id) const; |
| 185 bool HasTitle(int tab_id) const; |
| 186 bool HasBadgeText(int tab_id) const; |
| 187 bool HasBadgeBackgroundColor(int tab_id) const; |
| 188 bool HasBadgeTextColor(int tab_id) const; |
| 189 bool HasIsVisible(int tab_id) const; |
| 190 bool HasIcon(int tab_id) 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 Loading... |
| 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_ |
| OLD | NEW |