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/views/bookmark_menu_controller_views.h" | |
11 #include "views/controls/button/menu_button.h" | |
12 #include "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 GetDropFormats( | |
30 int* formats, | |
31 std::set<OSExchangeData::CustomFormat>* custom_formats); | |
32 virtual bool AreDropTypesRequired(); | |
33 virtual bool CanDrop(const OSExchangeData& data); | |
34 virtual int OnDragUpdated(const views::DropTargetEvent& event); | |
35 virtual void OnDragExited(); | |
36 virtual int OnPerformDrop(const views::DropTargetEvent& event); | |
37 | |
38 // BookmarkMenuController::Observer. | |
39 virtual void BookmarkMenuDeleted(BookmarkMenuController* controller); | |
40 | |
41 // ViewMenuDelegate. | |
42 virtual void RunMenu(views::View* source, const gfx::Point& pt); | |
43 | |
44 private: | |
45 // Shows the menu. | |
46 void RunMenu(views::View* source, | |
47 const gfx::Point& pt, | |
48 gfx::NativeWindow hwnd, | |
49 bool for_drop); | |
50 | |
51 // Returns the bookmark model. | |
52 BookmarkModel* GetBookmarkModel(); | |
53 | |
54 // Starts the timer for showing the drop menu if it isn't running. | |
55 void StartShowFolderDropMenuTimer(); | |
56 | |
57 // Stops the timer for showing the drop menu. | |
58 void StopShowFolderDropMenuTimer(); | |
59 | |
60 // Shows the drop menu. | |
61 void ShowDropMenu(); | |
62 | |
63 // Browser used to determine profile for showing bookmarks from. | |
64 Browser* browser_; | |
65 | |
66 // Contents of current drag. | |
67 BookmarkDragData drag_data_; | |
68 | |
69 // Menu shown during drag and drop. | |
70 BookmarkMenuController* bookmark_drop_menu_; | |
71 | |
72 // Drop operation for current drop. | |
73 int drop_operation_; | |
74 | |
75 // Timer used for showing the drop menu. | |
76 base::OneShotTimer<BookmarkMenuButton> show_drop_menu_timer_; | |
77 | |
78 DISALLOW_COPY_AND_ASSIGN(BookmarkMenuButton); | |
79 }; | |
80 | |
81 #endif // CHROME_BROWSER_VIEWS_BOOKMARK_MENU_BUTTON_H_ | |
OLD | NEW |