Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / views / bookmarks / bookmark_context_menu.h
blobeba85f646ea7452543e20ae0fb670ada548595b2
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 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 BookmarkNode* parent,
43 const std::vector<const BookmarkNode*>& selection,
44 bool close_on_remove);
45 virtual ~BookmarkContextMenu();
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 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
62 virtual bool IsItemChecked(int command_id) const OVERRIDE;
63 virtual bool IsCommandEnabled(int command_id) const OVERRIDE;
64 virtual bool ShouldCloseAllMenusOnExecute(int id) OVERRIDE;
66 // Overridden from BookmarkContextMenuControllerDelegate:
67 virtual void CloseMenu() OVERRIDE;
68 virtual void WillExecuteCommand(
69 int command_id,
70 const std::vector<const BookmarkNode*>& bookmarks) OVERRIDE;
71 virtual void DidExecuteCommand(int command_id) OVERRIDE;
73 private:
74 scoped_ptr<BookmarkContextMenuController> controller_;
76 // The parent of dialog boxes opened from the context menu.
77 views::Widget* parent_widget_;
79 // The menu itself. This is owned by |menu_runner_|.
80 views::MenuItemView* menu_;
82 // Responsible for running the menu.
83 scoped_ptr<views::MenuRunner> menu_runner_;
85 // The node we're showing the menu for.
86 const BookmarkNode* parent_node_;
88 BookmarkContextMenuObserver* observer_;
90 // Should the menu close when a node is removed.
91 bool close_on_remove_;
93 DISALLOW_COPY_AND_ASSIGN(BookmarkContextMenu);
96 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_CONTEXT_MENU_H_