Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6698)

Unified Diff: chrome/browser/ui/views/wrench_menu.h

Issue 7054020: Refactors code for showing bookmark menus so that it can be used by (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc ('k') | chrome/browser/ui/views/wrench_menu.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/wrench_menu.h
===================================================================
--- chrome/browser/ui/views/wrench_menu.h (revision 86142)
+++ chrome/browser/ui/views/wrench_menu.h (working copy)
@@ -11,9 +11,11 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/bookmarks/base_bookmark_model_observer.h"
#include "ui/base/models/menu_model.h"
#include "views/controls/menu/menu_delegate.h"
+class BookmarkMenuDelegate;
class Browser;
namespace views {
@@ -24,7 +26,8 @@
// WrenchMenu adapts the WrenchMenuModel to view's menu related classes.
class WrenchMenu : public base::RefCounted<WrenchMenu>,
- public views::MenuDelegate {
+ public views::MenuDelegate,
+ public BaseBookmarkModelObserver {
public:
explicit WrenchMenu(Browser* browser);
@@ -34,11 +37,40 @@
void RunMenu(views::MenuButton* host);
// MenuDelegate overrides:
- virtual bool IsItemChecked(int id) const;
- virtual bool IsCommandEnabled(int id) const;
- virtual void ExecuteCommand(int id);
- virtual bool GetAccelerator(int id, views::Accelerator* accelerator);
+ virtual std::wstring GetTooltipText(int id, const gfx::Point& p) OVERRIDE;
+ virtual bool IsTriggerableEvent(views::MenuItemView* menu,
+ const views::MouseEvent& e) OVERRIDE;
+ virtual bool GetDropFormats(
+ views::MenuItemView* menu,
+ int* formats,
+ std::set<ui::OSExchangeData::CustomFormat>* custom_formats) OVERRIDE;
+ virtual bool AreDropTypesRequired(views::MenuItemView* menu) OVERRIDE;
+ virtual bool CanDrop(views::MenuItemView* menu,
+ const ui::OSExchangeData& data) OVERRIDE;
+ virtual int GetDropOperation(views::MenuItemView* item,
+ const views::DropTargetEvent& event,
+ DropPosition* position) OVERRIDE;
+ virtual int OnPerformDrop(views::MenuItemView* menu,
+ DropPosition position,
+ const views::DropTargetEvent& event) OVERRIDE;
+ virtual bool ShowContextMenu(views::MenuItemView* source,
+ int id,
+ const gfx::Point& p,
+ bool is_mouse_gesture) OVERRIDE;
+ virtual bool CanDrag(views::MenuItemView* menu) OVERRIDE;
+ virtual void WriteDragData(views::MenuItemView* sender,
+ ui::OSExchangeData* data) OVERRIDE;
+ virtual int GetDragOperations(views::MenuItemView* sender) OVERRIDE;
+ virtual int GetMaxWidthForMenu(views::MenuItemView* menu) OVERRIDE;
+ virtual bool IsItemChecked(int id) const OVERRIDE;
+ virtual bool IsCommandEnabled(int id) const OVERRIDE;
+ virtual void ExecuteCommand(int id, int mouse_event_flags) OVERRIDE;
+ virtual bool GetAccelerator(int id, views::Accelerator* accelerator) OVERRIDE;
+ virtual void WillShowMenu(views::MenuItemView* menu) OVERRIDE;
+ // BaseBookmarkModelObserver overrides:
+ virtual void BookmarkModelChanged() OVERRIDE;
+
private:
friend class base::RefCounted<WrenchMenu>;
@@ -69,6 +101,15 @@
// activates the menu item in |model| at |index|.
void CancelAndEvaluate(ui::MenuModel* model, int index);
+ // Creates the bookmark menu if necessary. Does nothing if already created or
+ // the bookmark model isn't loaded.
+ void CreateBookmarkMenu();
+
+ // Returns true if |id| identifies a bookmark menu item.
+ bool is_bookmark_command(int id) const {
+ return bookmark_menu_delegate_.get() && id >= first_bookmark_command_id_;
+ }
+
// The views menu.
scoped_ptr<views::MenuItemView> root_;
@@ -86,6 +127,15 @@
ui::MenuModel* selected_menu_model_;
int selected_index_;
+ // Used for managing the bookmark menu items.
+ scoped_ptr<BookmarkMenuDelegate> bookmark_menu_delegate_;
+
+ // Menu corresponding to IDC_BOOKMARKS_MENU.
+ views::MenuItemView* bookmark_menu_;
+
+ // ID to use for the items representing bookmarks in the bookmark menu.
+ int first_bookmark_command_id_;
+
DISALLOW_COPY_AND_ASSIGN(WrenchMenu);
};
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc ('k') | chrome/browser/ui/views/wrench_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698