Chromium Code Reviews| 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..a9b8b6428176d2217b8b85aadbcc8f19d6dc4012 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 section in the browser action container. This contains the actual |
|
msw
2012/07/24 23:41:55
nit: s/section/entry/
yefimt
2012/07/25 21:09:21
Done.
|
| +// 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 the |button_| inside BrowserActionView. |
|
msw
2012/07/24 23:41:55
nit: use "button" as general terminology, as this
yefimt
2012/07/25 21:09:21
Done, but i was asked to use specific variable nam
msw
2012/07/25 23:02:03
Doh! Sorry I missed that earlier comment; either w
|
| + 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_; |
| + |
| + // The container for this view. |
|
msw
2012/07/24 23:41:55
nit: it's not obvious that |delegate_| a container
yefimt
2012/07/25 21:09:21
Done.
|
| + 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_; |
| @@ -129,57 +207,23 @@ class BrowserActionButton : public views::MenuButton, |
| SkBitmap default_icon_; |
| // The browser action shelf. |
|
msw
2012/07/24 23:41:55
nit: update comment.
yefimt
2012/07/25 21:09:21
Done.
|
| - BrowserActionsContainer* panel_; |
| + 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 was disabled. |
|
msw
2012/07/24 23:41:55
nit: s/was/is/
yefimt
2012/07/25 21:09:21
Done.
|
| + 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_ |