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 93b32ae5fee915f8d4c67f4c70ccf22b93f06d04..a3990874996647c31086f0b4ea9d67a6524b4bf2 100644 |
| --- a/chrome/browser/ui/views/browser_action_view.h |
| +++ b/chrome/browser/ui/views/browser_action_view.h |
| @@ -12,9 +12,11 @@ |
| #include "content/public/browser/notification_observer.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,18 +24,68 @@ class MenuItemView; |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| +// BrowserActionView |
| +// A single section in the browser action container. This contains the actual |
| +// BrowserActionButton, as well as the logic to paint the badge. |
| + |
|
Aaron Boodman
2012/07/02 22:41:34
Delete this line.
yefimt
2012/07/11 22:34:34
Done.
|
| +class BrowserActionView : public views::View { |
| + public: |
| + class Delegate : public views::DragController { |
| + public: |
| + virtual Browser* GetBrowser() const = 0; |
| + virtual int GetCurrentTabId() const = 0; |
| + virtual void OnBrowserActionExecuted(BrowserActionButton* button) = 0; |
| + virtual void OnBrowserActionVisibilityChanged() = 0; |
| + virtual gfx::Size GetViewContentOffset() const = 0; |
|
Aaron Boodman
2012/07/02 22:41:34
This name is not very descriptive. Can you pick a
yefimt
2012/07/11 22:34:34
I have a hard time to come up with a better name,
|
| + |
| + protected: |
| + Delegate() {} |
| + virtual ~Delegate() {} |
| + }; |
| + |
| + BrowserActionView(const extensions::Extension* extension, 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; |
| + |
| + private: |
| + // The 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. |
| // It acts on a ExtensionAction, in this case a BrowserAction and handles |
| // loading the image for the button asynchronously on the file thread. |
| class BrowserActionButton : public views::MenuButton, |
| - public views::ButtonListener, |
| - public ImageLoadingTracker::Observer, |
| - public content::NotificationObserver { |
| + public views::ButtonListener, |
|
Aaron Boodman
2012/07/02 22:41:34
These should line up as they did before.
yefimt
2012/07/11 22:34:34
Done
I have a devstudio plugin which tries to do s
|
| + public ImageLoadingTracker::Observer, |
| + public content::NotificationObserver { |
| public: |
| BrowserActionButton(const extensions::Extension* extension, |
| - BrowserActionsContainer* panel); |
| + BrowserActionView::Delegate* delegate); |
|
Aaron Boodman
2012/07/02 22:41:34
Put indent back as before.
yefimt
2012/07/11 22:34:34
Done.
|
| // Call this instead of delete. |
| void Destroy(); |
| @@ -56,17 +108,17 @@ class BrowserActionButton : public views::MenuButton, |
| // Overridden from views::ButtonListener: |
| virtual void ButtonPressed(views::Button* sender, |
| - const views::Event& event) OVERRIDE; |
| + const views::Event& event) OVERRIDE; |
|
Aaron Boodman
2012/07/02 22:41:34
Why are you changing all these indents?
yefimt
2012/07/11 22:34:34
Done.
|
| // Overridden from ImageLoadingTracker. |
| virtual void OnImageLoaded(const gfx::Image& image, |
| - const std::string& extension_id, |
| - int index) OVERRIDE; |
| + const std::string& extension_id, |
| + int index) OVERRIDE; |
| // Overridden from content::NotificationObserver: |
| virtual void Observe(int type, |
| - const content::NotificationSource& source, |
| - const content::NotificationDetails& details) OVERRIDE; |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) OVERRIDE; |
| // MenuButton behavior overrides. These methods all default to TextButton |
| // behavior unless this button is a popup. In that case, it uses MenuButton |
| @@ -79,7 +131,7 @@ class BrowserActionButton : public views::MenuButton, |
| 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; |
| + bool is_mouse_gesture) OVERRIDE; |
| // Overridden from ui::AcceleratorTarget. |
| virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; |
| @@ -89,11 +141,13 @@ class BrowserActionButton : public views::MenuButton, |
| void SetButtonPushed(); |
| void SetButtonNotPushed(); |
| + void DisableTooltip(bool disable_tooltip); |
|
Aaron Boodman
2012/07/02 22:41:34
Hm, we should do something with the tooltip text t
yefimt
2012/07/11 22:34:34
This one disables tooltip for an browser action bu
|
| + |
| protected: |
| // Overridden from views::View: |
| virtual void ViewHierarchyChanged(bool is_add, |
| - View* parent, |
| - View* child) OVERRIDE; |
| + View* parent, |
| + View* child) OVERRIDE; |
| private: |
| virtual ~BrowserActionButton(); |
| @@ -121,57 +175,22 @@ class BrowserActionButton : public views::MenuButton, |
| SkBitmap default_icon_; |
| // The browser action shelf. |
| - 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_; |
| + bool disable_tooltip_; |
|
Aaron Boodman
2012/07/02 22:41:34
Comment.
yefimt
2012/07/11 22:34:34
Done.
|
| + |
| 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_ |