Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / views / bookmarks / bookmark_context_menu.h
blobb90099afc955d8723dce012fb4f418253b8ae17a
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.
5 #ifndef CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_CONTEXT_MENU_H_
6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_CONTEXT_MENU_H_
8 #include "base/compiler_specific.h"
9 #include "chrome/browser/ui/bookmarks/bookmark_context_menu_controller.h"
10 #include "ui/views/controls/menu/menu_delegate.h"
12 class Browser;
14 namespace views {
15 class MenuRunner;
16 class Widget;
19 // Observer for the BookmarkContextMenu.
20 class BookmarkContextMenuObserver {
21 public:
22 // Invoked before the specified items are removed from the bookmark model.
23 virtual void WillRemoveBookmarks(
24 const std::vector<const bookmarks::BookmarkNode*>& bookmarks) = 0;
26 // Invoked after the items have been removed from the model.
27 virtual void DidRemoveBookmarks() = 0;
29 protected:
30 virtual ~BookmarkContextMenuObserver() {}
33 class BookmarkContextMenu : public BookmarkContextMenuControllerDelegate,
34 public views::MenuDelegate {
35 public:
36 // |browser| is used to open the bookmark manager, and is NULL in tests.
37 BookmarkContextMenu(
38 views::Widget* parent_widget,
39 Browser* browser,
40 Profile* profile,
41 content::PageNavigator* page_navigator,
42 const bookmarks::BookmarkNode* parent,
43 const std::vector<const bookmarks::BookmarkNode*>& selection,
44 bool close_on_remove);
45 ~BookmarkContextMenu() override;
47 // Shows the context menu at the specified point.
48 void RunMenuAt(const gfx::Point& point,
49 ui::MenuSourceType source_type);
51 views::MenuItemView* menu() const { return menu_; }
53 void set_observer(BookmarkContextMenuObserver* observer) {
54 observer_ = observer;
57 // Sets the PageNavigator.
58 void SetPageNavigator(content::PageNavigator* navigator);
60 // Overridden from views::MenuDelegate:
61 void ExecuteCommand(int command_id, int event_flags) override;
62 bool IsItemChecked(int command_id) const override;
63 bool IsCommandEnabled(int command_id) const override;
64 bool IsCommandVisible(int command_id) const override;
65 bool ShouldCloseAllMenusOnExecute(int id) override;
67 // Overridden from BookmarkContextMenuControllerDelegate:
68 void CloseMenu() override;
69 void WillExecuteCommand(
70 int command_id,
71 const std::vector<const bookmarks::BookmarkNode*>& bookmarks) override;
72 void DidExecuteCommand(int command_id) override;
74 private:
75 scoped_ptr<BookmarkContextMenuController> controller_;
77 // The parent of dialog boxes opened from the context menu.
78 views::Widget* parent_widget_;
80 // The menu itself. This is owned by |menu_runner_|.
81 views::MenuItemView* menu_;
83 // Responsible for running the menu.
84 scoped_ptr<views::MenuRunner> menu_runner_;
86 BookmarkContextMenuObserver* observer_;
88 // Should the menu close when a node is removed.
89 bool close_on_remove_;
91 DISALLOW_COPY_AND_ASSIGN(BookmarkContextMenu);
94 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_CONTEXT_MENU_H_