| Index: chrome/browser/ui/views/toolbar/browser_action_view.h
|
| diff --git a/chrome/browser/ui/views/toolbar/browser_action_view.h b/chrome/browser/ui/views/toolbar/browser_action_view.h
|
| index 190e545ab479aacec10071a2a20e74a4d54da040..213a02c077e4910ce82c6685a4a2a6b1a9f46f1c 100644
|
| --- a/chrome/browser/ui/views/toolbar/browser_action_view.h
|
| +++ b/chrome/browser/ui/views/toolbar/browser_action_view.h
|
| @@ -6,7 +6,7 @@
|
| #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTION_VIEW_H_
|
|
|
| #include "chrome/browser/ui/views/extensions/extension_action_view_controller.h"
|
| -#include "chrome/browser/ui/views/extensions/extension_action_view_delegate.h"
|
| +#include "chrome/browser/ui/views/toolbar/toolbar_action_view_delegate.h"
|
| #include "content/public/browser/notification_observer.h"
|
| #include "content/public/browser/notification_registrar.h"
|
| #include "ui/views/controls/button/menu_button.h"
|
| @@ -29,12 +29,12 @@ class Image;
|
| // BrowserActionView
|
| // A wrapper around an ExtensionActionViewController to display an extension
|
| // action in the BrowserActionsContainer.
|
| -// Despite its name, this class can handle either Browser Actions or Page
|
| -// Actions.
|
| +// Despite its name, this class can handle any type of toolbar action, including
|
| +// extension actions (browser and page actions) and chrome actions.
|
| // TODO(devlin): Rename this and BrowserActionsContainer when more of the
|
| // toolbar redesign is done.
|
| class BrowserActionView : public views::MenuButton,
|
| - public ExtensionActionViewDelegate,
|
| + public ToolbarActionViewDelegate,
|
| public views::ButtonListener,
|
| public content::NotificationObserver {
|
| public:
|
| @@ -66,48 +66,28 @@ class BrowserActionView : public views::MenuButton,
|
|
|
| // Returns the primary BrowserActionView associated with the given
|
| // |extension|.
|
| - virtual BrowserActionView* GetMainViewForExtension(
|
| - const extensions::Extension* extension) = 0;
|
| + virtual BrowserActionView* GetMainViewForAction(
|
| + BrowserActionView* view) = 0;
|
|
|
| protected:
|
| virtual ~Delegate() {}
|
| };
|
|
|
| - // The IconObserver will receive a notification when the button's icon has
|
| - // been updated.
|
| - class IconObserver {
|
| - public:
|
| - virtual void OnIconUpdated(const gfx::ImageSkia& icon) = 0;
|
| -
|
| - protected:
|
| - virtual ~IconObserver() {}
|
| + // The type of action this view is showing.
|
| + enum Type {
|
| + TYPE_EXTENSION_ACTION,
|
| + TYPE_CHROME_ACTION,
|
| };
|
|
|
| - BrowserActionView(const extensions::Extension* extension,
|
| - ExtensionAction* extension_action,
|
| + BrowserActionView(scoped_ptr<ToolbarActionViewController> view_controller,
|
| + Type type,
|
| Browser* browser,
|
| - BrowserActionView::Delegate* delegate);
|
| + Delegate* delegate);
|
| virtual ~BrowserActionView();
|
|
|
| - const extensions::Extension* extension() const {
|
| - return view_controller_->extension();
|
| - }
|
| - ExtensionAction* extension_action() {
|
| - return view_controller_->extension_action();
|
| - }
|
| - ExtensionActionViewController* view_controller() {
|
| - return view_controller_.get();
|
| - }
|
| - void set_icon_observer(IconObserver* icon_observer) {
|
| - icon_observer_ = icon_observer;
|
| - }
|
| -
|
| // Called to update the display to match the browser action's state.
|
| void UpdateState();
|
|
|
| - // Does this button's action have a popup?
|
| - bool IsPopup();
|
| -
|
| // Overridden from views::View:
|
| virtual void GetAccessibleState(ui::AXViewState* state) override;
|
|
|
| @@ -134,13 +114,19 @@ class BrowserActionView : public views::MenuButton,
|
| virtual scoped_ptr<views::LabelButtonBorder> CreateDefaultBorder() const
|
| override;
|
|
|
| - // 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.
|
| - bool IsEnabled(int tab_id) const;
|
| + // ExtensionActionViewDelegate: (public because called by others).
|
| + virtual int GetCurrentTabId() const override;
|
|
|
| - // Gets the icon of this button and its badge.
|
| - gfx::ImageSkia GetIconWithBadge();
|
| + // A convenience method to get the |view_controller_| as an
|
| + // ExtensionActionViewController. This will DCHECK if this isn't a view for
|
| + // an extension action.
|
| + ExtensionActionViewController* GetExtensionActionViewController();
|
| +
|
| + ToolbarActionViewController* view_controller() {
|
| + return view_controller_.get();
|
| + }
|
| + Browser* browser() { return browser_; }
|
| + Type type() const { return type_; }
|
|
|
| // Returns button icon so it can be accessed during tests.
|
| gfx::ImageSkia GetIconForTest();
|
| @@ -159,11 +145,10 @@ class BrowserActionView : public views::MenuButton,
|
| virtual bool IsShownInMenu() override;
|
| virtual views::FocusManager* GetFocusManagerForAccelerator() override;
|
| virtual views::Widget* GetParentForContextMenu() override;
|
| - virtual ExtensionActionViewController* GetPreferredPopupViewController()
|
| + virtual ToolbarActionViewController* GetPreferredPopupViewController()
|
| override;
|
| virtual views::View* GetReferenceViewForPopup() override;
|
| virtual views::MenuButton* GetContextMenuButton() override;
|
| - virtual content::WebContents* GetCurrentWebContents() override;
|
| virtual void HideActivePopup() override;
|
| virtual void OnIconUpdated() override;
|
| virtual void OnPopupShown(bool grant_tab_permissions) override;
|
| @@ -175,21 +160,23 @@ class BrowserActionView : public views::MenuButton,
|
| // object.
|
| scoped_ptr<views::MenuButton::PressedLock> pressed_lock_;
|
|
|
| - // The controller for this ExtensionAction view.
|
| - scoped_ptr<ExtensionActionViewController> view_controller_;
|
| + // The controller for this toolbar action view.
|
| + scoped_ptr<ToolbarActionViewController> view_controller_;
|
| +
|
| + // The type of action this view represents.
|
| + Type type_;
|
| +
|
| + // The associated browser.
|
| + Browser* browser_;
|
|
|
| // Delegate that usually represents a container for BrowserActionView.
|
| - BrowserActionView::Delegate* delegate_;
|
| + Delegate* delegate_;
|
|
|
| // Used to make sure we only register the command once.
|
| - bool called_registered_extension_command_;
|
| + bool called_register_command_;
|
|
|
| content::NotificationRegistrar registrar_;
|
|
|
| - // The observer that we need to notify when the icon of the button has been
|
| - // updated.
|
| - IconObserver* icon_observer_;
|
| -
|
| DISALLOW_COPY_AND_ASSIGN(BrowserActionView);
|
| };
|
|
|
|
|