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

Side by Side Diff: chrome/common/page_action.h

Issue 246037: Integrate browser actions with the wrench menu. Browser actions (Closed)
Patch Set: alphabetize 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
« no previous file with comments | « chrome/common/extensions/extension.cc ('k') | chrome/common/page_action.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_PAGE_ACTION_H_ 5 #ifndef CHROME_COMMON_PAGE_ACTION_H_
6 #define CHROME_COMMON_PAGE_ACTION_H_ 6 #define CHROME_COMMON_PAGE_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 13
14 class ContextualAction { 14 class ContextualAction {
15 public: 15 public:
16 ContextualAction(); 16 ContextualAction();
17 virtual ~ContextualAction(); 17 virtual ~ContextualAction();
18 18
19 typedef enum { 19 typedef enum {
20 PAGE_ACTION = 0, 20 PAGE_ACTION = 0,
21 BROWSER_ACTION = 1, 21 BROWSER_ACTION = 1,
22 } ContextualActionType; 22 } ContextualActionType;
23 23
24 int command_id() const { return command_id_; }
25
24 std::string id() const { return id_; } 26 std::string id() const { return id_; }
25 void set_id(const std::string& id) { id_ = id; } 27 void set_id(const std::string& id) { id_ = id; }
26 28
27 ContextualActionType type() const { return type_; } 29 ContextualActionType type() const { return type_; }
28 void set_type(ContextualActionType type) { type_ = type; } 30 void set_type(ContextualActionType type) { type_ = type; }
29 31
30 std::string extension_id() const { return extension_id_; } 32 std::string extension_id() const { return extension_id_; }
31 void set_extension_id(const std::string& extension_id) { 33 void set_extension_id(const std::string& extension_id) {
32 extension_id_ = extension_id; 34 extension_id_ = extension_id;
33 } 35 }
34 36
35 std::string name() const { return name_; } 37 std::string name() const { return name_; }
36 void set_name(const std::string& name) { name_ = name; } 38 void set_name(const std::string& name) { name_ = name; }
37 39
38 const std::vector<std::string>& icon_paths() const { return icon_paths_; } 40 const std::vector<std::string>& icon_paths() const { return icon_paths_; }
39 void AddIconPath(const std::string& icon_path) { 41 void AddIconPath(const std::string& icon_path) {
40 icon_paths_.push_back(icon_path); 42 icon_paths_.push_back(icon_path);
41 } 43 }
42 44
43 private: 45 private:
46 static int next_command_id_;
47
44 // The id for the ContextualAction, for example: "RssPageAction". 48 // The id for the ContextualAction, for example: "RssPageAction".
45 // For BrowserActions this is blank. 49 // For BrowserActions this is blank.
46 std::string id_; 50 std::string id_;
47 51
48 // The type of the ContextualAction, either PageAction or BrowserAction. 52 // The type of the ContextualAction, either PageAction or BrowserAction.
49 ContextualActionType type_; 53 ContextualActionType type_;
50 54
51 // The id for the extension this ContextualAction belongs to (as defined in 55 // The id for the extension this ContextualAction belongs to (as defined in
52 // the extension manifest). 56 // the extension manifest).
53 std::string extension_id_; 57 std::string extension_id_;
54 58
55 // The name of the ContextualAction. 59 // The name of the ContextualAction.
56 std::string name_; 60 std::string name_;
57 61
58 // The paths to the icons that this PageIcon can show. 62 // The paths to the icons that this PageIcon can show.
59 std::vector<std::string> icon_paths_; 63 std::vector<std::string> icon_paths_;
64
65 // An integer for use with the browser's command system. These should always
66 // be in the range [IDC_BROWSER_ACTION_FIRST, IDC_BROWSER_ACTION_LAST].
67 int command_id_;
60 }; 68 };
61 69
62 typedef std::map<std::string, ContextualAction*> ContextualActionMap; 70 typedef std::map<std::string, ContextualAction*> ContextualActionMap;
63 71
64 // This class keeps track of what values each tab uses to override the default 72 // This class keeps track of what values each tab uses to override the default
65 // values of the ContextualAction. 73 // values of the ContextualAction.
66 class ContextualActionState { 74 class ContextualActionState {
67 public: 75 public:
68 ContextualActionState(std::string title, int icon_index) 76 ContextualActionState(std::string title, int icon_index)
69 : title_(title), icon_index_(icon_index) { 77 : title_(title), icon_index_(icon_index) {
70 } 78 }
71 79
72 std::string title() const { return title_; } 80 std::string title() const { return title_; }
73 int icon_index() const { return icon_index_; } 81 int icon_index() const { return icon_index_; }
74 82
75 private: 83 private:
76 // The title to use. 84 // The title to use.
77 std::string title_; 85 std::string title_;
78 86
79 // The icon to use. 87 // The icon to use.
80 int icon_index_; 88 int icon_index_;
81 89
82 DISALLOW_COPY_AND_ASSIGN(ContextualActionState); 90 DISALLOW_COPY_AND_ASSIGN(ContextualActionState);
83 }; 91 };
84 92
85 #endif // CHROME_COMMON_PAGE_ACTION_H_ 93 #endif // CHROME_COMMON_PAGE_ACTION_H_
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension.cc ('k') | chrome/common/page_action.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698