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

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

Issue 10834279: Give request-to-act badges a grey background, and increase spacing to make it fit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add Views UI; clean up GTK Created 8 years, 4 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 | Annotate | Revision Log
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_COMMON_EXTENSIONS_EXTENSION_ACTION_H_ 5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_ACTION_H_
6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_ACTION_H_ 6 #define CHROME_COMMON_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 21 matching lines...) Expand all
32 // ExtensionAction encapsulates the state of a browser action, page action, or 32 // ExtensionAction encapsulates the state of a browser action, page action, or
33 // script badge. 33 // script badge.
34 // Instances can have both global and per-tab state. If a property does not have 34 // Instances can have both global and per-tab state. If a property does not have
35 // a per-tab value, the global value is used instead. 35 // a per-tab value, the global value is used instead.
36 class ExtensionAction { 36 class ExtensionAction {
37 public: 37 public:
38 // Use this ID to indicate the default state for properties that take a tab_id 38 // Use this ID to indicate the default state for properties that take a tab_id
39 // parameter. 39 // parameter.
40 static const int kDefaultTabId; 40 static const int kDefaultTabId;
41 41
42 static const SkColor kGetAttentionBorderColor;
Peter Kasting 2012/08/24 23:08:28 Nit: Why are these public class members instead of
Jeffrey Yasskin 2012/08/29 00:37:50 At one point I was using them from the platform-sp
43 static const SkColor kGetAttentionBackgroundTopColor;
44 static const SkColor kGetAttentionBackgroundBottomColor;
45
42 // The types of extension actions. 46 // The types of extension actions.
43 enum Type { 47 enum Type {
44 TYPE_BROWSER, 48 TYPE_BROWSER,
45 TYPE_PAGE, 49 TYPE_PAGE,
46 TYPE_SCRIPT_BADGE, 50 TYPE_SCRIPT_BADGE,
47 }; 51 };
48 52
49 enum Appearance { 53 enum Appearance {
50 // The action icon is hidden. 54 // The action icon is hidden.
51 INVISIBLE, 55 INVISIBLE,
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 // Set this action's badge visibility on a specific tab. This takes 233 // Set this action's badge visibility on a specific tab. This takes
230 // care of any appropriate transition animations. Returns true if 234 // care of any appropriate transition animations. Returns true if
231 // the appearance has changed. 235 // the appearance has changed.
232 bool SetAppearance(int tab_id, Appearance value); 236 bool SetAppearance(int tab_id, Appearance value);
233 // Get the badge visibility for a tab, or the default badge visibility 237 // Get the badge visibility for a tab, or the default badge visibility
234 // if none was set. 238 // if none was set.
235 bool GetIsVisible(int tab_id) const { 239 bool GetIsVisible(int tab_id) const {
236 return GetValue(&appearance_, tab_id) != INVISIBLE; 240 return GetValue(&appearance_, tab_id) != INVISIBLE;
237 } 241 }
238 242
243 // True if the tab's action wants the user's attention.
244 bool WantsAttention(int tab_id) const {
245 return GetValue(&appearance_, tab_id) == WANTS_ATTENTION;
246 }
247
239 // Remove all tab-specific state. 248 // Remove all tab-specific state.
240 void ClearAllValuesForTab(int tab_id); 249 void ClearAllValuesForTab(int tab_id);
241 250
251 // Paint the background and border for |tab_id|. |bounds| should include the
252 // top and bottom of the location bar, and the middle column exactly between
253 // two ExtensionActions, so both ExtensionActions can draw on it.
Peter Kasting 2012/08/24 23:08:28 Nit: You might want to note in this comment what s
Jeffrey Yasskin 2012/08/29 00:37:50 Done.
254 void PaintBackground(gfx::Canvas* canvas, const gfx::Rect& bounds,
Peter Kasting 2012/08/24 23:08:28 Nit: One line per arg
Jeffrey Yasskin 2012/08/29 00:37:50 Oops, done.
255 int tab_id);
256
242 // If the specified tab has a badge, paint it into the provided bounds. 257 // If the specified tab has a badge, paint it into the provided bounds.
243 void PaintBadge(gfx::Canvas* canvas, const gfx::Rect& bounds, int tab_id); 258 void PaintBadge(gfx::Canvas* canvas, const gfx::Rect& bounds, int tab_id);
244 259
245 // Returns icon image with badge for specified tab. 260 // Returns icon image with badge for specified tab.
246 gfx::ImageSkia GetIconWithBadge(const gfx::ImageSkia& icon, 261 gfx::ImageSkia GetIconWithBadge(const gfx::ImageSkia& icon,
247 int tab_id, 262 int tab_id,
248 const gfx::Size& spacing) const; 263 const gfx::Size& spacing) const;
249 264
250 // Gets a weak reference to the icon animation for a tab, if any. The 265 // Gets a weak reference to the icon animation for a tab, if any. The
251 // reference will only have a value while the animation is running. 266 // reference will only have a value while the animation is running.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 }; 360 };
346 361
347 template<> 362 template<>
348 struct ExtensionAction::ValueTraits<int> { 363 struct ExtensionAction::ValueTraits<int> {
349 static int CreateEmpty() { 364 static int CreateEmpty() {
350 return -1; 365 return -1;
351 } 366 }
352 }; 367 };
353 368
354 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_ACTION_H_ 369 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_ACTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698