| Index: chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.h
|
| diff --git a/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.h b/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.h
|
| index 069bcf5729da8c9acdb5945d4e20d679b1ac1d1f..fd29a16533d64f2bfd9b81519be81ba23afc2b11 100644
|
| --- a/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.h
|
| +++ b/chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.h
|
| @@ -1,133 +1,64 @@
|
| -// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BROWSER_ACTION_OVERFLOW_MENU_CONTROLLER_H_
|
| #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BROWSER_ACTION_OVERFLOW_MENU_CONTROLLER_H_
|
|
|
| -#include <set>
|
| -#include <vector>
|
| -
|
| -#include "base/compiler_specific.h"
|
| +#include "base/macros.h"
|
| #include "base/memory/scoped_ptr.h"
|
| -#include "base/memory/scoped_vector.h"
|
| -#include "base/sequenced_task_runner_helpers.h"
|
| -#include "ui/views/controls/menu/menu_delegate.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "ui/views/controls/button/menu_button.h"
|
| +#include "ui/views/controls/button/menu_button_listener.h"
|
|
|
| -class Browser;
|
| class BrowserActionsContainer;
|
| -class BrowserActionView;
|
| -class IconUpdater;
|
| -
|
| -namespace views {
|
| -class MenuRunner;
|
| -class Widget;
|
| -}
|
|
|
| -// This class handles the overflow menu for browser actions (showing the menu,
|
| -// drag and drop, etc). This class manages its own lifetime.
|
| -class BrowserActionOverflowMenuController : public views::MenuDelegate {
|
| +// The MenuButton for the chevron in the extension toolbar, which is also
|
| +// responsible for showing the legacy (drop-down) overflow menu.
|
| +class ChevronMenuButton : public views::MenuButton,
|
| + public views::MenuButtonListener {
|
| public:
|
| - // The observer is notified prior to the menu being deleted.
|
| - class Observer {
|
| - public:
|
| - virtual void NotifyMenuDeleted(
|
| - BrowserActionOverflowMenuController* controller) = 0;
|
| - };
|
| -
|
| - BrowserActionOverflowMenuController(
|
| - BrowserActionsContainer* owner,
|
| - Browser* browser,
|
| - views::MenuButton* menu_button,
|
| - const std::vector<BrowserActionView*>& views,
|
| - int start_index,
|
| - bool for_drop);
|
| -
|
| - void set_observer(Observer* observer) { observer_ = observer; }
|
| -
|
| - // Shows the overflow menu.
|
| - bool RunMenu(views::Widget* widget);
|
| -
|
| - // Closes the overflow menu (and its context menu if open as well).
|
| - void CancelMenu();
|
| -
|
| - // Notify the menu that the associated BrowserActionViews have been deleted.
|
| - void NotifyBrowserActionViewsDeleting();
|
| + explicit ChevronMenuButton(
|
| + BrowserActionsContainer* browser_actions_container);
|
| + virtual ~ChevronMenuButton();
|
|
|
| - // Overridden from views::MenuDelegate:
|
| - virtual bool IsCommandEnabled(int id) const OVERRIDE;
|
| - virtual void ExecuteCommand(int id) OVERRIDE;
|
| - virtual bool ShowContextMenu(views::MenuItemView* source,
|
| - int id,
|
| - const gfx::Point& p,
|
| - ui::MenuSourceType source_type) OVERRIDE;
|
| - virtual void DropMenuClosed(views::MenuItemView* menu) OVERRIDE;
|
| - // These drag functions offer support for dragging icons into the overflow
|
| - // menu.
|
| - virtual bool GetDropFormats(
|
| - views::MenuItemView* menu,
|
| - int* formats,
|
| - std::set<ui::OSExchangeData::CustomFormat>* custom_formats) OVERRIDE;
|
| - virtual bool AreDropTypesRequired(views::MenuItemView* menu) OVERRIDE;
|
| - virtual bool CanDrop(views::MenuItemView* menu,
|
| - const ui::OSExchangeData& data) OVERRIDE;
|
| - virtual int GetDropOperation(views::MenuItemView* item,
|
| - const ui::DropTargetEvent& event,
|
| - DropPosition* position) OVERRIDE;
|
| - virtual int OnPerformDrop(views::MenuItemView* menu,
|
| - DropPosition position,
|
| - const ui::DropTargetEvent& event) OVERRIDE;
|
| - // These three drag functions offer support for dragging icons out of the
|
| - // overflow menu.
|
| - virtual bool CanDrag(views::MenuItemView* menu) OVERRIDE;
|
| - virtual void WriteDragData(views::MenuItemView* sender,
|
| - ui::OSExchangeData* data) OVERRIDE;
|
| - virtual int GetDragOperations(views::MenuItemView* sender) OVERRIDE;
|
| + // Closes the overflow menu (and any context menu), if it is open.
|
| + void CloseMenu();
|
|
|
| private:
|
| - // This class manages its own lifetime.
|
| - virtual ~BrowserActionOverflowMenuController();
|
| -
|
| - // Returns the offset into |views_| for the given |id|.
|
| - size_t IndexForId(int id) const;
|
| -
|
| - // A pointer to the browser action container that owns the overflow menu.
|
| - BrowserActionsContainer* owner_;
|
| -
|
| - Browser* browser_;
|
| + class MenuController;
|
|
|
| - // The observer, may be null.
|
| - Observer* observer_;
|
| -
|
| - // A pointer to the overflow menu button that we are showing the menu for.
|
| - views::MenuButton* menu_button_;
|
| -
|
| - // The overflow menu for the menu button. Owned by |menu_runner_|.
|
| - views::MenuItemView* menu_;
|
| + // views::MenuButton:
|
| + virtual scoped_ptr<views::LabelButtonBorder> CreateDefaultBorder() const
|
| + OVERRIDE;
|
| + virtual bool GetDropFormats(int* formats,
|
| + std::set<ui::OSExchangeData::CustomFormat>* custom_formats) OVERRIDE;
|
| + virtual bool AreDropTypesRequired() OVERRIDE;
|
| + virtual bool CanDrop(const ui::OSExchangeData& data) OVERRIDE;
|
| + virtual void OnDragEntered(const ui::DropTargetEvent& event) OVERRIDE;
|
| + virtual int OnDragUpdated(const ui::DropTargetEvent& event) OVERRIDE;
|
| + virtual void OnDragExited() OVERRIDE;
|
| + virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE;
|
|
|
| - // Resposible for running the menu.
|
| - scoped_ptr<views::MenuRunner> menu_runner_;
|
| + // views::MenuButtonListener:
|
| + virtual void OnMenuButtonClicked(View* source, const gfx::Point& point)
|
| + OVERRIDE;
|
|
|
| - // The views vector of all the browser actions the container knows about. We
|
| - // won't show all items, just the one starting at |start_index| and above.
|
| - // Owned by |owner_|.
|
| - const std::vector<BrowserActionView*>& views_;
|
| + // Shows the overflow menu.
|
| + void ShowOverflowMenu(bool for_drop);
|
|
|
| - // The index into the BrowserActionView vector, indicating where to start
|
| - // picking browser actions to draw.
|
| - int start_index_;
|
| + // Called by the overflow menu when all the work is done.
|
| + void MenuDone();
|
|
|
| - // Whether this controller is being used for drop.
|
| - bool for_drop_;
|
| + // The owning BrowserActionsContainer.
|
| + BrowserActionsContainer* browser_actions_container_;
|
|
|
| - // The vector keeps all icon updaters associated with menu item views in the
|
| - // controller. The icon updater will update the menu item view's icon when
|
| - // the browser action view's icon has been updated.
|
| - ScopedVector<IconUpdater> icon_updaters_;
|
| + // The overflow menu controller.
|
| + scoped_ptr<MenuController> menu_controller_;
|
|
|
| - friend class base::DeleteHelper<BrowserActionOverflowMenuController>;
|
| + base::WeakPtrFactory<ChevronMenuButton> weak_factory_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(BrowserActionOverflowMenuController);
|
| + DISALLOW_COPY_AND_ASSIGN(ChevronMenuButton);
|
| };
|
|
|
| #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BROWSER_ACTION_OVERFLOW_MENU_CONTROLLER_H_
|
|
|