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

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

Issue 5544002: Move a bunch more browser stuff around.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years 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/window_sizer_win.cc ('k') | chrome/browser/wrench_menu_model.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_WRENCH_MENU_MODEL_H_
6 #define CHROME_BROWSER_WRENCH_MENU_MODEL_H_
7 #pragma once
8
9 #include "app/menus/accelerator.h"
10 #include "app/menus/button_menu_item_model.h"
11 #include "app/menus/simple_menu_model.h"
12 #include "base/scoped_ptr.h"
13 #include "chrome/browser/tabs/tab_strip_model_observer.h"
14 #include "chrome/common/notification_observer.h"
15 #include "chrome/common/notification_registrar.h"
16
17 class Browser;
18 class TabStripModel;
19
20 namespace {
21 class MockWrenchMenuModel;
22 } // namespace
23
24 // A menu model that builds the contents of an encoding menu.
25 class EncodingMenuModel : public menus::SimpleMenuModel,
26 public menus::SimpleMenuModel::Delegate {
27 public:
28 explicit EncodingMenuModel(Browser* browser);
29 virtual ~EncodingMenuModel();
30
31 // Overridden from menus::SimpleMenuModel::Delegate:
32 virtual bool IsCommandIdChecked(int command_id) const;
33 virtual bool IsCommandIdEnabled(int command_id) const;
34 virtual bool GetAcceleratorForCommandId(int command_id,
35 menus::Accelerator* accelerator);
36 virtual void ExecuteCommand(int command_id);
37
38 private:
39 void Build();
40
41 Browser* browser_; // weak
42
43 DISALLOW_COPY_AND_ASSIGN(EncodingMenuModel);
44 };
45
46 // A menu model that builds the contents of the zoom menu.
47 class ZoomMenuModel : public menus::SimpleMenuModel {
48 public:
49 explicit ZoomMenuModel(menus::SimpleMenuModel::Delegate* delegate);
50 virtual ~ZoomMenuModel();
51
52 private:
53 void Build();
54
55 DISALLOW_COPY_AND_ASSIGN(ZoomMenuModel);
56 };
57
58 class ToolsMenuModel : public menus::SimpleMenuModel {
59 public:
60 ToolsMenuModel(menus::SimpleMenuModel::Delegate* delegate, Browser* browser);
61 virtual ~ToolsMenuModel();
62
63 private:
64 void Build(Browser* browser);
65
66 scoped_ptr<EncodingMenuModel> encoding_menu_model_;
67
68 DISALLOW_COPY_AND_ASSIGN(ToolsMenuModel);
69 };
70
71 // A menu model that builds the contents of the wrench menu.
72 class WrenchMenuModel : public menus::SimpleMenuModel,
73 public menus::SimpleMenuModel::Delegate,
74 public menus::ButtonMenuItemModel::Delegate,
75 public TabStripModelObserver,
76 public NotificationObserver {
77 public:
78 WrenchMenuModel(menus::AcceleratorProvider* provider, Browser* browser);
79 virtual ~WrenchMenuModel();
80
81 // Overridden for ButtonMenuItemModel::Delegate:
82 virtual bool DoesCommandIdDismissMenu(int command_id) const;
83
84 // Overridden for both ButtonMenuItemModel::Delegate and SimpleMenuModel:
85 virtual bool IsLabelForCommandIdDynamic(int command_id) const;
86 virtual string16 GetLabelForCommandId(int command_id) const;
87 virtual void ExecuteCommand(int command_id);
88 virtual bool IsCommandIdChecked(int command_id) const;
89 virtual bool IsCommandIdEnabled(int command_id) const;
90 virtual bool IsCommandIdVisible(int command_id) const;
91 virtual bool GetAcceleratorForCommandId(
92 int command_id,
93 menus::Accelerator* accelerator);
94
95 // Overridden from TabStripModelObserver:
96 virtual void TabSelectedAt(TabContentsWrapper* old_contents,
97 TabContentsWrapper* new_contents,
98 int index,
99 bool user_gesture);
100 virtual void TabReplacedAt(TabContentsWrapper* old_contents,
101 TabContentsWrapper* new_contents, int index);
102 virtual void TabStripModelDeleted();
103
104 // Overridden from NotificationObserver:
105 virtual void Observe(NotificationType type,
106 const NotificationSource& source,
107 const NotificationDetails& details);
108
109 // Getters.
110 Browser* browser() const { return browser_; }
111
112 // Calculates |zoom_label_| in response to a zoom change.
113 void UpdateZoomControls();
114
115 private:
116 // Testing constructor used for mocking.
117 friend class ::MockWrenchMenuModel;
118 WrenchMenuModel();
119
120 void Build();
121
122 // Adds custom items to the menu. Deprecated in favor of a cross platform
123 // model for button items.
124 void CreateCutCopyPaste();
125 void CreateZoomFullscreen();
126
127 string16 GetSyncMenuLabel() const;
128
129 // Models for the special menu items with buttons.
130 scoped_ptr<menus::ButtonMenuItemModel> edit_menu_item_model_;
131 scoped_ptr<menus::ButtonMenuItemModel> zoom_menu_item_model_;
132
133 // Label of the zoom label in the zoom menu item.
134 string16 zoom_label_;
135
136 // Tools menu.
137 scoped_ptr<ToolsMenuModel> tools_menu_model_;
138
139 menus::AcceleratorProvider* provider_; // weak
140
141 Browser* browser_; // weak
142 TabStripModel* tabstrip_model_; // weak
143
144 NotificationRegistrar registrar_;
145
146 DISALLOW_COPY_AND_ASSIGN(WrenchMenuModel);
147 };
148
149 #endif // CHROME_BROWSER_WRENCH_MENU_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/window_sizer_win.cc ('k') | chrome/browser/wrench_menu_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698