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

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

Issue 10038033: Nukes wrench_menu_model_chromeos and folds functionality int (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix non-chromeos build Created 8 years, 8 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/defaults.cc ('k') | chrome/browser/ui/toolbar/wrench_menu_model_chromeos.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/toolbar/wrench_menu_model.h" 5 #include "chrome/browser/ui/toolbar/wrench_menu_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 } 422 }
423 423
424 // For testing. 424 // For testing.
425 WrenchMenuModel::WrenchMenuModel() 425 WrenchMenuModel::WrenchMenuModel()
426 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), 426 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)),
427 provider_(NULL), 427 provider_(NULL),
428 browser_(NULL), 428 browser_(NULL),
429 tabstrip_model_(NULL) { 429 tabstrip_model_(NULL) {
430 } 430 }
431 431
432 #if !defined(OS_CHROMEOS)
433 void WrenchMenuModel::Build() { 432 void WrenchMenuModel::Build() {
434 AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); 433 AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB);
435 AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW); 434 AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW);
435 #if defined(OS_CHROMEOS)
436 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession))
437 AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW);
438 #else
436 AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW); 439 AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW);
440 #endif
437 441
438 bookmark_sub_menu_model_.reset(new BookmarkSubMenuModel(this, browser_)); 442 bookmark_sub_menu_model_.reset(new BookmarkSubMenuModel(this, browser_));
439 AddSubMenuWithStringId(IDC_BOOKMARKS_MENU, IDS_BOOKMARKS_MENU, 443 AddSubMenuWithStringId(IDC_BOOKMARKS_MENU, IDS_BOOKMARKS_MENU,
440 bookmark_sub_menu_model_.get()); 444 bookmark_sub_menu_model_.get());
441 445
442 AddSeparator(); 446 AddSeparator();
443 #if defined(OS_POSIX) && !defined(TOOLKIT_VIEWS) 447 #if defined(OS_POSIX) && !defined(TOOLKIT_VIEWS)
444 // WARNING: Mac does not use the ButtonMenuItemModel, but instead defines the 448 // WARNING: Mac does not use the ButtonMenuItemModel, but instead defines the
445 // layout for this menu item in Toolbar.xib. It does, however, use the 449 // layout for this menu item in Toolbar.xib. It does, however, use the
446 // command_id value from AddButtonItem() to identify this special item. 450 // command_id value from AddButtonItem() to identify this special item.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 tools_menu_model_.reset(new ToolsMenuModel(this, browser_)); 486 tools_menu_model_.reset(new ToolsMenuModel(this, browser_));
483 AddSubMenuWithStringId(IDC_ZOOM_MENU, IDS_TOOLS_MENU, 487 AddSubMenuWithStringId(IDC_ZOOM_MENU, IDS_TOOLS_MENU,
484 tools_menu_model_.get()); 488 tools_menu_model_.get());
485 489
486 AddSeparator(); 490 AddSeparator();
487 491
488 AddItemWithStringId(IDC_SHOW_HISTORY, IDS_SHOW_HISTORY); 492 AddItemWithStringId(IDC_SHOW_HISTORY, IDS_SHOW_HISTORY);
489 AddItemWithStringId(IDC_SHOW_DOWNLOADS, IDS_SHOW_DOWNLOADS); 493 AddItemWithStringId(IDC_SHOW_DOWNLOADS, IDS_SHOW_DOWNLOADS);
490 AddSeparator(); 494 AddSeparator();
491 495
492 if (browser_->profile()->GetOriginalProfile()->IsSyncAccessible()) { 496 if (browser_defaults::kShowSyncSetupMenuItem &&
497 browser_->profile()->GetOriginalProfile()->IsSyncAccessible()) {
493 const string16 short_product_name = 498 const string16 short_product_name =
494 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); 499 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME);
495 AddItem(IDC_SHOW_SYNC_SETUP, l10n_util::GetStringFUTF16( 500 AddItem(IDC_SHOW_SYNC_SETUP, l10n_util::GetStringFUTF16(
496 IDS_SYNC_MENU_PRE_SYNCED_LABEL, short_product_name)); 501 IDS_SYNC_MENU_PRE_SYNCED_LABEL, short_product_name));
497 AddSeparator(); 502 AddSeparator();
498 } 503 }
499 504
500 AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS); 505 AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS);
501 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); 506 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT));
502 string16 num_background_pages = base::FormatNumber( 507 string16 num_background_pages = base::FormatNumber(
503 TaskManager::GetBackgroundPageCount()); 508 TaskManager::GetBackgroundPageCount());
504 AddItem(IDC_VIEW_BACKGROUND_PAGES, l10n_util::GetStringFUTF16( 509 AddItem(IDC_VIEW_BACKGROUND_PAGES, l10n_util::GetStringFUTF16(
505 IDS_VIEW_BACKGROUND_PAGES, num_background_pages)); 510 IDS_VIEW_BACKGROUND_PAGES, num_background_pages));
506 AddItem(IDC_UPGRADE_DIALOG, l10n_util::GetStringUTF16(IDS_UPDATE_NOW)); 511 if (browser_defaults::kShowUpgradeMenuItem)
512 AddItem(IDC_UPGRADE_DIALOG, l10n_util::GetStringUTF16(IDS_UPDATE_NOW));
507 AddItem(IDC_VIEW_INCOMPATIBILITIES, l10n_util::GetStringUTF16( 513 AddItem(IDC_VIEW_INCOMPATIBILITIES, l10n_util::GetStringUTF16(
508 IDS_VIEW_INCOMPATIBILITIES)); 514 IDS_VIEW_INCOMPATIBILITIES));
509 515
510 #if defined(OS_WIN) 516 #if defined(OS_WIN)
511 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
512 SetIcon(GetIndexOfCommandId(IDC_VIEW_INCOMPATIBILITIES), 517 SetIcon(GetIndexOfCommandId(IDC_VIEW_INCOMPATIBILITIES),
513 *rb.GetBitmapNamed(IDR_CONFLICT_MENU)); 518 *ui::ResourceBundle::GetSharedInstance().
tfarina 2012/04/13 20:13:59 nit: hum? could you revert this change?
sky 2012/04/13 21:45:09 No, otherwise 524 is going to be problematic.
tfarina 2012/04/13 22:39:53 OK, I see. So we have two options here: Move rb t
sky 2012/04/13 22:54:06 You can't move rb to upper scope since it isn't al
519 GetBitmapNamed(IDR_CONFLICT_MENU));
514 #endif 520 #endif
515 521
516 AddItemWithStringId(IDC_HELP_PAGE, IDS_HELP_PAGE); 522 AddItemWithStringId(IDC_HELP_PAGE, IDS_HELP_PAGE);
523 if (browser_defaults::kShowHelpMenuItemIcon) {
524 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
tfarina 2012/04/13 20:13:59 nit: please ui::ResourceBundle
525 SetIcon(GetIndexOfCommandId(IDC_HELP_PAGE),
526 *rb.GetBitmapNamed(IDR_HELP_MENU));
527 }
528
529 if (browser_defaults::kShowFeedbackMenuItem)
530 AddItemWithStringId(IDC_FEEDBACK, IDS_FEEDBACK);
517 531
518 AddGlobalErrorMenuItems(); 532 AddGlobalErrorMenuItems();
519 533
520 if (browser_defaults::kShowExitMenuItem) { 534 if (browser_defaults::kShowExitMenuItem) {
521 AddSeparator(); 535 AddSeparator();
522 AddItemWithStringId(IDC_EXIT, IDS_EXIT); 536 AddItemWithStringId(IDC_EXIT, IDS_EXIT);
523 } 537 }
524 } 538 }
525 #endif // !OS_CHROMEOS
526 539
527 void WrenchMenuModel::AddGlobalErrorMenuItems() { 540 void WrenchMenuModel::AddGlobalErrorMenuItems() {
528 // TODO(sail): Currently we only build the wrench menu once per browser 541 // TODO(sail): Currently we only build the wrench menu once per browser
529 // window. This means that if a new error is added after the menu is built 542 // window. This means that if a new error is added after the menu is built
530 // it won't show in the existing wrench menu. To fix this we need to some 543 // it won't show in the existing wrench menu. To fix this we need to some
531 // how update the menu if new errors are added. 544 // how update the menu if new errors are added.
532 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 545 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
533 const GlobalErrorService::GlobalErrorList& errors = 546 const GlobalErrorService::GlobalErrorList& errors =
534 GlobalErrorServiceFactory::GetForProfile(browser_->profile())->errors(); 547 GlobalErrorServiceFactory::GetForProfile(browser_->profile())->errors();
535 for (GlobalErrorService::GlobalErrorList::const_iterator 548 for (GlobalErrorService::GlobalErrorList::const_iterator
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 zoom_label_ = l10n_util::GetStringFUTF16( 587 zoom_label_ = l10n_util::GetStringFUTF16(
575 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); 588 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent));
576 } 589 }
577 590
578 string16 WrenchMenuModel::GetSyncMenuLabel() const { 591 string16 WrenchMenuModel::GetSyncMenuLabel() const {
579 Profile* profile = browser_->profile()->GetOriginalProfile(); 592 Profile* profile = browser_->profile()->GetOriginalProfile();
580 return sync_ui_util::GetSyncMenuLabel( 593 return sync_ui_util::GetSyncMenuLabel(
581 ProfileSyncServiceFactory::GetForProfile(profile), 594 ProfileSyncServiceFactory::GetForProfile(profile),
582 *SigninManagerFactory::GetForProfile(profile)); 595 *SigninManagerFactory::GetForProfile(profile));
583 } 596 }
OLDNEW
« no previous file with comments | « chrome/browser/defaults.cc ('k') | chrome/browser/ui/toolbar/wrench_menu_model_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698