| 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_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 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "components/bookmarks/browser/base_bookmark_model_observer.h" | 11 #include "components/bookmarks/browser/base_bookmark_model_observer.h" |
| 12 #include "components/bookmarks/browser/bookmark_node_data.h" | 12 #include "components/bookmarks/browser/bookmark_node_data.h" |
| 13 #include "ui/views/controls/menu/menu_delegate.h" | 13 #include "ui/views/controls/menu/menu_delegate.h" |
| 14 | 14 |
| 15 class BookmarkBarView; | 15 class BookmarkBarView; |
| 16 class BookmarkMenuControllerObserver; | 16 class BookmarkMenuControllerObserver; |
| 17 class BookmarkMenuDelegate; | 17 class BookmarkMenuDelegate; |
| 18 class Browser; |
| 19 |
| 20 namespace bookmarks { |
| 18 class BookmarkNode; | 21 class BookmarkNode; |
| 19 class Browser; | 22 } |
| 20 | 23 |
| 21 namespace content { | 24 namespace content { |
| 22 class PageNavigator; | 25 class PageNavigator; |
| 23 } | 26 } |
| 24 | 27 |
| 25 namespace ui { | 28 namespace ui { |
| 26 class OSExchangeData; | 29 class OSExchangeData; |
| 27 } | 30 } |
| 28 | 31 |
| 29 namespace views { | 32 namespace views { |
| 30 class MenuButton; | 33 class MenuButton; |
| 31 class MenuItemView; | 34 class MenuItemView; |
| 32 class MenuRunner; | 35 class MenuRunner; |
| 33 class Widget; | 36 class Widget; |
| 34 } | 37 } |
| 35 | 38 |
| 36 // BookmarkMenuController is responsible for showing a menu of bookmarks, | 39 // BookmarkMenuController is responsible for showing a menu of bookmarks, |
| 37 // each item in the menu represents a bookmark. | 40 // each item in the menu represents a bookmark. |
| 38 // BookmarkMenuController deletes itself as necessary, although the menu can | 41 // BookmarkMenuController deletes itself as necessary, although the menu can |
| 39 // be explicitly hidden by way of the Cancel method. | 42 // be explicitly hidden by way of the Cancel method. |
| 40 class BookmarkMenuController : public bookmarks::BaseBookmarkModelObserver, | 43 class BookmarkMenuController : public bookmarks::BaseBookmarkModelObserver, |
| 41 public views::MenuDelegate { | 44 public views::MenuDelegate { |
| 42 public: | 45 public: |
| 43 // Creates a BookmarkMenuController showing the children of |node| starting | 46 // Creates a BookmarkMenuController showing the children of |node| starting |
| 44 // at |start_child_index|. | 47 // at |start_child_index|. |
| 45 BookmarkMenuController(Browser* browser, | 48 BookmarkMenuController(Browser* browser, |
| 46 content::PageNavigator* page_navigator, | 49 content::PageNavigator* page_navigator, |
| 47 views::Widget* parent, | 50 views::Widget* parent, |
| 48 const BookmarkNode* node, | 51 const bookmarks::BookmarkNode* node, |
| 49 int start_child_index, | 52 int start_child_index, |
| 50 bool for_drop); | 53 bool for_drop); |
| 51 | 54 |
| 52 void RunMenuAt(BookmarkBarView* bookmark_bar); | 55 void RunMenuAt(BookmarkBarView* bookmark_bar); |
| 53 | 56 |
| 54 void clear_bookmark_bar() { | 57 void clear_bookmark_bar() { |
| 55 bookmark_bar_ = NULL; | 58 bookmark_bar_ = NULL; |
| 56 } | 59 } |
| 57 | 60 |
| 58 // Hides the menu. | 61 // Hides the menu. |
| 59 void Cancel(); | 62 void Cancel(); |
| 60 | 63 |
| 61 // Returns the node the menu is showing for. | 64 // Returns the node the menu is showing for. |
| 62 const BookmarkNode* node() const { return node_; } | 65 const bookmarks::BookmarkNode* node() const { return node_; } |
| 63 | 66 |
| 64 // Returns the menu. | 67 // Returns the menu. |
| 65 views::MenuItemView* menu() const; | 68 views::MenuItemView* menu() const; |
| 66 | 69 |
| 67 // Returns the context menu, or NULL if the context menu isn't showing. | 70 // Returns the context menu, or NULL if the context menu isn't showing. |
| 68 views::MenuItemView* context_menu() const; | 71 views::MenuItemView* context_menu() const; |
| 69 | 72 |
| 70 // Sets the page navigator. | 73 // Sets the page navigator. |
| 71 void SetPageNavigator(content::PageNavigator* navigator); | 74 void SetPageNavigator(content::PageNavigator* navigator); |
| 72 | 75 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 118 |
| 116 private: | 119 private: |
| 117 // BookmarkMenuController deletes itself as necessary. | 120 // BookmarkMenuController deletes itself as necessary. |
| 118 ~BookmarkMenuController() override; | 121 ~BookmarkMenuController() override; |
| 119 | 122 |
| 120 scoped_ptr<views::MenuRunner> menu_runner_; | 123 scoped_ptr<views::MenuRunner> menu_runner_; |
| 121 | 124 |
| 122 scoped_ptr<BookmarkMenuDelegate> menu_delegate_; | 125 scoped_ptr<BookmarkMenuDelegate> menu_delegate_; |
| 123 | 126 |
| 124 // The node we're showing the contents of. | 127 // The node we're showing the contents of. |
| 125 const BookmarkNode* node_; | 128 const bookmarks::BookmarkNode* node_; |
| 126 | 129 |
| 127 // Data for the drop. | 130 // Data for the drop. |
| 128 bookmarks::BookmarkNodeData drop_data_; | 131 bookmarks::BookmarkNodeData drop_data_; |
| 129 | 132 |
| 130 // The observer, may be null. | 133 // The observer, may be null. |
| 131 BookmarkMenuControllerObserver* observer_; | 134 BookmarkMenuControllerObserver* observer_; |
| 132 | 135 |
| 133 // Is the menu being shown for a drop? | 136 // Is the menu being shown for a drop? |
| 134 bool for_drop_; | 137 bool for_drop_; |
| 135 | 138 |
| 136 // The bookmark bar. This is only non-null if we're showing a menu item for a | 139 // The bookmark bar. This is only non-null if we're showing a menu item for a |
| 137 // folder on the bookmark bar and not for drop, or if the BookmarkBarView has | 140 // folder on the bookmark bar and not for drop, or if the BookmarkBarView has |
| 138 // been destroyed before the menu. | 141 // been destroyed before the menu. |
| 139 BookmarkBarView* bookmark_bar_; | 142 BookmarkBarView* bookmark_bar_; |
| 140 | 143 |
| 141 DISALLOW_COPY_AND_ASSIGN(BookmarkMenuController); | 144 DISALLOW_COPY_AND_ASSIGN(BookmarkMenuController); |
| 142 }; | 145 }; |
| 143 | 146 |
| 144 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_MENU_CONTROLLER_VIEWS_H_ | 147 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_MENU_CONTROLLER_VIEWS_H_ |
| OLD | NEW |