| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_GTK_BOOKMARK_CONTEXT_MENU_H_ | 5 #ifndef CHROME_BROWSER_GTK_BOOKMARK_CONTEXT_MENU_H_ |
| 6 #define CHROME_BROWSER_GTK_BOOKMARK_CONTEXT_MENU_H_ | 6 #define CHROME_BROWSER_GTK_BOOKMARK_CONTEXT_MENU_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // Used when the source is the table in the bookmark manager and the table | 43 // Used when the source is the table in the bookmark manager and the table |
| 44 // is showing recently bookmarked or searched. | 44 // is showing recently bookmarked or searched. |
| 45 BOOKMARK_MANAGER_TABLE_OTHER, | 45 BOOKMARK_MANAGER_TABLE_OTHER, |
| 46 BOOKMARK_MANAGER_TREE, | 46 BOOKMARK_MANAGER_TREE, |
| 47 BOOKMARK_MANAGER_ORGANIZE_MENU, | 47 BOOKMARK_MANAGER_ORGANIZE_MENU, |
| 48 // Used when the source is the bookmark manager and the table is showing | 48 // Used when the source is the bookmark manager and the table is showing |
| 49 // recently bookmarked or searched. | 49 // recently bookmarked or searched. |
| 50 BOOKMARK_MANAGER_ORGANIZE_MENU_OTHER | 50 BOOKMARK_MANAGER_ORGANIZE_MENU_OTHER |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 class Delegate { |
| 54 public: |
| 55 // Called when one of the menu items is selected and executed. |
| 56 virtual void WillExecuteCommand() = 0; |
| 57 }; |
| 58 |
| 53 // Creates the bookmark context menu. | 59 // Creates the bookmark context menu. |
| 54 // |profile| is used for opening urls as well as enabling 'open incognito'. | 60 // |profile| is used for opening urls as well as enabling 'open incognito'. |
| 55 // |browser| is used to determine the PageNavigator and may be null. | 61 // |browser| is used to determine the PageNavigator and may be null. |
| 56 // |navigator| is used if |browser| is null, and is provided for testing. | 62 // |navigator| is used if |browser| is null, and is provided for testing. |
| 57 // |parent| is the parent for newly created nodes if |selection| is empty. | 63 // |parent| is the parent for newly created nodes if |selection| is empty. |
| 58 // |selection| is the nodes the context menu operates on and may be empty. | 64 // |selection| is the nodes the context menu operates on and may be empty. |
| 59 // |configuration| determines which items to show. | 65 // |configuration| determines which items to show. |
| 60 BookmarkContextMenu(gfx::NativeView hwnd, | 66 BookmarkContextMenu(gfx::NativeView hwnd, |
| 61 Profile* profile, | 67 Profile* profile, |
| 62 Browser* browser, | 68 Browser* browser, |
| 63 PageNavigator* navigator, | 69 PageNavigator* navigator, |
| 64 const BookmarkNode* parent, | 70 const BookmarkNode* parent, |
| 65 const std::vector<const BookmarkNode*>& selection, | 71 const std::vector<const BookmarkNode*>& selection, |
| 66 ConfigurationType configuration); | 72 ConfigurationType configuration, |
| 73 Delegate* delegate); |
| 67 virtual ~BookmarkContextMenu(); | 74 virtual ~BookmarkContextMenu(); |
| 68 | 75 |
| 69 #if defined(TOOLKIT_VIEWS) | 76 #if defined(TOOLKIT_VIEWS) |
| 70 // Shows the menu at the specified place. | 77 // Shows the menu at the specified place. |
| 71 void RunMenuAt(int x, int y); | 78 void RunMenuAt(int x, int y); |
| 72 | 79 |
| 73 // Returns the menu. | 80 // Returns the menu. |
| 74 views::MenuItemView* menu() const { return menu_.get(); } | 81 views::MenuItemView* menu() const { return menu_.get(); } |
| 75 #elif defined(OS_LINUX) | 82 #elif defined(OS_LINUX) |
| 76 // Pops up this menu. This call doesn't block. | 83 // Pops up this menu. This call doesn't block. |
| 77 void PopupAsContext(guint32 event_time); | 84 void PopupAsContext(guint32 event_time); |
| 78 | 85 |
| 79 // Returns the menu. | 86 // Returns the menu. |
| 80 GtkWidget* menu() const { return menu_->widget(); } | 87 GtkWidget* menu() const { return menu_->widget(); } |
| 81 #endif | 88 #endif |
| 82 | 89 |
| 90 // Should be called by the delegate when it is no longer valid. |
| 91 void DelegateDestroyed(); |
| 92 |
| 83 // Menu::Delegate / MenuGtk::Delegate methods. | 93 // Menu::Delegate / MenuGtk::Delegate methods. |
| 84 virtual void ExecuteCommand(int id); | 94 virtual void ExecuteCommand(int id); |
| 85 virtual bool IsItemChecked(int id) const; | 95 virtual bool IsItemChecked(int id) const; |
| 86 virtual bool IsCommandEnabled(int id) const; | 96 virtual bool IsCommandEnabled(int id) const; |
| 87 | 97 |
| 88 private: | 98 private: |
| 89 // BookmarkModelObserver method. Any change to the model results in closing | 99 // BookmarkModelObserver method. Any change to the model results in closing |
| 90 // the menu. | 100 // the menu. |
| 91 virtual void Loaded(BookmarkModel* model) {} | 101 virtual void Loaded(BookmarkModel* model) {} |
| 92 virtual void BookmarkModelBeingDeleted(BookmarkModel* model); | 102 virtual void BookmarkModelBeingDeleted(BookmarkModel* model); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 const BookmarkNode* GetParentForNewNodes() const; | 146 const BookmarkNode* GetParentForNewNodes() const; |
| 137 | 147 |
| 138 gfx::NativeView wnd_; | 148 gfx::NativeView wnd_; |
| 139 Profile* profile_; | 149 Profile* profile_; |
| 140 Browser* browser_; | 150 Browser* browser_; |
| 141 PageNavigator* navigator_; | 151 PageNavigator* navigator_; |
| 142 const BookmarkNode* parent_; | 152 const BookmarkNode* parent_; |
| 143 std::vector<const BookmarkNode*> selection_; | 153 std::vector<const BookmarkNode*> selection_; |
| 144 BookmarkModel* model_; | 154 BookmarkModel* model_; |
| 145 ConfigurationType configuration_; | 155 ConfigurationType configuration_; |
| 156 Delegate* delegate_; |
| 146 | 157 |
| 147 #if defined(OS_WIN) || defined(TOOLKIT_VIEWS) | 158 #if defined(OS_WIN) || defined(TOOLKIT_VIEWS) |
| 148 scoped_ptr<views::MenuItemView> menu_; | 159 scoped_ptr<views::MenuItemView> menu_; |
| 149 #elif defined(OS_LINUX) | 160 #elif defined(OS_LINUX) |
| 150 scoped_ptr<MenuGtk> menu_; | 161 scoped_ptr<MenuGtk> menu_; |
| 151 #endif | 162 #endif |
| 152 | 163 |
| 153 DISALLOW_COPY_AND_ASSIGN(BookmarkContextMenu); | 164 DISALLOW_COPY_AND_ASSIGN(BookmarkContextMenu); |
| 154 }; | 165 }; |
| 155 | 166 |
| 156 #endif // CHROME_BROWSER_GTK_BOOKMARK_CONTEXT_MENU_H_ | 167 #endif // CHROME_BROWSER_GTK_BOOKMARK_CONTEXT_MENU_H_ |
| OLD | NEW |