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/scoped_ptr.h" | |
11 #include "base/memory/scoped_vector.h" | |
12 #include "chrome/browser/ui/views/browser_action_view.h" | |
13 #include "content/public/browser/notification_observer.h" | |
14 #include "ui/views/controls/menu/menu_delegate.h" | |
15 | |
16 class ActionBoxMenuModel; | |
17 | |
18 namespace views { | |
19 class Background; | |
20 class Border; | |
21 class MenuItemView; | |
22 class MenuRunner; | |
23 class View; | |
24 } | |
25 | |
26 // ActionBoxMenu adapts the ActionBoxMenuModel to view's menu related classes. | |
27 class ActionBoxMenu : public views::MenuDelegate, | |
28 public BrowserActionView::Delegate, | |
29 public content::NotificationObserver { | |
30 public: | |
31 ActionBoxMenu(Browser* browser, | |
32 ActionBoxMenuModel* model, | |
33 bool bookmark_item_state); | |
34 virtual ~ActionBoxMenu(); | |
35 | |
36 void Init(); | |
37 | |
38 // Shows the menu relative to the specified button. | |
39 void RunMenu(views::MenuButton* menu_button); | |
40 | |
41 private: | |
42 // Overridden from views::MenuDelegate: | |
43 virtual void ExecuteCommand(int id) OVERRIDE; | |
44 virtual views::Border* CreateMenuBorder() OVERRIDE; | |
45 virtual views::Background* CreateMenuBackground() OVERRIDE; | |
46 | |
47 // Overridden from BrowserActionView::Delegate and DragController overrides: | |
48 virtual int GetCurrentTabId() const OVERRIDE; | |
49 virtual void OnBrowserActionExecuted(BrowserActionButton* button) OVERRIDE; | |
50 virtual void OnBrowserActionVisibilityChanged() OVERRIDE; | |
51 virtual gfx::Size GetViewContentOffset() const OVERRIDE; | |
52 virtual void WriteDragDataForView(views::View* sender, | |
53 const gfx::Point& press_pt, | |
54 ui::OSExchangeData* data) OVERRIDE; | |
55 virtual int GetDragOperationsForView(views::View* sender, | |
56 const gfx::Point& p) OVERRIDE; | |
57 virtual bool CanStartDragForView(views::View* sender, | |
58 const gfx::Point& press_pt, | |
59 const gfx::Point& p) OVERRIDE; | |
60 | |
61 // NotificationObserver overrides: | |
62 virtual void Observe(int type, | |
63 const content::NotificationSource& source, | |
64 const content::NotificationDetails& details) OVERRIDE; | |
65 | |
66 // Adds a new bookmark menu item to the menu, |next_id| is incremented. | |
67 views::MenuItemView* AddBookmarkMenuItem(views::MenuItemView* parent, | |
68 int* next_id); | |
69 | |
70 // Populates |root_| with all the child menu items from the |model_|. | |
71 void PopulateMenu(); | |
72 | |
73 Browser* browser_; | |
74 | |
75 // The views menu. Owned by |menu_runner_|. | |
76 views::MenuItemView* root_; | |
77 | |
78 scoped_ptr<views::MenuRunner> menu_runner_; | |
79 | |
80 // The model that tracks the order of the toolbar icons. | |
81 ActionBoxMenuModel* model_; | |
82 | |
83 // Set to true when bookmark icon need to show bookmarked state. | |
msw
2012/07/25 23:02:03
nit: "the bookmark icon" and s/need/needs.
yefimt
2012/07/31 00:10:11
Done.
| |
84 bool bookmark_item_state_; | |
Peter Kasting
2012/07/26 20:37:17
Nit: For consistency with the rest of the codebase
yefimt
2012/07/31 00:10:11
Done.
| |
85 | |
86 ScopedVector<BrowserActionView> browser_action_views_; | |
87 | |
88 DISALLOW_COPY_AND_ASSIGN(ActionBoxMenu); | |
89 }; | |
90 | |
91 #endif // CHROME_BROWSER_UI_VIEWS_ACTION_BOX_MENU_H_ | |
OLD | NEW |