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

Unified Diff: chrome/browser/ui/views/browser_action_view.h

Issue 10533086: Action box menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Action box menu Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/action_box_menu.cc ('k') | chrome/browser/ui/views/browser_action_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/browser_action_view.h
diff --git a/chrome/browser/ui/views/browser_action_view.h b/chrome/browser/ui/views/browser_action_view.h
index efbf4db33497c12ae0c8338126ef6b98a228dbd6..effc3d3450202da7db39896281a3de00cce6e6ed 100644
--- a/chrome/browser/ui/views/browser_action_view.h
+++ b/chrome/browser/ui/views/browser_action_view.h
@@ -12,16 +12,92 @@
#include "ui/views/context_menu_controller.h"
#include "ui/views/controls/button/menu_button.h"
#include "ui/views/controls/button/menu_button_listener.h"
+#include "ui/views/drag_controller.h"
#include "ui/views/view.h"
-class BrowserActionsContainer;
+class Browser;
+class BrowserActionButton;
class ExtensionAction;
+namespace extensions {
+class Extension;
+}
+
namespace views {
class MenuItemView;
+class MenuRunner;
}
////////////////////////////////////////////////////////////////////////////////
+// BrowserActionView
+// A single entry in the browser action container. This contains the actual
+// BrowserActionButton, as well as the logic to paint the badge.
+class BrowserActionView : public views::View {
+ public:
+ // Need DragControler here because BrowserActionView could be dragged/dropped.
+ class Delegate : public views::DragController {
+ public:
+ // Returns the current tab's ID, or -1 if there is no current tab.
+ virtual int GetCurrentTabId() const = 0;
+
+ // Called when the user clicks on the browser action icon.
+ virtual void OnBrowserActionExecuted(BrowserActionButton* button) = 0;
+
+ // Called when a browser action becomes visible/hidden.
+ virtual void OnBrowserActionVisibilityChanged() = 0;
+
+ // Returns relative position of a button inside BrowserActionView.
+ virtual gfx::Size GetViewContentOffset() const = 0;
Matt Perry 2012/07/31 15:59:14 This should return a gfx::Point, right? It's an of
yefimt 2012/07/31 17:19:35 Done.
+
+ virtual bool NeedToShowMultipleIconStates() const { return true; }
+ virtual bool NeedToShowTooltip() const { return true; }
+
+ protected:
+ Delegate() {}
+ virtual ~Delegate() {}
+ };
+
+ BrowserActionView(const extensions::Extension* extension,
+ Browser* browser,
+ Delegate* delegate);
+ virtual ~BrowserActionView();
+
+ BrowserActionButton* button() { return button_; }
+
+ // Allocates a canvas object on the heap and draws into it the icon for the
+ // view as well as the badge (if any). Caller is responsible for deleting the
+ // returned object.
+ gfx::Canvas* GetIconWithBadge();
+
+ // Overridden from views::View:
+ virtual void Layout() OVERRIDE;
+ virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
+ virtual gfx::Size GetPreferredSize() OVERRIDE;
+
+ protected:
+ // Overridden from views::View to paint the badge on top of children.
+ virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE;
+ virtual void ViewHierarchyChanged(bool is_add,
+ View* parent,
+ View* child) OVERRIDE;
+
+ private:
+ // The Browser object this view is associated with.
+ Browser* browser_;
+
+ // Usually a container for this view.
+ Delegate* delegate_;
+
+ // The button this view contains.
+ BrowserActionButton* button_;
+
+ // Extension this view associated with.
+ const extensions::Extension* extension_;
+
+ DISALLOW_COPY_AND_ASSIGN(BrowserActionView);
+};
+
+////////////////////////////////////////////////////////////////////////////////
// BrowserActionButton
// The BrowserActionButton is a specialization of the MenuButton class.
@@ -34,7 +110,8 @@ class BrowserActionButton : public views::MenuButton,
public content::NotificationObserver {
public:
BrowserActionButton(const extensions::Extension* extension,
- BrowserActionsContainer* panel);
+ Browser* browser_,
+ BrowserActionView::Delegate* delegate);
// Call this instead of delete.
void Destroy();
@@ -83,6 +160,8 @@ class BrowserActionButton : public views::MenuButton,
virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE;
virtual bool OnKeyReleased(const views::KeyEvent& event) OVERRIDE;
+ virtual void ShowContextMenu(const gfx::Point& p,
+ bool is_mouse_gesture) OVERRIDE;
// Overridden from ui::AcceleratorTarget.
virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
@@ -113,6 +192,14 @@ class BrowserActionButton : public views::MenuButton,
// it is active.
void MaybeUnregisterExtensionCommand(bool only_if_active);
+ // Returns tooltip for the button.
+ string16 GetName();
+
+ void ShowContextMenuImpl();
+
+ // The Browser object this button is associated with.
+ Browser* browser_;
+
// The browser action this view represents. The ExtensionAction is not owned
// by this class.
ExtensionAction* browser_action_;
@@ -128,58 +215,24 @@ class BrowserActionButton : public views::MenuButton,
// browser action had a value for default_icon in the manifest.
SkBitmap default_icon_;
- // The browser action shelf.
- BrowserActionsContainer* panel_;
+ // Delegate that usually represents a container for BrowserActionView.
+ BrowserActionView::Delegate* delegate_;
// The context menu. This member is non-NULL only when the menu is shown.
views::MenuItemView* context_menu_;
content::NotificationRegistrar registrar_;
- // The extension keybinding accelerator this browser action is listening for
+ // The extension key binding accelerator this browser action is listening for
// (to show the popup).
scoped_ptr<ui::Accelerator> keybinding_;
+ // Responsible for running the menu.
+ scoped_ptr<views::MenuRunner> menu_runner_;
+
friend class base::DeleteHelper<BrowserActionButton>;
DISALLOW_COPY_AND_ASSIGN(BrowserActionButton);
};
-
-////////////////////////////////////////////////////////////////////////////////
-// BrowserActionView
-// A single section in the browser action container. This contains the actual
-// BrowserActionButton, as well as the logic to paint the badge.
-
-class BrowserActionView : public views::View {
- public:
- BrowserActionView(const extensions::Extension* extension,
- BrowserActionsContainer* panel);
- virtual ~BrowserActionView();
-
- BrowserActionButton* button() { return button_; }
-
- // Allocates a canvas object on the heap and draws into it the icon for the
- // view as well as the badge (if any). Caller is responsible for deleting the
- // returned object.
- gfx::Canvas* GetIconWithBadge();
-
- // Overridden from views::View:
- virtual void Layout() OVERRIDE;
- virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
-
- protected:
- // Overridden from views::View to paint the badge on top of children.
- virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE;
-
- private:
- // The container for this view.
- BrowserActionsContainer* panel_;
-
- // The button this view contains.
- BrowserActionButton* button_;
-
- DISALLOW_COPY_AND_ASSIGN(BrowserActionView);
-};
-
#endif // CHROME_BROWSER_UI_VIEWS_BROWSER_ACTION_VIEW_H_
« no previous file with comments | « chrome/browser/ui/views/action_box_menu.cc ('k') | chrome/browser/ui/views/browser_action_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698