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..41593e350c8aa34295aadf65a43f0d99dcc896b4 100644 |
--- a/chrome/browser/ui/views/browser_action_view.h |
+++ b/chrome/browser/ui/views/browser_action_view.h |
@@ -12,9 +12,11 @@ |
#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 views { |
@@ -22,6 +24,69 @@ class MenuItemView; |
} |
//////////////////////////////////////////////////////////////////////////////// |
+// 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; |
+ |
+ 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_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(BrowserActionView); |
+}; |
+ |
+//////////////////////////////////////////////////////////////////////////////// |
// BrowserActionButton |
// The BrowserActionButton is a specialization of the MenuButton class. |
@@ -34,7 +99,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 +149,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; |
@@ -92,6 +160,8 @@ class BrowserActionButton : public views::MenuButton, |
void SetButtonPushed(); |
void SetButtonNotPushed(); |
+ void SetTooltipDisabled(bool disable_tooltip); |
+ |
// Whether the browser action is enabled on this tab. Note that we cannot use |
// the built-in views enabled/SetEnabled because disabled views do not |
// receive drag events. |
@@ -113,6 +183,14 @@ class BrowserActionButton : public views::MenuButton, |
// it is active. |
void MaybeUnregisterExtensionCommand(bool only_if_active); |
+ // Returns tooltip for the button. |
+ string16 GetTextForTooltip(); |
+ |
+ 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 +206,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_; |
+ // True if tooltip is disabled. |
+ bool disable_tooltip_; |
+ |
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_ |