Chromium Code Reviews| Index: chrome/browser/ui/views/action_box_menu.h |
| diff --git a/chrome/browser/ui/views/action_box_menu.h b/chrome/browser/ui/views/action_box_menu.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fbb65c62476a2b92ef9c1dbce1f143e5d7931c9d |
| --- /dev/null |
| +++ b/chrome/browser/ui/views/action_box_menu.h |
| @@ -0,0 +1,98 @@ |
| +// Copyright (c) 2012 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_ACTION_BOX_MENU_H_ |
| +#define CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_ |
| +#pragma once |
| + |
| +#include <map> |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "chrome/browser/ui/views/browser_action_view.h" |
| +#include "content/public/browser/notification_observer.h" |
| +#include "ui/base/models/menu_model.h" |
| +#include "ui/views/controls/menu/menu_delegate.h" |
| + |
| +class ActionBoxMenuModel; |
| + |
| +namespace views { |
| +class Background; |
| +class Border; |
| +class MenuItemView; |
| +class MenuRunner; |
| +class View; |
| +} |
| + |
| +// ActionBoxMenu adapts the ActionBoxMenuModel to view's menu related classes. |
| +class ActionBoxMenu |
| + : public views::MenuDelegate, |
| + public BrowserActionView::Delegate, |
| + public content::NotificationObserver { |
| + public: |
| + ActionBoxMenu(Browser* browser, ActionBoxMenuModel* model, |
| + bool bookmark_item_state); |
| + virtual ~ActionBoxMenu(); |
| + |
| + void Init(); |
| + |
| + // Shows the menu relative to the specified view. |
| + void RunMenu(views::MenuButton* host); |
| + |
| + private: |
| + // MenuDelegate overrides: |
|
Aaron Boodman
2012/07/02 22:41:34
Indent is incorrect.
yefimt
2012/07/11 22:34:34
Done.
|
| + virtual void ExecuteCommand(int id); |
|
Aaron Boodman
2012/07/02 22:41:34
Why is OVERRIDE not needed here?
yefimt
2012/07/11 22:34:34
Done.
|
| + virtual views::Border* CreateMenuBorder() OVERRIDE; |
| + virtual views::Background* CreateMenuBackground() OVERRIDE; |
| + |
|
Aaron Boodman
2012/07/02 22:41:34
Remove extra blank line.
yefimt
2012/07/11 22:34:34
Done.
|
| + |
| + // BrowserActionsHostDelegate overrides: |
| + virtual Browser* GetBrowser() const OVERRIDE; |
| + virtual int GetCurrentTabId() const OVERRIDE; |
| + virtual void OnBrowserActionExecuted(BrowserActionButton* button) OVERRIDE; |
| + virtual void OnBrowserActionVisibilityChanged() OVERRIDE; |
| + virtual gfx::Size GetViewContentOffset() const OVERRIDE; |
| + |
| + // Overridden from views::DragController: |
|
Aaron Boodman
2012/07/02 22:41:34
Inconsistent comment wording: views::DragControlle
yefimt
2012/07/11 22:34:34
Done.
|
| + virtual void WriteDragDataForView(views::View* sender, |
| + const gfx::Point& press_pt, |
| + ui::OSExchangeData* data) OVERRIDE; |
|
Aaron Boodman
2012/07/02 22:41:34
The left column of all param lines should line up.
yefimt
2012/07/11 22:34:34
Done.
|
| + virtual int GetDragOperationsForView(views::View* sender, |
| + const gfx::Point& p) OVERRIDE; |
| + virtual bool CanStartDragForView(views::View* sender, |
| + const gfx::Point& press_pt, |
| + const gfx::Point& p) OVERRIDE; |
| + |
| + // content::NotificationObserver overrides: |
| + virtual void Observe(int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) OVERRIDE; |
| + |
| + views::MenuItemView* AddBookmarkMenuItem(views::MenuItemView* parent, |
| + int* index, |
| + int* next_id); |
| + |
| + // Populates |parent| with all the child menus in |model|. |
| + void PopulateMenu(); |
| + |
| + Browser* browser_; |
| + |
| + // The views menu. Owned by |menu_runner_|. |
| + views::MenuItemView* root_; |
| + |
| + scoped_ptr<views::MenuRunner> menu_runner_; |
| + |
| + // The model that tracks the order of the toolbar icons. |
| + ActionBoxMenuModel* model_; |
| + |
| + bool bookmark_item_state_; |
| + |
| + int model_index_offset_; |
| + |
| + typedef std::vector<BrowserActionView*> BrowserActionViews; |
| + BrowserActionViews browser_action_views_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ActionBoxMenu); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_ |