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

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

Issue 256032: Add an API to manipulate the browser action badge. (Closed)
Patch Set: meet halfway Created 11 years, 2 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/scoped_ptr.h"
14 #include "third_party/skia/include/core/SkColor.h"
13 15
14 class ExtensionAction { 16 class ExtensionAction {
15 public: 17 public:
16 ExtensionAction(); 18 ExtensionAction();
17 virtual ~ExtensionAction(); 19 virtual ~ExtensionAction();
18 20
19 typedef enum { 21 typedef enum {
20 PAGE_ACTION = 0, 22 PAGE_ACTION = 0,
21 BROWSER_ACTION = 1, 23 BROWSER_ACTION = 1,
22 } ExtensionActionType; 24 } ExtensionActionType;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 int command_id_; 69 int command_id_;
68 }; 70 };
69 71
70 typedef std::map<std::string, ExtensionAction*> ExtensionActionMap; 72 typedef std::map<std::string, ExtensionAction*> ExtensionActionMap;
71 73
72 // This class keeps track of what values each tab uses to override the default 74 // This class keeps track of what values each tab uses to override the default
73 // values of the ExtensionAction. 75 // values of the ExtensionAction.
74 class ExtensionActionState { 76 class ExtensionActionState {
75 public: 77 public:
76 ExtensionActionState(std::string title, int icon_index) 78 ExtensionActionState(std::string title, int icon_index)
77 : title_(title), icon_index_(icon_index) { 79 : title_(title), icon_index_(icon_index),
80 badge_background_color_(new SkColor(SkColorSetARGB(255, 218, 0, 24))) {
78 } 81 }
79 82
80 std::string title() const { return title_; } 83 const std::string& title() const { return title_; }
81 void set_title(const std::string& title) { title_ = title; } 84 void set_title(const std::string& title) { title_ = title; }
82 85
86 const std::string& badge_text() const { return badge_text_; }
87 void set_badge_text(const std::string& badge_text) {
88 badge_text_ = badge_text;
89 }
90
91 SkColor* badge_background_color() const {
92 return badge_background_color_.get();
93 }
94 void set_badge_background_color(const SkColor& badge_background_color) {
95 badge_background_color_.reset(new SkColor(badge_background_color));
96 }
97
83 int icon_index() const { return icon_index_; } 98 int icon_index() const { return icon_index_; }
84 void set_icon_index(int icon_index) { icon_index_ = icon_index; } 99 void set_icon_index(int icon_index) { icon_index_ = icon_index; }
85 100
86 private: 101 private:
87 // The title to use. 102 // The title to use.
88 std::string title_; 103 std::string title_;
89 104
90 // The icon to use. 105 // The icon to use.
91 int icon_index_; 106 int icon_index_;
92 107
108 // The badge text.
109 std::string badge_text_;
110
111 // The background color for the badge.
112 scoped_ptr<SkColor> badge_background_color_;
113
93 DISALLOW_COPY_AND_ASSIGN(ExtensionActionState); 114 DISALLOW_COPY_AND_ASSIGN(ExtensionActionState);
94 }; 115 };
95 116
96 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_ACTION_H_ 117 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_ACTION_H_
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/extension_api.json ('k') | chrome/test/data/extensions/samples/make_page_red/background.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698