OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 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_VIEWS_BOOKMARK_MENU_BUTTON_H_ |
| 6 #define CHROME_BROWSER_VIEWS_BOOKMARK_MENU_BUTTON_H_ |
| 7 |
| 8 #include "base/timer.h" |
| 9 #include "chrome/browser/bookmarks/bookmark_drag_data.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_menu_controller.h" |
| 11 #include "chrome/views/controls/button/menu_button.h" |
| 12 #include "chrome/views/controls/menu/view_menu_delegate.h" |
| 13 |
| 14 class BookmarkModel; |
| 15 class Browser; |
| 16 |
| 17 // BookmarkMenuButton is the button on the toolbar that when clicked shows |
| 18 // all bookmarks in a menu. Additionally users can drag bookmarks over the |
| 19 // button to have the menu appear. |
| 20 |
| 21 class BookmarkMenuButton : public views::MenuButton, |
| 22 public BookmarkMenuController::Observer, |
| 23 public views::ViewMenuDelegate { |
| 24 public: |
| 25 explicit BookmarkMenuButton(Browser* browser); |
| 26 virtual ~BookmarkMenuButton(); |
| 27 |
| 28 // View drop methods. |
| 29 virtual bool CanDrop(const OSExchangeData& data); |
| 30 virtual int OnDragUpdated(const views::DropTargetEvent& event); |
| 31 virtual void OnDragExited(); |
| 32 virtual int OnPerformDrop(const views::DropTargetEvent& event); |
| 33 |
| 34 // BookmarkMenuController::Observer. |
| 35 virtual void BookmarkMenuDeleted(BookmarkMenuController* controller); |
| 36 |
| 37 // ViewMenuDelegate. |
| 38 virtual void RunMenu(views::View* source, |
| 39 const CPoint& pt, |
| 40 gfx::NativeView hwnd); |
| 41 |
| 42 private: |
| 43 // Shows the menu. |
| 44 void RunMenu(views::View* source, |
| 45 const CPoint& pt, |
| 46 gfx::NativeView hwnd, |
| 47 bool for_drop); |
| 48 |
| 49 // Returns the bookmark model. |
| 50 BookmarkModel* GetBookmarkModel(); |
| 51 |
| 52 // If the timer for showing the drop menu isn't running, it's started. |
| 53 void StartShowFolderDropMenuTimer(); |
| 54 |
| 55 // Stops the timer for showing the drop menu. |
| 56 void StopShowFolderDropMenuTimer(); |
| 57 |
| 58 // Shows the drop menu. |
| 59 void ShowDropMenu(); |
| 60 |
| 61 // Browser used to determine profile for showing bookmarks from. |
| 62 Browser* browser_; |
| 63 |
| 64 // Contents of current drag. |
| 65 BookmarkDragData drag_data_; |
| 66 |
| 67 // Menu shown during drag and drop. |
| 68 BookmarkMenuController* bookmark_drop_menu_; |
| 69 |
| 70 // Drop operation for current drop. |
| 71 int drop_operation_; |
| 72 |
| 73 // Timer used for showing the drop menu. |
| 74 base::OneShotTimer<BookmarkMenuButton> show_drop_menu_timer_; |
| 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(BookmarkMenuButton); |
| 77 }; |
| 78 |
| 79 #endif // CHROME_BROWSER_VIEWS_BOOKMARK_MENU_BUTTON_H_ |
OLD | NEW |