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

Side by Side Diff: chrome/browser/ui/views/wrench_menu.h

Issue 8201006: Views: Rebuild wrench menu if error is added or removed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/toolbar_view.cc ('k') | chrome/browser/ui/views/wrench_menu.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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_UI_VIEWS_WRENCH_MENU_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_WRENCH_MENU_H_
6 #define CHROME_BROWSER_UI_VIEWS_WRENCH_MENU_H_ 6 #define CHROME_BROWSER_UI_VIEWS_WRENCH_MENU_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/bookmarks/base_bookmark_model_observer.h" 13 #include "chrome/browser/bookmarks/base_bookmark_model_observer.h"
14 #include "content/common/notification_observer.h"
15 #include "content/common/notification_registrar.h"
14 #include "ui/base/models/menu_model.h" 16 #include "ui/base/models/menu_model.h"
15 #include "views/controls/menu/menu_delegate.h" 17 #include "views/controls/menu/menu_delegate.h"
16 18
17 class BookmarkMenuDelegate; 19 class BookmarkMenuDelegate;
18 class Browser; 20 class Browser;
19 21
20 namespace views { 22 namespace views {
21 class MenuButton; 23 class MenuButton;
22 class MenuItemView; 24 class MenuItemView;
23 class MenuRunner; 25 class MenuRunner;
24 class View; 26 class View;
25 } // namespace views 27 } // namespace views
26 28
27 // WrenchMenu adapts the WrenchMenuModel to view's menu related classes. 29 // WrenchMenu adapts the WrenchMenuModel to view's menu related classes.
28 class WrenchMenu : public views::MenuDelegate, 30 class WrenchMenu : public views::MenuDelegate,
29 public BaseBookmarkModelObserver { 31 public BaseBookmarkModelObserver,
32 public NotificationObserver {
30 public: 33 public:
31 explicit WrenchMenu(Browser* browser); 34 explicit WrenchMenu(Browser* browser);
32 virtual ~WrenchMenu(); 35 virtual ~WrenchMenu();
33 36
34 void Init(ui::MenuModel* model); 37 void Init(ui::MenuModel* model);
35 38
36 // Shows the menu relative to the specified view. 39 // Shows the menu relative to the specified view.
37 void RunMenu(views::MenuButton* host); 40 void RunMenu(views::MenuButton* host);
38 41
39 // MenuDelegate overrides: 42 // MenuDelegate overrides:
(...skipping 24 matching lines...) Expand all
64 virtual int GetMaxWidthForMenu(views::MenuItemView* menu) OVERRIDE; 67 virtual int GetMaxWidthForMenu(views::MenuItemView* menu) OVERRIDE;
65 virtual bool IsItemChecked(int id) const OVERRIDE; 68 virtual bool IsItemChecked(int id) const OVERRIDE;
66 virtual bool IsCommandEnabled(int id) const OVERRIDE; 69 virtual bool IsCommandEnabled(int id) const OVERRIDE;
67 virtual void ExecuteCommand(int id, int mouse_event_flags) OVERRIDE; 70 virtual void ExecuteCommand(int id, int mouse_event_flags) OVERRIDE;
68 virtual bool GetAccelerator(int id, views::Accelerator* accelerator) OVERRIDE; 71 virtual bool GetAccelerator(int id, views::Accelerator* accelerator) OVERRIDE;
69 virtual void WillShowMenu(views::MenuItemView* menu) OVERRIDE; 72 virtual void WillShowMenu(views::MenuItemView* menu) OVERRIDE;
70 73
71 // BaseBookmarkModelObserver overrides: 74 // BaseBookmarkModelObserver overrides:
72 virtual void BookmarkModelChanged() OVERRIDE; 75 virtual void BookmarkModelChanged() OVERRIDE;
73 76
77 // NotificationObserver overrides:
78 virtual void Observe(int type,
79 const NotificationSource& source,
80 const NotificationDetails& details) OVERRIDE;
81
74 private: 82 private:
75 class CutCopyPasteView; 83 class CutCopyPasteView;
76 class ZoomView; 84 class ZoomView;
77 85
78 typedef std::pair<ui::MenuModel*,int> Entry; 86 typedef std::pair<ui::MenuModel*,int> Entry;
79 typedef std::map<int,Entry> IDToEntry; 87 typedef std::map<int,Entry> IDToEntry;
80 88
81 // Populates |parent| with all the child menus in |model|. Recursively invokes 89 // Populates |parent| with all the child menus in |model|. Recursively invokes
82 // |PopulateMenu| for any submenu. |next_id| is incremented for every menu 90 // |PopulateMenu| for any submenu. |next_id| is incremented for every menu
83 // that is created. 91 // that is created.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 135
128 // Used for managing the bookmark menu items. 136 // Used for managing the bookmark menu items.
129 scoped_ptr<BookmarkMenuDelegate> bookmark_menu_delegate_; 137 scoped_ptr<BookmarkMenuDelegate> bookmark_menu_delegate_;
130 138
131 // Menu corresponding to IDC_BOOKMARKS_MENU. 139 // Menu corresponding to IDC_BOOKMARKS_MENU.
132 views::MenuItemView* bookmark_menu_; 140 views::MenuItemView* bookmark_menu_;
133 141
134 // ID to use for the items representing bookmarks in the bookmark menu. 142 // ID to use for the items representing bookmarks in the bookmark menu.
135 int first_bookmark_command_id_; 143 int first_bookmark_command_id_;
136 144
145 NotificationRegistrar registrar_;
146
137 DISALLOW_COPY_AND_ASSIGN(WrenchMenu); 147 DISALLOW_COPY_AND_ASSIGN(WrenchMenu);
138 }; 148 };
139 149
140 #endif // CHROME_BROWSER_UI_VIEWS_WRENCH_MENU_H_ 150 #endif // CHROME_BROWSER_UI_VIEWS_WRENCH_MENU_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar_view.cc ('k') | chrome/browser/ui/views/wrench_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698