Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_ | |
| 6 #define CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 | |
| 10 #include "base/memory/linked_ptr.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "chrome/browser/ui/views/browser_action_view.h" | |
| 13 #include "content/public/browser/notification_observer.h" | |
| 14 #include "ui/base/models/menu_model.h" | |
| 15 #include "ui/views/controls/menu/menu_delegate.h" | |
| 16 | |
| 17 class ActionBoxMenuModel; | |
| 18 | |
| 19 namespace views { | |
| 20 class Background; | |
| 21 class Border; | |
| 22 class MenuItemView; | |
| 23 class MenuRunner; | |
| 24 class View; | |
| 25 } | |
| 26 | |
| 27 // ActionBoxMenu adapts the ActionBoxMenuModel to view's menu related classes. | |
| 28 class ActionBoxMenu | |
| 29 : public views::MenuDelegate, | |
|
Peter Kasting
2012/07/14 02:08:01
Nit: Place at end of previous line, indent subsequ
yefimt
2012/07/17 18:20:37
Done.
| |
| 30 public BrowserActionView::Delegate, | |
| 31 public content::NotificationObserver { | |
| 32 public: | |
| 33 ActionBoxMenu(Browser* browser, ActionBoxMenuModel* model, | |
|
Peter Kasting
2012/07/14 02:08:01
Nit: One arg per line
yefimt
2012/07/17 18:20:37
Done.
| |
| 34 bool bookmark_item_state); | |
| 35 virtual ~ActionBoxMenu(); | |
| 36 | |
| 37 void Init(); | |
| 38 | |
| 39 // Shows the menu relative to the specified view. | |
|
Peter Kasting
2012/07/14 02:08:01
Nit: "specified button" perhaps?
yefimt
2012/07/17 18:20:37
Done.
| |
| 40 void RunMenu(views::MenuButton* host); | |
|
Peter Kasting
2012/07/14 02:08:01
Nit: |host| seems like an odd name, what about |bu
yefimt
2012/07/17 18:20:37
Done.
| |
| 41 | |
| 42 private: | |
| 43 // MenuDelegate overrides: | |
| 44 virtual void ExecuteCommand(int id) OVERRIDE; | |
| 45 virtual views::Border* CreateMenuBorder() OVERRIDE; | |
| 46 virtual views::Background* CreateMenuBackground() OVERRIDE; | |
| 47 | |
| 48 // BrowserActionsHostDelegate overrides: | |
| 49 virtual Browser* GetBrowser() const OVERRIDE; | |
| 50 virtual int GetCurrentTabId() const OVERRIDE; | |
| 51 virtual void OnBrowserActionExecuted(BrowserActionButton* button) OVERRIDE; | |
| 52 virtual void OnBrowserActionVisibilityChanged() OVERRIDE; | |
| 53 virtual gfx::Size GetViewContentOffset() const OVERRIDE; | |
| 54 | |
| 55 // DragController overrides: | |
| 56 virtual void WriteDragDataForView(views::View* sender, | |
| 57 const gfx::Point& press_pt, | |
| 58 ui::OSExchangeData* data) OVERRIDE; | |
| 59 virtual int GetDragOperationsForView(views::View* sender, | |
| 60 const gfx::Point& p) OVERRIDE; | |
| 61 virtual bool CanStartDragForView(views::View* sender, | |
| 62 const gfx::Point& press_pt, | |
| 63 const gfx::Point& p) OVERRIDE; | |
| 64 | |
| 65 // NotificationObserver overrides: | |
| 66 virtual void Observe(int type, | |
| 67 const content::NotificationSource& source, | |
| 68 const content::NotificationDetails& details) OVERRIDE; | |
| 69 | |
| 70 views::MenuItemView* AddBookmarkMenuItem(views::MenuItemView* parent, | |
| 71 int* next_id); | |
| 72 | |
| 73 // Populates |parent| with all the child menus in |model|. | |
| 74 void PopulateMenu(); | |
| 75 | |
| 76 Browser* browser_; | |
| 77 | |
| 78 // The views menu. Owned by |menu_runner_|. | |
| 79 views::MenuItemView* root_; | |
| 80 | |
| 81 scoped_ptr<views::MenuRunner> menu_runner_; | |
| 82 | |
| 83 // The model that tracks the order of the toolbar icons. | |
| 84 ActionBoxMenuModel* model_; | |
| 85 | |
| 86 bool bookmark_item_state_; | |
| 87 | |
| 88 typedef std::vector<linked_ptr<BrowserActionView> > BrowserActionViews; | |
|
Peter Kasting
2012/07/14 02:08:01
Use ScopedVector instead.
Nit: Typedef goes atop
yefimt
2012/07/17 18:20:37
Actually another reviewer, aa@, insisted to use ve
| |
| 89 BrowserActionViews browser_action_views_; | |
| 90 | |
| 91 DISALLOW_COPY_AND_ASSIGN(ActionBoxMenu); | |
| 92 }; | |
| 93 | |
| 94 #endif // CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_ | |
| OLD | NEW |