| 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_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" | 13 #include "base/scoped_ptr.h" |
| 14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 15 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
| 16 #include "third_party/skia/include/core/SkColor.h" | 16 #include "third_party/skia/include/core/SkColor.h" |
| 17 | 17 |
| 18 class ExtensionAction { | 18 class ExtensionAction { |
| 19 public: | 19 public: |
| 20 ExtensionAction(); | 20 ExtensionAction(); |
| 21 virtual ~ExtensionAction(); | 21 virtual ~ExtensionAction(); |
| 22 | 22 |
| 23 typedef enum { | 23 typedef enum { |
| 24 PAGE_ACTION = 0, | 24 PAGE_ACTION = 0, |
| 25 BROWSER_ACTION = 1, | 25 BROWSER_ACTION = 1, |
| 26 } ExtensionActionType; | 26 } ExtensionActionType; |
| 27 | 27 |
| 28 int command_id() const { return command_id_; } | |
| 29 | |
| 30 std::string id() const { return id_; } | 28 std::string id() const { return id_; } |
| 31 void set_id(const std::string& id) { id_ = id; } | 29 void set_id(const std::string& id) { id_ = id; } |
| 32 | 30 |
| 33 ExtensionActionType type() const { return type_; } | 31 ExtensionActionType type() const { return type_; } |
| 34 void set_type(ExtensionActionType type) { type_ = type; } | 32 void set_type(ExtensionActionType type) { type_ = type; } |
| 35 | 33 |
| 36 std::string extension_id() const { return extension_id_; } | 34 std::string extension_id() const { return extension_id_; } |
| 37 void set_extension_id(const std::string& extension_id) { | 35 void set_extension_id(const std::string& extension_id) { |
| 38 extension_id_ = extension_id; | 36 extension_id_ = extension_id; |
| 39 } | 37 } |
| 40 | 38 |
| 41 std::string title() const { return title_; } | 39 std::string title() const { return title_; } |
| 42 void set_title(const std::string& title) { title_ = title; } | 40 void set_title(const std::string& title) { title_ = title; } |
| 43 | 41 |
| 44 const std::vector<std::string>& icon_paths() const { return icon_paths_; } | 42 const std::vector<std::string>& icon_paths() const { return icon_paths_; } |
| 45 void AddIconPath(const std::string& icon_path) { | 43 void AddIconPath(const std::string& icon_path) { |
| 46 icon_paths_.push_back(icon_path); | 44 icon_paths_.push_back(icon_path); |
| 47 } | 45 } |
| 48 | 46 |
| 49 const GURL& popup_url() const { return popup_url_; } | 47 const GURL& popup_url() const { return popup_url_; } |
| 50 void set_popup_url(const GURL& url) { popup_url_ = url; } | 48 void set_popup_url(const GURL& url) { popup_url_ = url; } |
| 51 | 49 |
| 52 const int popup_height() const { return popup_height_; } | 50 const int popup_height() const { return popup_height_; } |
| 53 void set_popup_height(int height) { popup_height_ = height; } | 51 void set_popup_height(int height) { popup_height_ = height; } |
| 54 | 52 |
| 55 bool is_popup() const { return !popup_url_.is_empty(); } | 53 bool is_popup() const { return !popup_url_.is_empty(); } |
| 56 | 54 |
| 57 private: | 55 private: |
| 58 static int next_command_id_; | |
| 59 | |
| 60 // The id for the ExtensionAction, for example: "RssPageAction". | 56 // The id for the ExtensionAction, for example: "RssPageAction". |
| 61 // For BrowserActions this is blank. | 57 // For BrowserActions this is blank. |
| 62 std::string id_; | 58 std::string id_; |
| 63 | 59 |
| 64 // The type of the ExtensionAction, either PageAction or BrowserAction. | 60 // The type of the ExtensionAction, either PageAction or BrowserAction. |
| 65 ExtensionActionType type_; | 61 ExtensionActionType type_; |
| 66 | 62 |
| 67 // The id for the extension this ExtensionAction belongs to (as defined in | 63 // The id for the extension this ExtensionAction belongs to (as defined in |
| 68 // the extension manifest). | 64 // the extension manifest). |
| 69 std::string extension_id_; | 65 std::string extension_id_; |
| 70 | 66 |
| 71 // The title text of the ExtensionAction. | 67 // The title text of the ExtensionAction. |
| 72 std::string title_; | 68 std::string title_; |
| 73 | 69 |
| 74 // The paths to the icons that this PageIcon can show. | 70 // The paths to the icons that this PageIcon can show. |
| 75 std::vector<std::string> icon_paths_; | 71 std::vector<std::string> icon_paths_; |
| 76 | 72 |
| 77 // An integer for use with the browser's command system. These should always | |
| 78 // be in the range [IDC_BROWSER_ACTION_FIRST, IDC_BROWSER_ACTION_LAST]. | |
| 79 int command_id_; | |
| 80 | |
| 81 // If the action has a popup, it has a URL and a height. | 73 // If the action has a popup, it has a URL and a height. |
| 82 GURL popup_url_; | 74 GURL popup_url_; |
| 83 int popup_height_; | 75 int popup_height_; |
| 84 }; | 76 }; |
| 85 | 77 |
| 86 typedef std::map<std::string, ExtensionAction*> ExtensionActionMap; | 78 typedef std::map<std::string, ExtensionAction*> ExtensionActionMap; |
| 87 | 79 |
| 88 // This class keeps track of what values each tab uses to override the default | 80 // This class keeps track of what values each tab uses to override the default |
| 89 // values of the ExtensionAction. | 81 // values of the ExtensionAction. |
| 90 class ExtensionActionState { | 82 class ExtensionActionState { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 // The badge text. | 120 // The badge text. |
| 129 std::string badge_text_; | 121 std::string badge_text_; |
| 130 | 122 |
| 131 // The background color for the badge. | 123 // The background color for the badge. |
| 132 SkColor badge_background_color_; | 124 SkColor badge_background_color_; |
| 133 | 125 |
| 134 DISALLOW_COPY_AND_ASSIGN(ExtensionActionState); | 126 DISALLOW_COPY_AND_ASSIGN(ExtensionActionState); |
| 135 }; | 127 }; |
| 136 | 128 |
| 137 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_ACTION_H_ | 129 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_ACTION_H_ |
| OLD | NEW |