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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_CONTEXT_MENU_H_ 6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_CONTEXT_MENU_H_ 7 #pragma once 8 9 #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_views.h" 10 #include "views/controls/menu/menu_delegate.h" 11 12 // Observer for the BookmarkContextMenu. 13 class BookmarkContextMenuObserver { 14 public: 15 // Invoked before the specified items are removed from the bookmark model. 16 virtual void WillRemoveBookmarks( 17 const std::vector<const BookmarkNode*>& bookmarks) = 0; 18 19 // Invoked after the items have been removed from the model. 20 virtual void DidRemoveBookmarks() = 0; 21 22 protected: 23 virtual ~BookmarkContextMenuObserver() {} 24 }; 25 26 class BookmarkContextMenu : public BookmarkContextMenuControllerViewsDelegate, 27 public views::MenuDelegate { 28 public: 29 BookmarkContextMenu( 30 gfx::NativeWindow parent_window, 31 Profile* profile, 32 PageNavigator* page_navigator, 33 const BookmarkNode* parent, 34 const std::vector<const BookmarkNode*>& selection); 35 virtual ~BookmarkContextMenu(); 36 37 // Shows the context menu at the specified point. 38 void RunMenuAt(const gfx::Point& point); 39 40 views::MenuItemView* menu() const { return menu_.get(); } 41 42 void set_observer(BookmarkContextMenuObserver* observer) { 43 observer_ = observer; 44 } 45 46 // Overridden from views::MenuDelegate: 47 virtual void ExecuteCommand(int command_id); 48 virtual bool IsItemChecked(int command_id) const; 49 virtual bool IsCommandEnabled(int command_id) const; 50 virtual bool ShouldCloseAllMenusOnExecute(int id); 51 52 // Overridden from BookmarkContextMenuControllerViewsDelegate: 53 virtual void CloseMenu(); 54 virtual void AddItemWithStringId(int command_id, int string_id); 55 virtual void AddSeparator(); 56 virtual void AddCheckboxItem(int command_id, int string_id); 57 virtual void WillRemoveBookmarks( 58 const std::vector<const BookmarkNode*>& bookmarks); 59 virtual void DidRemoveBookmarks(); 60 61 private: 62 scoped_ptr<BookmarkContextMenuControllerViews> controller_; 63 64 // The parent of dialog boxes opened from the context menu. 65 gfx::NativeWindow parent_window_; 66 67 // The menu itself. 68 scoped_ptr<views::MenuItemView> menu_; 69 70 // The node we're showing the menu for. 71 const BookmarkNode* parent_node_; 72 73 BookmarkContextMenuObserver* observer_; 74 75 DISALLOW_COPY_AND_ASSIGN(BookmarkContextMenu); 76 }; 77 78 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_CONTEXT_MENU_H_ 79