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

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

Issue 3163023: Clean up the WrenchMenuModel so that it uses SimpleMenu::Delegate. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Fix stray rb Created 10 years, 4 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 #include "chrome/browser/wrench_menu_model.h" 5 #include "chrome/browser/wrench_menu_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
11 #include "app/menus/button_menu_item_model.h" 11 #include "app/menus/button_menu_item_model.h"
12 #include "app/resource_bundle.h" 12 #include "app/resource_bundle.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 #include "chrome/app/chrome_dll_resource.h" 17 #include "chrome/app/chrome_dll_resource.h"
18 #include "chrome/browser/browser.h" 18 #include "chrome/browser/browser.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/defaults.h" 20 #include "chrome/browser/defaults.h"
21 #include "chrome/browser/encoding_menu_controller.h" 21 #include "chrome/browser/encoding_menu_controller.h"
22 #include "chrome/browser/host_zoom_map.h" 22 #include "chrome/browser/host_zoom_map.h"
23 #include "chrome/browser/pref_service.h"
23 #include "chrome/browser/profile.h" 24 #include "chrome/browser/profile.h"
24 #include "chrome/browser/sync/profile_sync_service.h" 25 #include "chrome/browser/sync/profile_sync_service.h"
25 #include "chrome/browser/sync/sync_ui_util.h" 26 #include "chrome/browser/sync/sync_ui_util.h"
26 #include "chrome/browser/tab_contents/tab_contents.h" 27 #include "chrome/browser/tab_contents/tab_contents.h"
27 #include "chrome/browser/upgrade_detector.h" 28 #include "chrome/browser/upgrade_detector.h"
28 #include "chrome/common/chrome_switches.h" 29 #include "chrome/common/chrome_switches.h"
29 #include "chrome/common/notification_service.h" 30 #include "chrome/common/notification_service.h"
30 #include "chrome/common/notification_source.h" 31 #include "chrome/common/notification_source.h"
31 #include "chrome/common/notification_type.h" 32 #include "chrome/common/notification_type.h"
33 #include "chrome/common/pref_names.h"
32 #include "grit/chromium_strings.h" 34 #include "grit/chromium_strings.h"
33 #include "grit/generated_resources.h" 35 #include "grit/generated_resources.h"
34 #include "grit/theme_resources.h" 36 #include "grit/theme_resources.h"
35 37
36 #if defined(OS_LINUX) 38 #if defined(OS_LINUX)
37 #include <gtk/gtk.h> 39 #include <gtk/gtk.h>
38 #endif 40 #endif
39 41
42 #if defined(OS_MACOSX)
43 #include "chrome/browser/browser_window.h"
44 #endif
45
40 //////////////////////////////////////////////////////////////////////////////// 46 ////////////////////////////////////////////////////////////////////////////////
41 // EncodingMenuModel 47 // EncodingMenuModel
42 48
43 EncodingMenuModel::EncodingMenuModel(Browser* browser) 49 EncodingMenuModel::EncodingMenuModel(Browser* browser)
44 : ALLOW_THIS_IN_INITIALIZER_LIST(menus::SimpleMenuModel(this)), 50 : ALLOW_THIS_IN_INITIALIZER_LIST(menus::SimpleMenuModel(this)),
45 browser_(browser) { 51 browser_(browser) {
46 Build(); 52 Build();
47 } 53 }
48 54
49 void EncodingMenuModel::Build() { 55 void EncodingMenuModel::Build() {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 AddItemWithStringId(IDC_VIEW_SOURCE, IDS_VIEW_SOURCE); 160 AddItemWithStringId(IDC_VIEW_SOURCE, IDS_VIEW_SOURCE);
155 if (g_browser_process->have_inspector_files()) { 161 if (g_browser_process->have_inspector_files()) {
156 AddItemWithStringId(IDC_DEV_TOOLS, IDS_DEV_TOOLS); 162 AddItemWithStringId(IDC_DEV_TOOLS, IDS_DEV_TOOLS);
157 AddItemWithStringId(IDC_DEV_TOOLS_CONSOLE, IDS_DEV_TOOLS_CONSOLE); 163 AddItemWithStringId(IDC_DEV_TOOLS_CONSOLE, IDS_DEV_TOOLS_CONSOLE);
158 } 164 }
159 } 165 }
160 166
161 //////////////////////////////////////////////////////////////////////////////// 167 ////////////////////////////////////////////////////////////////////////////////
162 // WrenchMenuModel 168 // WrenchMenuModel
163 169
164 WrenchMenuModel::WrenchMenuModel(menus::SimpleMenuModel::Delegate* delegate, 170 WrenchMenuModel::WrenchMenuModel(menus::AcceleratorProvider* provider,
165 Browser* browser) 171 Browser* browser)
166 : menus::SimpleMenuModel(delegate), 172 : ALLOW_THIS_IN_INITIALIZER_LIST(model_(this)),
167 delegate_(delegate), 173 provider_(provider),
168 browser_(browser), 174 browser_(browser),
169 tabstrip_model_(browser_->tabstrip_model()) { 175 tabstrip_model_(browser_->tabstrip_model()) {
170 Build(); 176 Build();
171 UpdateZoomControls(); 177 UpdateZoomControls();
172 178
173 tabstrip_model_->AddObserver(this); 179 tabstrip_model_->AddObserver(this);
174 180
175 registrar_.Add(this, NotificationType::ZOOM_LEVEL_CHANGED, 181 registrar_.Add(this, NotificationType::ZOOM_LEVEL_CHANGED,
176 Source<Profile>(browser_->profile())); 182 Source<Profile>(browser_->profile()));
177 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED, 183 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED,
178 NotificationService::AllSources()); 184 NotificationService::AllSources());
179 } 185 }
180 186
187 // For testing.
188 WrenchMenuModel::WrenchMenuModel() : model_(NULL) {
sky 2010/08/23 21:55:59 Position should match that of header.
189 }
190
181 WrenchMenuModel::~WrenchMenuModel() { 191 WrenchMenuModel::~WrenchMenuModel() {
182 if (tabstrip_model_) 192 if (tabstrip_model_)
183 tabstrip_model_->RemoveObserver(this); 193 tabstrip_model_->RemoveObserver(this);
184 } 194 }
185 195
186 bool WrenchMenuModel::IsLabelDynamicAt(int index) const { 196 bool WrenchMenuModel::IsLabelForCommandIdDynamic(int command_id) const {
187 return IsDynamicItem(index) || SimpleMenuModel::IsLabelDynamicAt(index); 197 return command_id == IDC_ZOOM_PERCENT_DISPLAY ||
198 command_id == IDC_SYNC_BOOKMARKS ||
199 #if defined(OS_MACOSX)
200 command_id == IDC_FULLSCREEN ||
201 #endif
202 command_id == IDC_ABOUT;
188 } 203 }
189 204
190 string16 WrenchMenuModel::GetLabelAt(int index) const { 205 string16 WrenchMenuModel::GetLabelForCommandId(int command_id) const {
191 if (!IsDynamicItem(index))
192 return SimpleMenuModel::GetLabelAt(index);
193
194 int command_id = GetCommandIdAt(index);
195
196 switch (command_id) { 206 switch (command_id) {
197 case IDC_ABOUT: 207 case IDC_ABOUT:
198 return GetAboutEntryMenuLabel(); 208 return GetAboutEntryMenuLabel();
199 case IDC_SYNC_BOOKMARKS: 209 case IDC_SYNC_BOOKMARKS:
200 return GetSyncMenuLabel(); 210 return GetSyncMenuLabel();
211 case IDC_ZOOM_PERCENT_DISPLAY:
212 return zoom_label_;
213 #if defined(OS_MACOSX)
214 case IDC_FULLSCREEN: {
215 int string_id = IDS_ENTER_FULLSCREEN_MAC; // Default to Enter.
216 // Note: On startup, |window()| may be NULL.
217 if (browser_->window() && browser_->window()->IsFullscreen())
218 string_id = IDS_EXIT_FULLSCREEN_MAC;
219 return l10n_util::GetStringUTF16(string_id);
220 }
221 #endif
201 default: 222 default:
202 NOTREACHED(); 223 NOTREACHED();
203 return string16(); 224 return string16();
204 } 225 }
205 } 226 }
206 227
207 bool WrenchMenuModel::GetIconAt(int index, SkBitmap* icon) const { 228 void WrenchMenuModel::ExecuteCommand(int command_id) {
208 if (GetCommandIdAt(index) == IDC_ABOUT && 229 browser_->ExecuteCommand(command_id);
209 Singleton<UpgradeDetector>::get()->notify_upgrade()) { 230 }
210 // Show the exclamation point next to the menu item. 231
211 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 232 bool WrenchMenuModel::IsCommandIdChecked(int command_id) const {
212 *icon = *rb.GetBitmapNamed(IDR_UPDATE_AVAILABLE); 233 #if defined(OS_CHROMEOS)
213 return true; 234 if (command_id == IDC_TOGGLE_VERTICAL_TABS) {
235 return browser_->UseVerticalTabs();
214 } 236 }
237 #endif
238
239 if (command_id == IDC_SHOW_BOOKMARK_BAR) {
240 return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar);
241 }
242
215 return false; 243 return false;
216 } 244 }
217 245
218 bool WrenchMenuModel::IsLabelForCommandIdDynamic(int command_id) const { 246 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const {
219 return command_id == IDC_ZOOM_PERCENT_DISPLAY; 247 return browser_->command_updater()->IsCommandEnabled(command_id);
220 } 248 }
221 249
222 string16 WrenchMenuModel::GetLabelForCommandId(int command_id) const { 250 bool WrenchMenuModel::GetAcceleratorForCommandId(
223 DCHECK_EQ(IDC_ZOOM_PERCENT_DISPLAY, command_id); 251 int command_id,
224 return zoom_label_; 252 menus::Accelerator* accelerator) {
225 } 253 return provider_->GetAcceleratorForCommandId(command_id, accelerator);
226
227 void WrenchMenuModel::ExecuteCommand(int command_id) {
228 if (delegate_)
229 delegate_->ExecuteCommand(command_id);
230 } 254 }
231 255
232 void WrenchMenuModel::TabSelectedAt(TabContents* old_contents, 256 void WrenchMenuModel::TabSelectedAt(TabContents* old_contents,
233 TabContents* new_contents, 257 TabContents* new_contents,
234 int index, 258 int index,
235 bool user_gesture) { 259 bool user_gesture) {
236 // The user has switched between tabs and the new tab may have a different 260 // The user has switched between tabs and the new tab may have a different
237 // zoom setting. 261 // zoom setting.
238 UpdateZoomControls(); 262 UpdateZoomControls();
239 } 263 }
(...skipping 10 matching lines...) Expand all
250 tabstrip_model_ = NULL; 274 tabstrip_model_ = NULL;
251 } 275 }
252 276
253 void WrenchMenuModel::Observe(NotificationType type, 277 void WrenchMenuModel::Observe(NotificationType type,
254 const NotificationSource& source, 278 const NotificationSource& source,
255 const NotificationDetails& details) { 279 const NotificationDetails& details) {
256 UpdateZoomControls(); 280 UpdateZoomControls();
257 } 281 }
258 282
259 void WrenchMenuModel::Build() { 283 void WrenchMenuModel::Build() {
260 AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); 284 model_.AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB);
261 AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW); 285 model_.AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW);
262 AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW); 286 model_.AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW,
287 IDS_NEW_INCOGNITO_WINDOW);
263 288
264 AddSeparator(); 289 model_.AddSeparator();
265 #if defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)) 290 #if defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(TOOLKIT_VIEWS))
266 // WARNING: Mac does not use the ButtonMenuItemModel, but instead defines the 291 // WARNING: Mac does not use the ButtonMenuItemModel, but instead defines the
267 // layout for this menu item in Toolbar.xib. It does, however, use the 292 // layout for this menu item in Toolbar.xib. It does, however, use the
268 // command_id value from AddButtonItem() to identify this special item. 293 // command_id value from AddButtonItem() to identify this special item.
269 edit_menu_item_model_.reset(new menus::ButtonMenuItemModel(IDS_EDIT, this)); 294 edit_menu_item_model_.reset(new menus::ButtonMenuItemModel(IDS_EDIT, this));
270 edit_menu_item_model_->AddGroupItemWithStringId(IDC_CUT, IDS_CUT); 295 edit_menu_item_model_->AddGroupItemWithStringId(IDC_CUT, IDS_CUT);
271 edit_menu_item_model_->AddGroupItemWithStringId(IDC_COPY, IDS_COPY); 296 edit_menu_item_model_->AddGroupItemWithStringId(IDC_COPY, IDS_COPY);
272 edit_menu_item_model_->AddGroupItemWithStringId(IDC_PASTE, IDS_PASTE); 297 edit_menu_item_model_->AddGroupItemWithStringId(IDC_PASTE, IDS_PASTE);
273 AddButtonItem(IDC_EDIT_MENU, edit_menu_item_model_.get()); 298 model_.AddButtonItem(IDC_EDIT_MENU, edit_menu_item_model_.get());
274 #else 299 #else
275 // TODO(port): Move to the above. 300 // TODO(port): Move to the above.
276 CreateCutCopyPaste(); 301 CreateCutCopyPaste();
277 #endif 302 #endif
278 303
279 AddSeparator(); 304 model_.AddSeparator();
280 #if defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)) 305 #if defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(TOOLKIT_VIEWS))
281 // WARNING: See above comment. 306 // WARNING: See above comment.
282 zoom_menu_item_model_.reset( 307 zoom_menu_item_model_.reset(
283 new menus::ButtonMenuItemModel(IDS_ZOOM_MENU, this)); 308 new menus::ButtonMenuItemModel(IDS_ZOOM_MENU, this));
284 zoom_menu_item_model_->AddGroupItemWithStringId( 309 zoom_menu_item_model_->AddGroupItemWithStringId(
285 IDC_ZOOM_MINUS, IDS_ZOOM_MINUS2); 310 IDC_ZOOM_MINUS, IDS_ZOOM_MINUS2);
286 zoom_menu_item_model_->AddButtonLabel(IDC_ZOOM_PERCENT_DISPLAY, 311 zoom_menu_item_model_->AddButtonLabel(IDC_ZOOM_PERCENT_DISPLAY,
287 IDS_ZOOM_PLUS2); 312 IDS_ZOOM_PLUS2);
288 zoom_menu_item_model_->AddGroupItemWithStringId( 313 zoom_menu_item_model_->AddGroupItemWithStringId(
289 IDC_ZOOM_PLUS, IDS_ZOOM_PLUS2); 314 IDC_ZOOM_PLUS, IDS_ZOOM_PLUS2);
290 zoom_menu_item_model_->AddSpace(); 315 zoom_menu_item_model_->AddSpace();
291 zoom_menu_item_model_->AddItemWithImage( 316 zoom_menu_item_model_->AddItemWithImage(
292 IDC_FULLSCREEN, IDR_FULLSCREEN_MENU_BUTTON); 317 IDC_FULLSCREEN, IDR_FULLSCREEN_MENU_BUTTON);
293 AddButtonItem(IDC_ZOOM_MENU, zoom_menu_item_model_.get()); 318 model_.AddButtonItem(IDC_ZOOM_MENU, zoom_menu_item_model_.get());
294 #else 319 #else
295 // TODO(port): Move to the above. 320 // TODO(port): Move to the above.
296 CreateZoomFullscreen(); 321 CreateZoomFullscreen();
297 #endif 322 #endif
298 323
299 AddSeparator(); 324 model_.AddSeparator();
300 AddItemWithStringId(IDC_SAVE_PAGE, IDS_SAVE_PAGE); 325 model_.AddItemWithStringId(IDC_SAVE_PAGE, IDS_SAVE_PAGE);
301 AddItemWithStringId(IDC_FIND, IDS_FIND); 326 model_.AddItemWithStringId(IDC_FIND, IDS_FIND);
302 AddItemWithStringId(IDC_PRINT, IDS_PRINT); 327 model_.AddItemWithStringId(IDC_PRINT, IDS_PRINT);
303 328
304 tools_menu_model_.reset(new ToolsMenuModel(delegate(), browser_)); 329 tools_menu_model_.reset(new ToolsMenuModel(this, browser_));
305 AddSubMenuWithStringId(IDC_ZOOM_MENU, IDS_TOOLS_MENU, 330 model_.AddSubMenuWithStringId(IDC_ZOOM_MENU, IDS_TOOLS_MENU,
306 tools_menu_model_.get()); 331 tools_menu_model_.get());
307 332
308 AddSeparator(); 333 model_.AddSeparator();
309 #if defined(ENABLE_REMOTING) 334 #if defined(ENABLE_REMOTING)
310 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableRemoting)) { 335 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableRemoting)) {
311 AddItem(IDC_REMOTING_SETUP, 336 model_.AddItem(IDC_REMOTING_SETUP,
312 l10n_util::GetStringUTF16(IDS_REMOTING_SETUP_LABEL)); 337 l10n_util::GetStringUTF16(IDS_REMOTING_SETUP_LABEL));
313 } 338 }
314 #endif 339 #endif
315 AddItemWithStringId(IDC_SHOW_BOOKMARK_MANAGER, IDS_BOOKMARK_MANAGER); 340 model_.AddItemWithStringId(IDC_SHOW_BOOKMARK_MANAGER, IDS_BOOKMARK_MANAGER);
316 AddItemWithStringId(IDC_SHOW_HISTORY, IDS_SHOW_HISTORY); 341 model_.AddItemWithStringId(IDC_SHOW_HISTORY, IDS_SHOW_HISTORY);
317 AddItemWithStringId(IDC_SHOW_DOWNLOADS, IDS_SHOW_DOWNLOADS); 342 model_.AddItemWithStringId(IDC_SHOW_DOWNLOADS, IDS_SHOW_DOWNLOADS);
318 AddSeparator(); 343 model_.AddSeparator();
319 344
320 #if defined(OS_MACOSX) 345 #if defined(OS_MACOSX)
321 AddItemWithStringId(IDC_OPTIONS, IDS_PREFERENCES_MAC); 346 model_.AddItemWithStringId(IDC_OPTIONS, IDS_PREFERENCES_MAC);
322 #elif defined(OS_LINUX) 347 #elif defined(OS_LINUX)
323 GtkStockItem stock_item; 348 GtkStockItem stock_item;
324 if (gtk_stock_lookup(GTK_STOCK_PREFERENCES, &stock_item)) { 349 if (gtk_stock_lookup(GTK_STOCK_PREFERENCES, &stock_item)) {
325 const char16 kUnderscore[] = { '_', 0 }; 350 const char16 kUnderscore[] = { '_', 0 };
326 string16 preferences; 351 string16 preferences;
327 RemoveChars(UTF8ToUTF16(stock_item.label), kUnderscore, &preferences); 352 RemoveChars(UTF8ToUTF16(stock_item.label), kUnderscore, &preferences);
328 AddItem(IDC_OPTIONS, preferences); 353 model_.AddItem(IDC_OPTIONS, preferences);
354 } else {
355 model_.AddItemWithStringId(IDC_OPTIONS, IDS_OPTIONS);
329 } 356 }
330 #else 357 #else
331 AddItemWithStringId(IDC_OPTIONS, IDS_OPTIONS); 358 model_.AddItemWithStringId(IDC_OPTIONS, IDS_OPTIONS);
332 #endif 359 #endif
333 360
334 #if defined(OS_CHROMEOS) 361 #if defined(OS_CHROMEOS)
335 AddCheckItemWithStringId(IDC_TOGGLE_VERTICAL_TABS, 362 model_.AddCheckItemWithStringId(IDC_TOGGLE_VERTICAL_TABS,
336 IDS_TAB_CXMENU_USE_VERTICAL_TABS); 363 IDS_TAB_CXMENU_USE_VERTICAL_TABS);
337 #endif 364 #endif
338 365
366 // TODO(erg): This entire section needs to be reworked and is out of scope of
367 // the first cleanup patch I'm doing. Part 1 (crbug.com/47320) is moving most
368 // of the logic from each platform specific UI code into the model here. Part
369 // 2 (crbug.com/46221) is normalizing the about menu item/hidden update menu
370 // item behaviour across the three platforms.
371
339 // On Mac, there is no About item unless it is replaced with the update 372 // On Mac, there is no About item unless it is replaced with the update
340 // available notification. 373 // available notification.
341 if (browser_defaults::kShowAboutMenuItem || 374 if (browser_defaults::kShowAboutMenuItem ||
342 Singleton<UpgradeDetector>::get()->notify_upgrade()) { 375 Singleton<UpgradeDetector>::get()->notify_upgrade()) {
343 AddItem(IDC_ABOUT, 376 model_.AddItem(IDC_ABOUT,
344 l10n_util::GetStringFUTF16( 377 l10n_util::GetStringFUTF16(
345 IDS_ABOUT, 378 IDS_ABOUT,
346 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); 379 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
380 // ResourceBundle& rb = ResourceBundle::GetSharedInstance();
381 // model_.SetIcon(model_.GetIndexOfCommandId(IDC_ABOUT),
382 // *rb.GetBitmapNamed(IDR_UPDATE_AVAILABLE));
347 } 383 }
348 AddItemWithStringId(IDC_HELP_PAGE, IDS_HELP_PAGE); 384 model_.AddItemWithStringId(IDC_HELP_PAGE, IDS_HELP_PAGE);
349 if (browser_defaults::kShowExitMenuItem) { 385 if (browser_defaults::kShowExitMenuItem) {
350 AddSeparator(); 386 model_.AddSeparator();
351 #if defined(OS_CHROMEOS) 387 #if defined(OS_CHROMEOS)
352 AddItemWithStringId(IDC_EXIT, IDS_SIGN_OUT); 388 model_.AddItemWithStringId(IDC_EXIT, IDS_SIGN_OUT);
353 #else 389 #else
354 AddItemWithStringId(IDC_EXIT, IDS_EXIT); 390 model_.AddItemWithStringId(IDC_EXIT, IDS_EXIT);
355 #endif 391 #endif
356 } 392 }
357 } 393 }
358 394
359 void WrenchMenuModel::CreateCutCopyPaste() { 395 void WrenchMenuModel::CreateCutCopyPaste() {
360 // WARNING: views/wrench_menu assumes these items are added in this order. If 396 // WARNING: views/wrench_menu assumes these items are added in this order. If
361 // you change the order you'll need to update wrench_menu as well. 397 // you change the order you'll need to update wrench_menu as well.
362 AddItemWithStringId(IDC_CUT, IDS_CUT); 398 model_.AddItemWithStringId(IDC_CUT, IDS_CUT);
363 AddItemWithStringId(IDC_COPY, IDS_COPY); 399 model_.AddItemWithStringId(IDC_COPY, IDS_COPY);
364 AddItemWithStringId(IDC_PASTE, IDS_PASTE); 400 model_.AddItemWithStringId(IDC_PASTE, IDS_PASTE);
365 } 401 }
366 402
367 void WrenchMenuModel::CreateZoomFullscreen() { 403 void WrenchMenuModel::CreateZoomFullscreen() {
368 // WARNING: views/wrench_menu assumes these items are added in this order. If 404 // WARNING: views/wrench_menu assumes these items are added in this order. If
369 // you change the order you'll need to update wrench_menu as well. 405 // you change the order you'll need to update wrench_menu as well.
370 AddItemWithStringId(IDC_ZOOM_MINUS, IDS_ZOOM_MINUS); 406 model_.AddItemWithStringId(IDC_ZOOM_MINUS, IDS_ZOOM_MINUS);
371 AddItemWithStringId(IDC_ZOOM_PLUS, IDS_ZOOM_PLUS); 407 model_.AddItemWithStringId(IDC_ZOOM_PLUS, IDS_ZOOM_PLUS);
372 AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN); 408 model_.AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN);
373 } 409 }
374 410
375 void WrenchMenuModel::UpdateZoomControls() { 411 void WrenchMenuModel::UpdateZoomControls() {
376 bool enable_increment, enable_decrement; 412 bool enable_increment, enable_decrement;
377 int zoom_percent = 413 int zoom_percent =
378 static_cast<int>(GetZoom(&enable_increment, &enable_decrement) * 100); 414 static_cast<int>(GetZoom(&enable_increment, &enable_decrement) * 100);
379 zoom_label_ = l10n_util::GetStringFUTF16( 415 zoom_label_ = l10n_util::GetStringFUTF16(
380 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); 416 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent));
381 } 417 }
382 418
(...skipping 23 matching lines...) Expand all
406 } 442 }
407 443
408 string16 WrenchMenuModel::GetAboutEntryMenuLabel() const { 444 string16 WrenchMenuModel::GetAboutEntryMenuLabel() const {
409 if (Singleton<UpgradeDetector>::get()->notify_upgrade()) { 445 if (Singleton<UpgradeDetector>::get()->notify_upgrade()) {
410 return l10n_util::GetStringFUTF16( 446 return l10n_util::GetStringFUTF16(
411 IDS_UPDATE_NOW, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 447 IDS_UPDATE_NOW, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
412 } 448 }
413 return l10n_util::GetStringFUTF16( 449 return l10n_util::GetStringFUTF16(
414 IDS_ABOUT, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 450 IDS_ABOUT, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
415 } 451 }
416
417 bool WrenchMenuModel::IsDynamicItem(int index) const {
418 int command_id = GetCommandIdAt(index);
419 return command_id == IDC_SYNC_BOOKMARKS ||
420 command_id == IDC_ABOUT;
421 }
422
423 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const {
424 if (delegate_)
425 return delegate_->IsCommandIdEnabled(command_id);
426 return true;
427 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698