OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BOOKMARKS_BOOKMARK_MENU_CONTROLLER_VIEWS_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_MENU_CONTROLLER_VIEWS_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_MENU_CONTROLLER_VIEWS_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_MENU_CONTROLLER_VIEWS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 namespace gfx { | 22 namespace gfx { |
23 class Rect; | 23 class Rect; |
24 } // namespace gfx | 24 } // namespace gfx |
25 | 25 |
26 namespace ui { | 26 namespace ui { |
27 class OSExchangeData; | 27 class OSExchangeData; |
28 } // namespace ui | 28 } // namespace ui |
29 | 29 |
30 namespace views { | 30 namespace views { |
31 class MenuButton; | 31 class MenuButton; |
| 32 class MenuRunner; |
32 class Widget; | 33 class Widget; |
33 } // namespace views | 34 } // namespace views |
34 | 35 |
35 // BookmarkMenuController is responsible for showing a menu of bookmarks, | 36 // BookmarkMenuController is responsible for showing a menu of bookmarks, |
36 // each item in the menu represents a bookmark. | 37 // each item in the menu represents a bookmark. |
37 // BookmarkMenuController deletes itself as necessary, although the menu can | 38 // BookmarkMenuController deletes itself as necessary, although the menu can |
38 // be explicitly hidden by way of the Cancel method. | 39 // be explicitly hidden by way of the Cancel method. |
39 class BookmarkMenuController : public BaseBookmarkModelObserver, | 40 class BookmarkMenuController : public BaseBookmarkModelObserver, |
40 public views::MenuDelegate { | 41 public views::MenuDelegate { |
41 public: | 42 public: |
42 // The observer is notified prior to the menu being deleted. | 43 // The observer is notified prior to the menu being deleted. |
43 class Observer { | 44 class Observer { |
44 public: | 45 public: |
45 virtual void BookmarkMenuDeleted(BookmarkMenuController* controller) = 0; | 46 virtual void BookmarkMenuDeleted(BookmarkMenuController* controller) = 0; |
46 | 47 |
47 protected: | 48 protected: |
48 virtual ~Observer() {} | 49 virtual ~Observer() {} |
49 }; | 50 }; |
50 | 51 |
51 // Creates a BookmarkMenuController showing the children of |node| starting | 52 // Creates a BookmarkMenuController showing the children of |node| starting |
52 // at |start_child_index|. | 53 // at |start_child_index|. |
53 BookmarkMenuController(Profile* profile, | 54 BookmarkMenuController(Profile* profile, |
54 PageNavigator* page_navigator, | 55 PageNavigator* page_navigator, |
55 views::Widget* parent, | 56 views::Widget* parent, |
56 const BookmarkNode* node, | 57 const BookmarkNode* node, |
57 int start_child_index); | 58 int start_child_index); |
58 | 59 |
59 void RunMenuAt(BookmarkBarView* bookmark_bar, bool for_drop); | 60 void RunMenuAt(BookmarkBarView* bookmark_bar, bool for_drop); |
60 | 61 |
61 // Shows the menu. | |
62 void RunMenuAt(views::MenuButton* button, | |
63 views::MenuItemView::AnchorPosition position, | |
64 bool for_drop); | |
65 | |
66 // Hides the menu. | 62 // Hides the menu. |
67 void Cancel(); | 63 void Cancel(); |
68 | 64 |
69 // Returns the node the menu is showing for. | 65 // Returns the node the menu is showing for. |
70 const BookmarkNode* node() const { return node_; } | 66 const BookmarkNode* node() const { return node_; } |
71 | 67 |
72 // Returns the menu. | 68 // Returns the menu. |
73 views::MenuItemView* menu() const; | 69 views::MenuItemView* menu() const; |
74 | 70 |
75 // Returns the context menu, or NULL if the context menu isn't showing. | 71 // Returns the context menu, or NULL if the context menu isn't showing. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 views::MenuButton** button); | 108 views::MenuButton** button); |
113 virtual int GetMaxWidthForMenu(views::MenuItemView* view); | 109 virtual int GetMaxWidthForMenu(views::MenuItemView* view); |
114 | 110 |
115 // BookmarkModelObserver methods. | 111 // BookmarkModelObserver methods. |
116 virtual void BookmarkModelChanged(); | 112 virtual void BookmarkModelChanged(); |
117 | 113 |
118 private: | 114 private: |
119 // BookmarkMenuController deletes itself as necessary. | 115 // BookmarkMenuController deletes itself as necessary. |
120 virtual ~BookmarkMenuController(); | 116 virtual ~BookmarkMenuController(); |
121 | 117 |
| 118 scoped_ptr<views::MenuRunner> menu_runner_; |
| 119 |
122 scoped_ptr<BookmarkMenuDelegate> menu_delegate_; | 120 scoped_ptr<BookmarkMenuDelegate> menu_delegate_; |
123 | 121 |
124 // The node we're showing the contents of. | 122 // The node we're showing the contents of. |
125 const BookmarkNode* node_; | 123 const BookmarkNode* node_; |
126 | 124 |
127 // Data for the drop. | 125 // Data for the drop. |
128 BookmarkNodeData drop_data_; | 126 BookmarkNodeData drop_data_; |
129 | 127 |
130 // The observer, may be null. | 128 // The observer, may be null. |
131 Observer* observer_; | 129 Observer* observer_; |
132 | 130 |
133 // Is the menu being shown for a drop? | 131 // Is the menu being shown for a drop? |
134 bool for_drop_; | 132 bool for_drop_; |
135 | 133 |
136 // The bookmark bar. This is only non-null if we're showing a menu item | 134 // The bookmark bar. This is only non-null if we're showing a menu item |
137 // for a folder on the bookmark bar and not for drop. | 135 // for a folder on the bookmark bar and not for drop. |
138 BookmarkBarView* bookmark_bar_; | 136 BookmarkBarView* bookmark_bar_; |
139 | 137 |
140 DISALLOW_COPY_AND_ASSIGN(BookmarkMenuController); | 138 DISALLOW_COPY_AND_ASSIGN(BookmarkMenuController); |
141 }; | 139 }; |
142 | 140 |
143 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_MENU_CONTROLLER_VIEWS_H_ | 141 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_MENU_CONTROLLER_VIEWS_H_ |
OLD | NEW |