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 #pragma once | |
8 | |
9 #include <map> | |
10 | |
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, | |
30 public BrowserActionView::Delegate, | |
31 public content::NotificationObserver { | |
32 public: | |
33 ActionBoxMenu(Browser* browser, ActionBoxMenuModel* model, | |
34 bool bookmark_item_state); | |
35 virtual ~ActionBoxMenu(); | |
36 | |
37 void Init(); | |
38 | |
39 // Shows the menu relative to the specified view. | |
40 void RunMenu(views::MenuButton* host); | |
41 | |
42 private: | |
43 // MenuDelegate overrides: | |
Aaron Boodman
2012/07/02 22:41:34
Indent is incorrect.
yefimt
2012/07/11 22:34:34
Done.
| |
44 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.
| |
45 virtual views::Border* CreateMenuBorder() OVERRIDE; | |
46 virtual views::Background* CreateMenuBackground() OVERRIDE; | |
47 | |
Aaron Boodman
2012/07/02 22:41:34
Remove extra blank line.
yefimt
2012/07/11 22:34:34
Done.
| |
48 | |
49 // BrowserActionsHostDelegate overrides: | |
50 virtual Browser* GetBrowser() const OVERRIDE; | |
51 virtual int GetCurrentTabId() const OVERRIDE; | |
52 virtual void OnBrowserActionExecuted(BrowserActionButton* button) OVERRIDE; | |
53 virtual void OnBrowserActionVisibilityChanged() OVERRIDE; | |
54 virtual gfx::Size GetViewContentOffset() const OVERRIDE; | |
55 | |
56 // 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.
| |
57 virtual void WriteDragDataForView(views::View* sender, | |
58 const gfx::Point& press_pt, | |
59 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.
| |
60 virtual int GetDragOperationsForView(views::View* sender, | |
61 const gfx::Point& p) OVERRIDE; | |
62 virtual bool CanStartDragForView(views::View* sender, | |
63 const gfx::Point& press_pt, | |
64 const gfx::Point& p) OVERRIDE; | |
65 | |
66 // content::NotificationObserver overrides: | |
67 virtual void Observe(int type, | |
68 const content::NotificationSource& source, | |
69 const content::NotificationDetails& details) OVERRIDE; | |
70 | |
71 views::MenuItemView* AddBookmarkMenuItem(views::MenuItemView* parent, | |
72 int* index, | |
73 int* next_id); | |
74 | |
75 // Populates |parent| with all the child menus in |model|. | |
76 void PopulateMenu(); | |
77 | |
78 Browser* browser_; | |
79 | |
80 // The views menu. Owned by |menu_runner_|. | |
81 views::MenuItemView* root_; | |
82 | |
83 scoped_ptr<views::MenuRunner> menu_runner_; | |
84 | |
85 // The model that tracks the order of the toolbar icons. | |
86 ActionBoxMenuModel* model_; | |
87 | |
88 bool bookmark_item_state_; | |
89 | |
90 int model_index_offset_; | |
91 | |
92 typedef std::vector<BrowserActionView*> BrowserActionViews; | |
93 BrowserActionViews browser_action_views_; | |
94 | |
95 DISALLOW_COPY_AND_ASSIGN(ActionBoxMenu); | |
96 }; | |
97 | |
98 #endif // CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_ | |
OLD | NEW |