summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/browser_actions_container.h
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-26 03:18:46 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-26 03:18:46 +0000
commit671e6c1cecf01e46dc0267e020971aa0f98de0a2 (patch)
tree61db92254d4030103b4f4f68b7b8a7ad342f6d93 /chrome/browser/views/browser_actions_container.h
parent37e1bb64e696f39acb8a80021af58356af8e3bf1 (diff)
downloadchromium_src-671e6c1cecf01e46dc0267e020971aa0f98de0a2.zip
chromium_src-671e6c1cecf01e46dc0267e020971aa0f98de0a2.tar.gz
chromium_src-671e6c1cecf01e46dc0267e020971aa0f98de0a2.tar.bz2
Implement Browser Actions extensions.
Browser Actions are like Page Actions, except they appear next to the Omnibox and are always visible. For details see http://code.google.com/p/chromium/wiki/BrowserActions. Added a simple browser action sample that adds a Print button to the chrome toolbar (which brings up the Print dialog for the current page). Removed |type| from PageActions, which is currently ignored and was already removed from the docs. Each extension can only have 1 browser_action. Each browser action can specify more than one icon, but only the first is used. And no API has been added yet (besides the event definition). BUG=22099 TEST=Install the sample browser action, navigate to google.com, press the print button. A print dialog should come up. Review URL: http://codereview.chromium.org/243001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27319 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/browser_actions_container.h')
-rw-r--r--chrome/browser/views/browser_actions_container.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/chrome/browser/views/browser_actions_container.h b/chrome/browser/views/browser_actions_container.h
new file mode 100644
index 0000000..73d4f13
--- /dev/null
+++ b/chrome/browser/views/browser_actions_container.h
@@ -0,0 +1,69 @@
+// 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_BROWSER_VIEWS_BROWSER_ACTIONS_PANEL_H_
+#define CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_PANEL_H_
+
+#include <vector>
+
+#include "chrome/common/notification_observer.h"
+#include "chrome/common/notification_registrar.h"
+#include "views/view.h"
+
+class ContextualAction;
+class Profile;
+class ToolbarView;
+namespace views {
+class ImageButton;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// The BrowserActionsContainer is a container view, responsible for drawing the
+// icons that represent browser actions (extensions that add icons to the
+// toolbar).
+//
+////////////////////////////////////////////////////////////////////////////////
+class BrowserActionsContainer : public views::View,
+ public NotificationObserver {
+ public:
+ BrowserActionsContainer(Profile* profile, ToolbarView* toolbar);
+ virtual ~BrowserActionsContainer();
+
+ // Update the views to reflect the state of the browser action icons.
+ void RefreshBrowserActionViews();
+
+ // Delete all browser action views.
+ void DeleteBrowserActionViews();
+
+ // Called when a browser action becomes visible/hidden.
+ void OnBrowserActionVisibilityChanged();
+
+ // Called when the user clicks on the browser action icon.
+ void OnBrowserActionExecuted(const ContextualAction& browser_action);
+
+ // Overridden from views::View:
+ virtual gfx::Size GetPreferredSize();
+ virtual void Layout();
+
+ // Overridden from NotificationObserver:
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
+ private:
+ // The vector of browser actions (icons/image buttons for each action).
+ std::vector<views::ImageButton*> browser_action_views_;
+
+ NotificationRegistrar registrar_;
+
+ Profile* profile_;
+
+ // The toolbar that owns us.
+ ToolbarView* toolbar_;
+
+ DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer);
+};
+
+#endif // CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_PANEL_H_