summaryrefslogtreecommitdiffstats
path: root/chrome/common/page_action.h
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-01 22:02:34 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-01 22:02:34 +0000
commitf7f3a5f86a24f65666284802b51d0eaa5c9d7741 (patch)
tree5605992d68c1b48fe47f7fbee560dca7cda6693b /chrome/common/page_action.h
parent32d371758f777380486f9c8ef28b1faca37ab26c (diff)
downloadchromium_src-f7f3a5f86a24f65666284802b51d0eaa5c9d7741.zip
chromium_src-f7f3a5f86a24f65666284802b51d0eaa5c9d7741.tar.gz
chromium_src-f7f3a5f86a24f65666284802b51d0eaa5c9d7741.tar.bz2
This is the first part of the PageAction implementation. More work is required, but this is a good checkpoint.
Design doc: http://dev.chromium.org/developers/design-documents/extensions/page-actions-api This checkin only covers Tab scoped page actions (not type "permanent"). It works end to end (if you have an extension that supplies the page action info -- I created an RSS page action that links to Google Reader). Please note that TabIndex is hard coded to 0 until the extension system can provide the tab id to the extensions (which I understand is in progress). This means that page action(s) only show up for the first tab in the tabstrip. :) BUG=None TEST=There is a unit test for the API, but apart from that it is not possible to test this manually without writing an extension that adds a PageAction. My RSS page action is not ready to be checked in but I can provide it if there is interest in a sneak preview during review/QA. Review URL: http://codereview.chromium.org/99253 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15105 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/page_action.h')
-rw-r--r--chrome/common/page_action.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/chrome/common/page_action.h b/chrome/common/page_action.h
new file mode 100644
index 0000000..ea08da3
--- /dev/null
+++ b/chrome/common/page_action.h
@@ -0,0 +1,82 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_COMMON_PAGE_ACTION_H_
+#define CHROME_COMMON_PAGE_ACTION_H_
+
+#include <string>
+#include <map>
+
+#include "base/file_path.h"
+#include "googleurl/src/gurl.h"
+
+class PageAction {
+ public:
+ PageAction();
+ virtual ~PageAction();
+
+ typedef enum PageActionType {
+ PERMANENT = 0,
+ TAB = 1,
+ };
+
+ std::string id() const { return id_; }
+ void set_id(std::string id) { id_ = id; }
+
+ PageActionType type() const { return type_; }
+ void set_type(PageActionType type) { type_ = type; }
+
+ std::string extension_id() const { return extension_id_; }
+ void set_extension_id(std::string extension_id) {
+ extension_id_ = extension_id;
+ }
+
+ std::string name() const { return name_; }
+ void set_name(const std::string& name) { name_ = name; }
+
+ FilePath icon_path() const { return icon_path_; }
+ void set_icon_path(const FilePath& icon_path) {
+ icon_path_ = icon_path;
+ }
+
+ std::string tooltip() const { return tooltip_; }
+ void set_tooltip(const std::string& tooltip) {
+ tooltip_ = tooltip;
+ }
+
+ // Sets the active tab and url for this PageAction.
+ void SetActiveTabIdAndUrl(int tab_id, const GURL& url);
+ // Returns true if the PageAction is active in the specified |tab_id| & |url|.
+ bool IsActive(int tab_id, const GURL& url) const;
+
+ private:
+ // The id for the PageAction, for example: "RssPageAction".
+ std::string id_;
+
+ // The type of the PageAction.
+ PageActionType type_;
+
+ // The id for the extension this PageAction belongs to (as defined in the
+ // extension manifest).
+ std::string extension_id_;
+
+ // The name of the PageAction.
+ std::string name_;
+
+ // The icon that represents the PageIcon.
+ FilePath icon_path_;
+
+ // The tooltip to show when the mouse hovers over the icon of the page action.
+ std::string tooltip_;
+
+ // The url of the page which the PageAction is currently active in.
+ GURL active_url_;
+
+ // The tab ID for which the PageAction is currently active in.
+ int active_tab_id_;
+};
+
+typedef std::map<std::string, PageAction*> PageActionMap;
+
+#endif // CHROME_COMMON_PAGE_ACTION_H_