| 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 316ab876c47e8780502cf441b7d24faadd88c905..36a8f0f5043b277b998cdd0767ca215cb1cfc12b 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 DragController 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::Point GetViewContentOffset() const = 0;
|
| +
|
| + virtual bool NeedToShowMultipleIconStates() const;
|
| + virtual bool NeedToShowTooltip() const;
|
| +
|
| + protected:
|
| + 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();
|
| @@ -111,6 +188,9 @@ class BrowserActionButton : public views::MenuButton,
|
| // it is active.
|
| void MaybeUnregisterExtensionCommand(bool only_if_active);
|
|
|
| + // 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_;
|
| @@ -122,58 +202,28 @@ class BrowserActionButton : public views::MenuButton,
|
| // asynchronously.
|
| ImageLoadingTracker tracker_;
|
|
|
| - // The browser action shelf.
|
| - BrowserActionsContainer* panel_;
|
| + // The default icon for our browser action. This might be non-empty if the
|
| + // browser action had a value for default_icon in the manifest.
|
| + SkBitmap default_icon_;
|
| +
|
| + // 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_
|
|
|