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

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

Issue 149046: PageActions can now specify multiple icons and switch between them... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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
« no previous file with comments | « chrome/common/extensions/extension.cc ('k') | chrome/renderer/renderer_resources.grd » ('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 <string> 9 #include <string>
9 #include <map> 10 #include <vector>
10 11
11 #include "base/file_path.h" 12 #include "base/file_path.h"
12 13
13 class PageAction { 14 class PageAction {
14 public: 15 public:
15 PageAction(); 16 PageAction();
16 virtual ~PageAction(); 17 virtual ~PageAction();
17 18
18 typedef enum { 19 typedef enum {
19 PERMANENT = 0, 20 PERMANENT = 0,
20 TAB = 1, 21 TAB = 1,
21 } PageActionType; 22 } PageActionType;
22 23
23 std::string id() const { return id_; } 24 std::string id() const { return id_; }
24 void set_id(std::string id) { id_ = id; } 25 void set_id(std::string id) { id_ = id; }
25 26
26 PageActionType type() const { return type_; } 27 PageActionType type() const { return type_; }
27 void set_type(PageActionType type) { type_ = type; } 28 void set_type(PageActionType type) { type_ = type; }
28 29
29 std::string extension_id() const { return extension_id_; } 30 std::string extension_id() const { return extension_id_; }
30 void set_extension_id(std::string extension_id) { 31 void set_extension_id(std::string extension_id) {
31 extension_id_ = extension_id; 32 extension_id_ = extension_id;
32 } 33 }
33 34
34 std::string name() const { return name_; } 35 std::string name() const { return name_; }
35 void set_name(const std::string& name) { name_ = name; } 36 void set_name(const std::string& name) { name_ = name; }
36 37
37 FilePath icon_path() const { return icon_path_; } 38 const std::vector<FilePath>& icon_paths() const { return icon_paths_; }
38 void set_icon_path(const FilePath& icon_path) { 39 void AddIconPath(const FilePath& icon_path) {
39 icon_path_ = icon_path; 40 icon_paths_.push_back(icon_path);
40 } 41 }
41 42
42 private: 43 private:
43 // The id for the PageAction, for example: "RssPageAction". 44 // The id for the PageAction, for example: "RssPageAction".
44 std::string id_; 45 std::string id_;
45 46
46 // The type of the PageAction. 47 // The type of the PageAction.
47 PageActionType type_; 48 PageActionType type_;
48 49
49 // The id for the extension this PageAction belongs to (as defined in the 50 // The id for the extension this PageAction belongs to (as defined in the
50 // extension manifest). 51 // extension manifest).
51 std::string extension_id_; 52 std::string extension_id_;
52 53
53 // The name of the PageAction. 54 // The name of the PageAction.
54 std::string name_; 55 std::string name_;
55 56
56 // The icon that represents the PageIcon. 57 // The paths to the icons that this PageIcon can show.
57 FilePath icon_path_; 58 std::vector<FilePath> icon_paths_;
58 }; 59 };
59 60
60 typedef std::map<std::string, PageAction*> PageActionMap; 61 typedef std::map<std::string, PageAction*> PageActionMap;
61 62
63 // This class keeps track of what values each tab uses to override the default
64 // values of the PageAction.
65 class PageActionState {
66 public:
67 PageActionState(std::string title, int icon_index)
68 : title_(title), icon_index_(icon_index) {
69 }
70
71 std::string title() const { return title_; }
72 int icon_index() const { return icon_index_; }
73
74 private:
75 // The title to use.
76 std::string title_;
77
78 // The icon to use.
79 int icon_index_;
80
81 DISALLOW_COPY_AND_ASSIGN(PageActionState);
82 };
83
62 #endif // CHROME_COMMON_PAGE_ACTION_H_ 84 #endif // CHROME_COMMON_PAGE_ACTION_H_
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension.cc ('k') | chrome/renderer/renderer_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698