| OLD | NEW |
| 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 PageAction { | 14 class ContextualAction { |
| 15 public: | 15 public: |
| 16 PageAction(); | 16 ContextualAction(); |
| 17 virtual ~PageAction(); | 17 virtual ~ContextualAction(); |
| 18 | 18 |
| 19 typedef enum { | 19 typedef enum { |
| 20 PERMANENT = 0, | 20 PAGE_ACTION = 0, |
| 21 TAB = 1, | 21 BROWSER_ACTION = 1, |
| 22 } PageActionType; | 22 } ContextualActionType; |
| 23 | 23 |
| 24 std::string id() const { return id_; } | 24 std::string id() const { return id_; } |
| 25 void set_id(const std::string& id) { id_ = id; } | 25 void set_id(const std::string& id) { id_ = id; } |
| 26 | 26 |
| 27 PageActionType type() const { return type_; } | 27 ContextualActionType type() const { return type_; } |
| 28 void set_type(PageActionType type) { type_ = type; } | 28 void set_type(ContextualActionType type) { type_ = type; } |
| 29 | 29 |
| 30 std::string extension_id() const { return extension_id_; } | 30 std::string extension_id() const { return extension_id_; } |
| 31 void set_extension_id(const std::string& extension_id) { | 31 void set_extension_id(const std::string& extension_id) { |
| 32 extension_id_ = extension_id; | 32 extension_id_ = extension_id; |
| 33 } | 33 } |
| 34 | 34 |
| 35 std::string name() const { return name_; } | 35 std::string name() const { return name_; } |
| 36 void set_name(const std::string& name) { name_ = name; } | 36 void set_name(const std::string& name) { name_ = name; } |
| 37 | 37 |
| 38 const std::vector<std::string>& icon_paths() const { return icon_paths_; } | 38 const std::vector<std::string>& icon_paths() const { return icon_paths_; } |
| 39 void AddIconPath(const std::string& icon_path) { | 39 void AddIconPath(const std::string& icon_path) { |
| 40 icon_paths_.push_back(icon_path); | 40 icon_paths_.push_back(icon_path); |
| 41 } | 41 } |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 // The id for the PageAction, for example: "RssPageAction". | 44 // The id for the ContextualAction, for example: "RssPageAction". |
| 45 // For BrowserActions this is blank. |
| 45 std::string id_; | 46 std::string id_; |
| 46 | 47 |
| 47 // The type of the PageAction. | 48 // The type of the ContextualAction, either PageAction or BrowserAction. |
| 48 PageActionType type_; | 49 ContextualActionType type_; |
| 49 | 50 |
| 50 // The id for the extension this PageAction belongs to (as defined in the | 51 // The id for the extension this ContextualAction belongs to (as defined in |
| 51 // extension manifest). | 52 // the extension manifest). |
| 52 std::string extension_id_; | 53 std::string extension_id_; |
| 53 | 54 |
| 54 // The name of the PageAction. | 55 // The name of the ContextualAction. |
| 55 std::string name_; | 56 std::string name_; |
| 56 | 57 |
| 57 // The paths to the icons that this PageIcon can show. | 58 // The paths to the icons that this PageIcon can show. |
| 58 std::vector<std::string> icon_paths_; | 59 std::vector<std::string> icon_paths_; |
| 59 }; | 60 }; |
| 60 | 61 |
| 61 typedef std::map<std::string, PageAction*> PageActionMap; | 62 typedef std::map<std::string, ContextualAction*> ContextualActionMap; |
| 62 | 63 |
| 63 // This class keeps track of what values each tab uses to override the default | 64 // This class keeps track of what values each tab uses to override the default |
| 64 // values of the PageAction. | 65 // values of the ContextualAction. |
| 65 class PageActionState { | 66 class ContextualActionState { |
| 66 public: | 67 public: |
| 67 PageActionState(std::string title, int icon_index) | 68 ContextualActionState(std::string title, int icon_index) |
| 68 : title_(title), icon_index_(icon_index) { | 69 : title_(title), icon_index_(icon_index) { |
| 69 } | 70 } |
| 70 | 71 |
| 71 std::string title() const { return title_; } | 72 std::string title() const { return title_; } |
| 72 int icon_index() const { return icon_index_; } | 73 int icon_index() const { return icon_index_; } |
| 73 | 74 |
| 74 private: | 75 private: |
| 75 // The title to use. | 76 // The title to use. |
| 76 std::string title_; | 77 std::string title_; |
| 77 | 78 |
| 78 // The icon to use. | 79 // The icon to use. |
| 79 int icon_index_; | 80 int icon_index_; |
| 80 | 81 |
| 81 DISALLOW_COPY_AND_ASSIGN(PageActionState); | 82 DISALLOW_COPY_AND_ASSIGN(ContextualActionState); |
| 82 }; | 83 }; |
| 83 | 84 |
| 84 #endif // CHROME_COMMON_PAGE_ACTION_H_ | 85 #endif // CHROME_COMMON_PAGE_ACTION_H_ |
| OLD | NEW |