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

Side by Side Diff: chrome/browser/wrench_menu_model.h

Issue 2800015: GTK: First draft of the unified cut/copy/paste and +/-/Fullscreen menu items. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: estade cleanups Created 10 years, 6 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_WRENCH_MENU_MODEL_H_ 5 #ifndef CHROME_BROWSER_WRENCH_MENU_MODEL_H_
6 #define CHROME_BROWSER_WRENCH_MENU_MODEL_H_ 6 #define CHROME_BROWSER_WRENCH_MENU_MODEL_H_
7 7
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
11 #include "app/menus/simple_menu_model.h" 11 #include "app/menus/simple_menu_model.h"
12 #include "base/ref_counted.h" 12 #include "base/ref_counted.h"
13 #include "base/scoped_ptr.h" 13 #include "base/scoped_ptr.h"
14 #include "chrome/common/notification_observer.h"
15 #include "chrome/common/notification_registrar.h"
14 16
15 class Browser; 17 class Browser;
16 class EncodingMenuModel; 18 class EncodingMenuModel;
17 19
20 namespace menus {
21 class ButtonMenuItemModel;
22 } // namespace menus
23
18 class ToolsMenuModel : public menus::SimpleMenuModel { 24 class ToolsMenuModel : public menus::SimpleMenuModel {
19 public: 25 public:
20 explicit ToolsMenuModel(menus::SimpleMenuModel::Delegate* delegate, 26 ToolsMenuModel(menus::SimpleMenuModel::Delegate* delegate, Browser* browser);
21 Browser* browser);
22 virtual ~ToolsMenuModel(); 27 virtual ~ToolsMenuModel();
23 28
24 private: 29 private:
25 void Build(Browser* browser); 30 void Build(Browser* browser);
26 31
27 scoped_ptr<EncodingMenuModel> encoding_menu_model_; 32 scoped_ptr<EncodingMenuModel> encoding_menu_model_;
28 33
29 DISALLOW_COPY_AND_ASSIGN(ToolsMenuModel); 34 DISALLOW_COPY_AND_ASSIGN(ToolsMenuModel);
30 }; 35 };
31 36
32 // A menu model that builds the contents of the wrench menu. 37 // A menu model that builds the contents of the wrench menu.
33 class WrenchMenuModel : public menus::SimpleMenuModel { 38 class WrenchMenuModel : public menus::SimpleMenuModel,
39 public menus::ButtonMenuItemModel::Delegate,
40 public NotificationObserver {
34 public: 41 public:
35 explicit WrenchMenuModel(menus::SimpleMenuModel::Delegate* delegate, 42 WrenchMenuModel(menus::SimpleMenuModel::Delegate* delegate,
36 Browser* browser); 43 Browser* browser);
37 virtual ~WrenchMenuModel(); 44 virtual ~WrenchMenuModel();
38 45
39 // Returns true if the WrenchMenuModel is enabled. 46 // Returns true if the WrenchMenuModel is enabled.
40 static bool IsEnabled(); 47 static bool IsEnabled();
41 48
42 // Overridden from menus::SimpleMenuModel: 49 // Overridden from menus::SimpleMenuModel:
43 virtual bool IsLabelDynamicAt(int index) const; 50 virtual bool IsLabelDynamicAt(int index) const;
44 virtual string16 GetLabelAt(int index) const; 51 virtual string16 GetLabelAt(int index) const;
45 virtual bool HasIcons() const { return true; } 52 virtual bool HasIcons() const { return true; }
46 virtual bool GetIconAt(int index, SkBitmap* icon) const; 53 virtual bool GetIconAt(int index, SkBitmap* icon) const;
47 54
48 protected: 55 // Overridden from menus::ButtonMenuItemModel::Delegate:
49 // Adds the cut/copy/paste items to the menu. The default implementation adds 56 virtual bool IsLabelForCommandIdDynamic(int command_id) const;
50 // three real menu items, while platform specific subclasses add their own 57 virtual string16 GetLabelForCommandId(int command_id) const;
51 // native monstrosities. 58 virtual void ExecuteCommand(int command_id);
52 virtual void CreateCutCopyPaste();
53 59
54 // Adds the zoom/fullscreen items to the menu. Like CreateCutCopyPaste(). 60 // Overridden from NotificationObserver:
55 virtual void CreateZoomFullscreen(); 61 virtual void Observe(NotificationType type,
62 const NotificationSource& source,
63 const NotificationDetails& details);
56 64
57 private: 65 private:
58 void Build(); 66 void Build();
59 67
68 // Adds custom items to the menu. Deprecated in favor of a cross platform
69 // model for button items.
70 void CreateCutCopyPaste();
71 void CreateZoomFullscreen();
72
73 // Calculates |zoom_label_| in response to a zoom change.
74 void UpdateZoomControls();
75 double GetZoom(bool* enable_increment, bool* enable_decrement);
76
60 string16 GetSyncMenuLabel() const; 77 string16 GetSyncMenuLabel() const;
61 string16 GetAboutEntryMenuLabel() const; 78 string16 GetAboutEntryMenuLabel() const;
62 bool IsDynamicItem(int index) const; 79 bool IsDynamicItem(int index) const;
63 80
81 // Models for the special menu items with buttons.
82 scoped_ptr<menus::ButtonMenuItemModel> edit_menu_item_model_;
83 scoped_ptr<menus::ButtonMenuItemModel> zoom_menu_item_model_;
84
85 // Label of the zoom label in the zoom menu item.
86 string16 zoom_label_;
87
64 // Tools menu. 88 // Tools menu.
65 scoped_ptr<ToolsMenuModel> tools_menu_model_; 89 scoped_ptr<ToolsMenuModel> tools_menu_model_;
66 90
91 menus::SimpleMenuModel::Delegate* delegate_; // weak
92
67 Browser* browser_; // weak 93 Browser* browser_; // weak
68 94
95 NotificationRegistrar registrar_;
96
69 DISALLOW_COPY_AND_ASSIGN(WrenchMenuModel); 97 DISALLOW_COPY_AND_ASSIGN(WrenchMenuModel);
70 }; 98 };
71 99
72 #endif // CHROME_BROWSER_WRENCH_MENU_MODEL_H_ 100 #endif // CHROME_BROWSER_WRENCH_MENU_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/gtk/notifications/notification_options_menu_model.cc ('k') | chrome/browser/wrench_menu_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698