OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_ |
7 | 7 |
8 #include <map> | |
9 | |
10 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/scoped_vector.h" | |
12 #include "chrome/browser/ui/views/browser_action_view.h" | |
13 #include "ui/views/controls/menu/menu_delegate.h" | 9 #include "ui/views/controls/menu/menu_delegate.h" |
14 | 10 |
15 class ActionBoxButtonController; | |
16 class ActionBoxMenuModel; | 11 class ActionBoxMenuModel; |
17 | 12 |
18 namespace views { | 13 namespace views { |
19 class Background; | 14 class MenuButton; |
20 class Border; | |
21 class MenuItemView; | |
22 class MenuRunner; | 15 class MenuRunner; |
23 class View; | |
24 } | 16 } |
25 | 17 |
26 // ActionBoxMenu adapts the ActionBoxMenuModel to view's menu related classes. | 18 // ActionBoxMenu adapts the ActionBoxMenuModel to view's menu related classes. |
27 class ActionBoxMenu : public views::MenuDelegate, | 19 class ActionBoxMenu : public views::MenuDelegate { |
28 public BrowserActionView::Delegate { | |
29 public: | 20 public: |
30 // Constructs and initializes an ActionBoxMenu. | 21 // Constructs and initializes an ActionBoxMenu. |
31 static scoped_ptr<ActionBoxMenu> Create( | 22 static scoped_ptr<ActionBoxMenu> Create(scoped_ptr<ActionBoxMenuModel> model); |
32 Browser* browser, | |
33 scoped_ptr<ActionBoxMenuModel> model); | |
34 | 23 |
35 virtual ~ActionBoxMenu(); | 24 virtual ~ActionBoxMenu(); |
36 | 25 |
37 // Shows the menu relative to the specified button. | 26 // Shows the menu relative to the specified button. |
38 void RunMenu(views::MenuButton* menu_button, gfx::Point menu_offset); | 27 void RunMenu(views::MenuButton* menu_button, gfx::Point menu_offset); |
39 | 28 |
40 private: | 29 private: |
41 ActionBoxMenu(Browser* browser, scoped_ptr<ActionBoxMenuModel> model); | 30 explicit ActionBoxMenu(scoped_ptr<ActionBoxMenuModel> model); |
42 | 31 |
43 // Overridden from views::MenuDelegate: | 32 // Overridden from views::MenuDelegate: |
44 virtual void ExecuteCommand(int id) OVERRIDE; | 33 virtual void ExecuteCommand(int id) OVERRIDE; |
45 | 34 |
46 // Overridden from BrowserActionView::Delegate and DragController overrides: | |
47 virtual void InspectPopup(ExtensionAction* button) OVERRIDE; | |
48 virtual int GetCurrentTabId() const OVERRIDE; | |
49 virtual void OnBrowserActionExecuted(BrowserActionButton* button) OVERRIDE; | |
50 virtual void OnBrowserActionVisibilityChanged() OVERRIDE; | |
51 virtual gfx::Point GetViewContentOffset() const OVERRIDE; | |
52 virtual bool NeedToShowMultipleIconStates() const OVERRIDE; | |
53 virtual bool NeedToShowTooltip() const OVERRIDE; | |
54 virtual void WriteDragDataForView(views::View* sender, | |
55 const gfx::Point& press_pt, | |
56 ui::OSExchangeData* data) OVERRIDE; | |
57 virtual int GetDragOperationsForView(views::View* sender, | |
58 const gfx::Point& p) OVERRIDE; | |
59 virtual bool CanStartDragForView(views::View* sender, | |
60 const gfx::Point& press_pt, | |
61 const gfx::Point& p) OVERRIDE; | |
62 | |
63 // Populates |root_| with all the child menu items from the |model_|. | 35 // Populates |root_| with all the child menu items from the |model_|. |
64 void PopulateMenu(); | 36 void PopulateMenu(); |
65 | 37 |
66 Browser* browser_; | |
67 | |
68 scoped_ptr<views::MenuRunner> menu_runner_; | 38 scoped_ptr<views::MenuRunner> menu_runner_; |
69 | 39 |
70 // The model that tracks the order of the toolbar icons. | 40 // The model that tracks the order of the toolbar icons. |
71 scoped_ptr<ActionBoxMenuModel> model_; | 41 scoped_ptr<ActionBoxMenuModel> model_; |
72 | 42 |
73 DISALLOW_COPY_AND_ASSIGN(ActionBoxMenu); | 43 DISALLOW_COPY_AND_ASSIGN(ActionBoxMenu); |
74 }; | 44 }; |
75 | 45 |
76 #endif // CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_ | 46 #endif // CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_ |
OLD | NEW |