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

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

Issue 10837317: Setting the touch wrench menu as default menu for ChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: And another merge! Created 8 years, 3 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
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 encoding_menu_controller.GetEncodingMenuItems(browser_->profile(), 90 encoding_menu_controller.GetEncodingMenuItems(browser_->profile(),
91 &encoding_menu_items); 91 &encoding_menu_items);
92 92
93 int group_id = 0; 93 int group_id = 0;
94 EncodingMenuController::EncodingMenuItemList::iterator it = 94 EncodingMenuController::EncodingMenuItemList::iterator it =
95 encoding_menu_items.begin(); 95 encoding_menu_items.begin();
96 for (; it != encoding_menu_items.end(); ++it) { 96 for (; it != encoding_menu_items.end(); ++it) {
97 int id = it->first; 97 int id = it->first;
98 string16& label = it->second; 98 string16& label = it->second;
99 if (id == 0) { 99 if (id == 0) {
100 AddSeparator(); 100 AddSeparator(ui::NORMAL_SEPARATOR);
101 } else { 101 } else {
102 if (id == IDC_ENCODING_AUTO_DETECT) { 102 if (id == IDC_ENCODING_AUTO_DETECT) {
103 AddCheckItem(id, label); 103 AddCheckItem(id, label);
104 } else { 104 } else {
105 // Use the id of the first radio command as the id of the group. 105 // Use the id of the first radio command as the id of the group.
106 if (group_id <= 0) 106 if (group_id <= 0)
107 group_id = id; 107 group_id = id;
108 AddRadioItem(id, label, group_id); 108 AddRadioItem(id, label, group_id);
109 } 109 }
110 } 110 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 Browser* browser) 165 Browser* browser)
166 : SimpleMenuModel(delegate) { 166 : SimpleMenuModel(delegate) {
167 Build(browser); 167 Build(browser);
168 } 168 }
169 169
170 ToolsMenuModel::~ToolsMenuModel() {} 170 ToolsMenuModel::~ToolsMenuModel() {}
171 171
172 void ToolsMenuModel::Build(Browser* browser) { 172 void ToolsMenuModel::Build(Browser* browser) {
173 #if !defined(OS_CHROMEOS) && !defined(OS_MACOSX) 173 #if !defined(OS_CHROMEOS) && !defined(OS_MACOSX)
174 AddItemWithStringId(IDC_CREATE_SHORTCUTS, IDS_CREATE_SHORTCUTS); 174 AddItemWithStringId(IDC_CREATE_SHORTCUTS, IDS_CREATE_SHORTCUTS);
175 AddSeparator(); 175 AddSeparator(ui::NORMAL_SEPARATOR);
176 #endif 176 #endif
177 177
178 AddItemWithStringId(IDC_MANAGE_EXTENSIONS, IDS_SHOW_EXTENSIONS); 178 AddItemWithStringId(IDC_MANAGE_EXTENSIONS, IDS_SHOW_EXTENSIONS);
179 179
180 if (chrome::CanOpenTaskManager()) 180 if (chrome::CanOpenTaskManager())
181 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); 181 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER);
182 182
183 AddItemWithStringId(IDC_CLEAR_BROWSING_DATA, IDS_CLEAR_BROWSING_DATA); 183 AddItemWithStringId(IDC_CLEAR_BROWSING_DATA, IDS_CLEAR_BROWSING_DATA);
184 184
185 AddSeparator(); 185 AddSeparator(ui::NORMAL_SEPARATOR);
186 186
187 #if !defined(OS_CHROMEOS) 187 #if !defined(OS_CHROMEOS)
188 // Show IDC_FEEDBACK in "Tools" menu for non-ChromeOS platforms. 188 // Show IDC_FEEDBACK in "Tools" menu for non-ChromeOS platforms.
189 AddItemWithStringId(IDC_FEEDBACK, IDS_FEEDBACK); 189 AddItemWithStringId(IDC_FEEDBACK, IDS_FEEDBACK);
190 AddSeparator(); 190 AddSeparator(ui::NORMAL_SEPARATOR);
191 #endif 191 #endif
192 192
193 encoding_menu_model_.reset(new EncodingMenuModel(browser)); 193 encoding_menu_model_.reset(new EncodingMenuModel(browser));
194 AddSubMenuWithStringId(IDC_ENCODING_MENU, IDS_ENCODING_MENU, 194 AddSubMenuWithStringId(IDC_ENCODING_MENU, IDS_ENCODING_MENU,
195 encoding_menu_model_.get()); 195 encoding_menu_model_.get());
196 AddItemWithStringId(IDC_VIEW_SOURCE, IDS_VIEW_SOURCE); 196 AddItemWithStringId(IDC_VIEW_SOURCE, IDS_VIEW_SOURCE);
197 AddItemWithStringId(IDC_DEV_TOOLS, IDS_DEV_TOOLS); 197 AddItemWithStringId(IDC_DEV_TOOLS, IDS_DEV_TOOLS);
198 AddItemWithStringId(IDC_DEV_TOOLS_CONSOLE, IDS_DEV_TOOLS_CONSOLE); 198 AddItemWithStringId(IDC_DEV_TOOLS_CONSOLE, IDS_DEV_TOOLS_CONSOLE);
199 199
200 #if defined(ENABLE_PROFILING) && !defined(NO_TCMALLOC) 200 #if defined(ENABLE_PROFILING) && !defined(NO_TCMALLOC)
201 AddSeparator(); 201 AddSeparator(ui::NORMAL_SEPARATOR);
202 AddCheckItemWithStringId(IDC_PROFILING_ENABLED, IDS_PROFILING_ENABLED); 202 AddCheckItemWithStringId(IDC_PROFILING_ENABLED, IDS_PROFILING_ENABLED);
203 #endif 203 #endif
204 } 204 }
205 205
206 //////////////////////////////////////////////////////////////////////////////// 206 ////////////////////////////////////////////////////////////////////////////////
207 // WrenchMenuModel 207 // WrenchMenuModel
208 208
209 WrenchMenuModel::WrenchMenuModel(ui::AcceleratorProvider* provider, 209 WrenchMenuModel::WrenchMenuModel(ui::AcceleratorProvider* provider,
210 Browser* browser) 210 Browser* browser)
211 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), 211 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)),
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 443
444 // For testing. 444 // For testing.
445 WrenchMenuModel::WrenchMenuModel() 445 WrenchMenuModel::WrenchMenuModel()
446 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), 446 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)),
447 provider_(NULL), 447 provider_(NULL),
448 browser_(NULL), 448 browser_(NULL),
449 tab_strip_model_(NULL) { 449 tab_strip_model_(NULL) {
450 } 450 }
451 451
452 void WrenchMenuModel::Build() { 452 void WrenchMenuModel::Build() {
453 bool is_touch_menu = ui::GetDisplayLayout() == ui::LAYOUT_TOUCH; 453 // TODO(skuhne): Remove special casing when only the new menu style is left.
454 #if defined(USE_AURA)
455 bool is_new_menu = true;
456 #else
457 bool is_new_menu = ui::GetDisplayLayout() == ui::LAYOUT_TOUCH;
458 #endif
459 if (is_new_menu)
460 AddSeparator(ui::SPACING_SEPARATOR);
454 461
455 AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); 462 AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB);
456 AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW); 463 AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW);
457 #if defined(OS_CHROMEOS) 464 #if defined(OS_CHROMEOS)
458 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) 465 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession))
459 AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW); 466 AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW);
460 #else 467 #else
461 AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW); 468 AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW);
462 #endif 469 #endif
463 470
464 AddItemWithStringId(IDC_PIN_TO_START_SCREEN, IDS_PIN_TO_START_SCREEN); 471 AddItemWithStringId(IDC_PIN_TO_START_SCREEN, IDS_PIN_TO_START_SCREEN);
465 bookmark_sub_menu_model_.reset(new BookmarkSubMenuModel(this, browser_)); 472 bookmark_sub_menu_model_.reset(new BookmarkSubMenuModel(this, browser_));
466 AddSubMenuWithStringId(IDC_BOOKMARKS_MENU, IDS_BOOKMARKS_MENU, 473 AddSubMenuWithStringId(IDC_BOOKMARKS_MENU, IDS_BOOKMARKS_MENU,
467 bookmark_sub_menu_model_.get()); 474 bookmark_sub_menu_model_.get());
468 475
469 // Append the full menu including separators. The final separator only gets 476 // Append the full menu including separators. The final separator only gets
470 // appended when this is a touch menu - otherwise it would get added twice. 477 // appended when this is a touch menu - otherwise it would get added twice.
471 CreateCutCopyPasteMenu(is_touch_menu); 478 CreateCutCopyPasteMenu(is_new_menu);
472 479
473 if (!is_touch_menu) 480 if (!is_new_menu)
474 CreateZoomMenu(); 481 CreateZoomMenu(is_new_menu);
475 482
476 AddItemWithStringId(IDC_SAVE_PAGE, IDS_SAVE_PAGE); 483 AddItemWithStringId(IDC_SAVE_PAGE, IDS_SAVE_PAGE);
477 AddItemWithStringId(IDC_FIND, IDS_FIND); 484 AddItemWithStringId(IDC_FIND, IDS_FIND);
478 AddItemWithStringId(IDC_PRINT, IDS_PRINT); 485 AddItemWithStringId(IDC_PRINT, IDS_PRINT);
479 486
480 tools_menu_model_.reset(new ToolsMenuModel(this, browser_)); 487 tools_menu_model_.reset(new ToolsMenuModel(this, browser_));
481 // In case of touch this is the last item. 488 // In case of touch this is the last item.
482 if (!is_touch_menu) { 489 if (!is_new_menu) {
483 AddSubMenuWithStringId(IDC_ZOOM_MENU, IDS_TOOLS_MENU, 490 AddSubMenuWithStringId(IDC_ZOOM_MENU, IDS_TOOLS_MENU,
484 tools_menu_model_.get()); 491 tools_menu_model_.get());
485 } 492 }
486 493
487 if (is_touch_menu) 494 if (is_new_menu)
488 CreateZoomMenu(); 495 CreateZoomMenu(is_new_menu);
489 else 496 else
490 AddSeparator(); 497 AddSeparator(ui::NORMAL_SEPARATOR);
491 498
492 AddItemWithStringId(IDC_SHOW_HISTORY, IDS_SHOW_HISTORY); 499 AddItemWithStringId(IDC_SHOW_HISTORY, IDS_SHOW_HISTORY);
493 AddItemWithStringId(IDC_SHOW_DOWNLOADS, IDS_SHOW_DOWNLOADS); 500 AddItemWithStringId(IDC_SHOW_DOWNLOADS, IDS_SHOW_DOWNLOADS);
494 AddSeparator(); 501 AddSeparator(ui::NORMAL_SEPARATOR);
495 502
496 if (browser_defaults::kShowSyncSetupMenuItem && 503 if (browser_defaults::kShowSyncSetupMenuItem &&
497 browser_->profile()->GetOriginalProfile()->IsSyncAccessible()) { 504 browser_->profile()->GetOriginalProfile()->IsSyncAccessible()) {
498 const string16 short_product_name = 505 const string16 short_product_name =
499 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); 506 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME);
500 AddItem(IDC_SHOW_SYNC_SETUP, l10n_util::GetStringFUTF16( 507 AddItem(IDC_SHOW_SYNC_SETUP, l10n_util::GetStringFUTF16(
501 IDS_SYNC_MENU_PRE_SYNCED_LABEL, short_product_name)); 508 IDS_SYNC_MENU_PRE_SYNCED_LABEL, short_product_name));
502 AddSeparator(); 509 AddSeparator(ui::NORMAL_SEPARATOR);
503 } 510 }
504 511
505 AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS); 512 AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS);
506 513
507 // On ChromeOS-Touch, we don't want the about/background pages menu options. 514 // On ChromeOS-Touch, we don't want the about/background pages menu options.
508 #if defined(OS_CHROMEOS) 515 #if defined(OS_CHROMEOS)
509 if (!is_touch_menu) 516 if (!is_new_menu)
510 #endif 517 #endif
511 { 518 {
512 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); 519 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT));
513 // We use the task manager to show background pages. 520 // We use the task manager to show background pages.
514 if (chrome::CanOpenTaskManager()) { 521 if (chrome::CanOpenTaskManager()) {
515 string16 num_background_pages = base::FormatNumber( 522 string16 num_background_pages = base::FormatNumber(
516 TaskManager::GetBackgroundPageCount()); 523 TaskManager::GetBackgroundPageCount());
517 AddItem(IDC_VIEW_BACKGROUND_PAGES, l10n_util::GetStringFUTF16( 524 AddItem(IDC_VIEW_BACKGROUND_PAGES, l10n_util::GetStringFUTF16(
518 IDS_VIEW_BACKGROUND_PAGES, num_background_pages)); 525 IDS_VIEW_BACKGROUND_PAGES, num_background_pages));
519 } 526 }
520 } 527 }
521 528
522 if (browser_defaults::kShowUpgradeMenuItem) 529 if (browser_defaults::kShowUpgradeMenuItem)
523 AddItem(IDC_UPGRADE_DIALOG, l10n_util::GetStringUTF16(IDS_UPDATE_NOW)); 530 AddItem(IDC_UPGRADE_DIALOG, l10n_util::GetStringUTF16(IDS_UPDATE_NOW));
524 AddItem(IDC_VIEW_INCOMPATIBILITIES, l10n_util::GetStringUTF16( 531 AddItem(IDC_VIEW_INCOMPATIBILITIES, l10n_util::GetStringUTF16(
525 IDS_VIEW_INCOMPATIBILITIES)); 532 IDS_VIEW_INCOMPATIBILITIES));
526 533
527 #if defined(OS_WIN) 534 #if defined(OS_WIN)
528 SetIcon(GetIndexOfCommandId(IDC_VIEW_INCOMPATIBILITIES), 535 SetIcon(GetIndexOfCommandId(IDC_VIEW_INCOMPATIBILITIES),
529 ui::ResourceBundle::GetSharedInstance(). 536 ui::ResourceBundle::GetSharedInstance().
530 GetNativeImageNamed(IDR_CONFLICT_MENU)); 537 GetNativeImageNamed(IDR_CONFLICT_MENU));
531 #endif 538 #endif
532 539
533 if (!is_touch_menu) { 540 if (!is_new_menu) {
534 AddItemWithStringId(IDC_HELP_PAGE_VIA_MENU, IDS_HELP_PAGE); 541 AddItemWithStringId(IDC_HELP_PAGE_VIA_MENU, IDS_HELP_PAGE);
535 542
536 if (browser_defaults::kShowHelpMenuItemIcon) { 543 if (browser_defaults::kShowHelpMenuItemIcon) {
537 ui::ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 544 ui::ResourceBundle& rb = ResourceBundle::GetSharedInstance();
538 SetIcon(GetIndexOfCommandId(IDC_HELP_PAGE_VIA_MENU), 545 SetIcon(GetIndexOfCommandId(IDC_HELP_PAGE_VIA_MENU),
539 rb.GetNativeImageNamed(IDR_HELP_MENU)); 546 rb.GetNativeImageNamed(IDR_HELP_MENU));
540 } 547 }
541 } 548 }
542 549
543 if (browser_defaults::kShowFeedbackMenuItem) 550 if (browser_defaults::kShowFeedbackMenuItem)
544 AddItemWithStringId(IDC_FEEDBACK, IDS_FEEDBACK); 551 AddItemWithStringId(IDC_FEEDBACK, IDS_FEEDBACK);
545 552
546 AddGlobalErrorMenuItems(); 553 AddGlobalErrorMenuItems();
547 554
548 if (is_touch_menu) { 555 if (is_new_menu) {
549 AddSubMenuWithStringId(IDC_ZOOM_MENU, IDS_MORE_TOOLS_MENU, 556 AddSubMenuWithStringId(IDC_ZOOM_MENU, IDS_MORE_TOOLS_MENU,
550 tools_menu_model_.get()); 557 tools_menu_model_.get());
551 } 558 }
552 559
553 if (browser_defaults::kShowExitMenuItem) { 560 if (browser_defaults::kShowExitMenuItem) {
554 #if defined(OS_WIN) 561 #if defined(OS_WIN)
555 if (!base::win::IsMetroProcess()) 562 if (!base::win::IsMetroProcess())
556 #endif 563 #endif
557 { 564 {
558 AddSeparator(); 565 AddSeparator(ui::NORMAL_SEPARATOR);
559 AddItemWithStringId(IDC_EXIT, IDS_EXIT); 566 AddItemWithStringId(IDC_EXIT, IDS_EXIT);
560 } 567 }
561 } 568 }
569
570 if (is_new_menu)
571 AddSeparator(ui::SPACING_SEPARATOR);
562 } 572 }
563 573
564 void WrenchMenuModel::AddGlobalErrorMenuItems() { 574 void WrenchMenuModel::AddGlobalErrorMenuItems() {
565 // TODO(sail): Currently we only build the wrench menu once per browser 575 // TODO(sail): Currently we only build the wrench menu once per browser
566 // window. This means that if a new error is added after the menu is built 576 // window. This means that if a new error is added after the menu is built
567 // it won't show in the existing wrench menu. To fix this we need to some 577 // it won't show in the existing wrench menu. To fix this we need to some
568 // how update the menu if new errors are added. 578 // how update the menu if new errors are added.
569 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 579 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
570 const GlobalErrorService::GlobalErrorList& errors = 580 const GlobalErrorService::GlobalErrorList& errors =
571 GlobalErrorServiceFactory::GetForProfile(browser_->profile())->errors(); 581 GlobalErrorServiceFactory::GetForProfile(browser_->profile())->errors();
572 for (GlobalErrorService::GlobalErrorList::const_iterator 582 for (GlobalErrorService::GlobalErrorList::const_iterator
573 it = errors.begin(); it != errors.end(); ++it) { 583 it = errors.begin(); it != errors.end(); ++it) {
574 GlobalError* error = *it; 584 GlobalError* error = *it;
575 if (error->HasMenuItem()) { 585 if (error->HasMenuItem()) {
576 AddItem(error->MenuItemCommandID(), error->MenuItemLabel()); 586 AddItem(error->MenuItemCommandID(), error->MenuItemLabel());
577 int icon_id = error->MenuItemIconResourceID(); 587 int icon_id = error->MenuItemIconResourceID();
578 if (icon_id) { 588 if (icon_id) {
579 const gfx::Image& image = rb.GetNativeImageNamed(icon_id); 589 const gfx::Image& image = rb.GetNativeImageNamed(icon_id);
580 SetIcon(GetIndexOfCommandId(error->MenuItemCommandID()), 590 SetIcon(GetIndexOfCommandId(error->MenuItemCommandID()),
581 image); 591 image);
582 } 592 }
583 } 593 }
584 } 594 }
585 } 595 }
586 596
587 void WrenchMenuModel::CreateCutCopyPasteMenu(bool append_final_separator) { 597 void WrenchMenuModel::CreateCutCopyPasteMenu(bool new_menu) {
588 AddSeparator(); 598 AddSeparator(new_menu ? ui::LOWER_SEPARATOR: ui::NORMAL_SEPARATOR);
589 599
590 #if defined(OS_POSIX) && !defined(TOOLKIT_VIEWS) 600 #if defined(OS_POSIX) && !defined(TOOLKIT_VIEWS)
591 // WARNING: Mac does not use the ButtonMenuItemModel, but instead defines the 601 // WARNING: Mac does not use the ButtonMenuItemModel, but instead defines the
592 // layout for this menu item in Toolbar.xib. It does, however, use the 602 // layout for this menu item in Toolbar.xib. It does, however, use the
593 // command_id value from AddButtonItem() to identify this special item. 603 // command_id value from AddButtonItem() to identify this special item.
594 edit_menu_item_model_.reset(new ui::ButtonMenuItemModel(IDS_EDIT, this)); 604 edit_menu_item_model_.reset(new ui::ButtonMenuItemModel(IDS_EDIT, this));
595 edit_menu_item_model_->AddGroupItemWithStringId(IDC_CUT, IDS_CUT); 605 edit_menu_item_model_->AddGroupItemWithStringId(IDC_CUT, IDS_CUT);
596 edit_menu_item_model_->AddGroupItemWithStringId(IDC_COPY, IDS_COPY); 606 edit_menu_item_model_->AddGroupItemWithStringId(IDC_COPY, IDS_COPY);
597 edit_menu_item_model_->AddGroupItemWithStringId(IDC_PASTE, IDS_PASTE); 607 edit_menu_item_model_->AddGroupItemWithStringId(IDC_PASTE, IDS_PASTE);
598 AddButtonItem(IDC_EDIT_MENU, edit_menu_item_model_.get()); 608 AddButtonItem(IDC_EDIT_MENU, edit_menu_item_model_.get());
599 #else 609 #else
600 // WARNING: views/wrench_menu assumes these items are added in this order. If 610 // WARNING: views/wrench_menu assumes these items are added in this order. If
601 // you change the order you'll need to update wrench_menu as well. 611 // you change the order you'll need to update wrench_menu as well.
602 AddItemWithStringId(IDC_CUT, IDS_CUT); 612 AddItemWithStringId(IDC_CUT, IDS_CUT);
603 AddItemWithStringId(IDC_COPY, IDS_COPY); 613 AddItemWithStringId(IDC_COPY, IDS_COPY);
604 AddItemWithStringId(IDC_PASTE, IDS_PASTE); 614 AddItemWithStringId(IDC_PASTE, IDS_PASTE);
605 #endif 615 #endif
606 616
607 if (append_final_separator) 617 if (new_menu)
608 AddSeparator(); 618 AddSeparator(ui::UPPER_SEPARATOR);
609 } 619 }
610 620
611 void WrenchMenuModel::CreateZoomMenu() { 621 void WrenchMenuModel::CreateZoomMenu(bool new_menu) {
612 // This menu needs to be enclosed by separators. 622 // This menu needs to be enclosed by separators.
613 AddSeparator(); 623 AddSeparator(new_menu ? ui::LOWER_SEPARATOR: ui::NORMAL_SEPARATOR);
614 624
615 #if defined(OS_POSIX) && !defined(TOOLKIT_VIEWS) 625 #if defined(OS_POSIX) && !defined(TOOLKIT_VIEWS)
616 // WARNING: Mac does not use the ButtonMenuItemModel, but instead defines the 626 // WARNING: Mac does not use the ButtonMenuItemModel, but instead defines the
617 // layout for this menu item in Toolbar.xib. It does, however, use the 627 // layout for this menu item in Toolbar.xib. It does, however, use the
618 // command_id value from AddButtonItem() to identify this special item. 628 // command_id value from AddButtonItem() to identify this special item.
619 zoom_menu_item_model_.reset( 629 zoom_menu_item_model_.reset(
620 new ui::ButtonMenuItemModel(IDS_ZOOM_MENU, this)); 630 new ui::ButtonMenuItemModel(IDS_ZOOM_MENU, this));
621 zoom_menu_item_model_->AddGroupItemWithStringId( 631 zoom_menu_item_model_->AddGroupItemWithStringId(
622 IDC_ZOOM_MINUS, IDS_ZOOM_MINUS2); 632 IDC_ZOOM_MINUS, IDS_ZOOM_MINUS2);
623 zoom_menu_item_model_->AddButtonLabel(IDC_ZOOM_PERCENT_DISPLAY, 633 zoom_menu_item_model_->AddButtonLabel(IDC_ZOOM_PERCENT_DISPLAY,
624 IDS_ZOOM_PLUS2); 634 IDS_ZOOM_PLUS2);
625 zoom_menu_item_model_->AddGroupItemWithStringId( 635 zoom_menu_item_model_->AddGroupItemWithStringId(
626 IDC_ZOOM_PLUS, IDS_ZOOM_PLUS2); 636 IDC_ZOOM_PLUS, IDS_ZOOM_PLUS2);
627 zoom_menu_item_model_->AddSpace(); 637 zoom_menu_item_model_->AddSpace();
628 zoom_menu_item_model_->AddItemWithImage( 638 zoom_menu_item_model_->AddItemWithImage(
629 IDC_FULLSCREEN, IDR_FULLSCREEN_MENU_BUTTON); 639 IDC_FULLSCREEN, IDR_FULLSCREEN_MENU_BUTTON);
630 AddButtonItem(IDC_ZOOM_MENU, zoom_menu_item_model_.get()); 640 AddButtonItem(IDC_ZOOM_MENU, zoom_menu_item_model_.get());
631 #else 641 #else
632 // WARNING: views/wrench_menu assumes these items are added in this order. If 642 // WARNING: views/wrench_menu assumes these items are added in this order. If
633 // you change the order you'll need to update wrench_menu as well. 643 // you change the order you'll need to update wrench_menu as well.
634 AddItemWithStringId(IDC_ZOOM_MINUS, IDS_ZOOM_MINUS); 644 AddItemWithStringId(IDC_ZOOM_MINUS, IDS_ZOOM_MINUS);
635 AddItemWithStringId(IDC_ZOOM_PLUS, IDS_ZOOM_PLUS); 645 AddItemWithStringId(IDC_ZOOM_PLUS, IDS_ZOOM_PLUS);
636 AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN); 646 AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN);
637 #endif 647 #endif
638 648
639 AddSeparator(); 649 AddSeparator(new_menu ? ui::UPPER_SEPARATOR: ui::NORMAL_SEPARATOR);
640 } 650 }
641 651
642 void WrenchMenuModel::UpdateZoomControls() { 652 void WrenchMenuModel::UpdateZoomControls() {
643 bool enable_increment = false; 653 bool enable_increment = false;
644 bool enable_decrement = false; 654 bool enable_decrement = false;
645 int zoom_percent = 100; 655 int zoom_percent = 100;
646 if (chrome::GetActiveWebContents(browser_)) { 656 if (chrome::GetActiveWebContents(browser_)) {
647 zoom_percent = chrome::GetActiveWebContents(browser_)->GetZoomPercent( 657 zoom_percent = chrome::GetActiveWebContents(browser_)->GetZoomPercent(
648 &enable_increment, &enable_decrement); 658 &enable_increment, &enable_decrement);
649 } 659 }
650 zoom_label_ = l10n_util::GetStringFUTF16( 660 zoom_label_ = l10n_util::GetStringFUTF16(
651 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); 661 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent));
652 } 662 }
653 663
654 string16 WrenchMenuModel::GetSyncMenuLabel() const { 664 string16 WrenchMenuModel::GetSyncMenuLabel() const {
655 Profile* profile = browser_->profile()->GetOriginalProfile(); 665 Profile* profile = browser_->profile()->GetOriginalProfile();
656 return sync_ui_util::GetSyncMenuLabel( 666 return sync_ui_util::GetSyncMenuLabel(
657 ProfileSyncServiceFactory::GetForProfile(profile), 667 ProfileSyncServiceFactory::GetForProfile(profile),
658 *SigninManagerFactory::GetForProfile(profile)); 668 *SigninManagerFactory::GetForProfile(profile));
659 } 669 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/wrench_menu_model.h ('k') | chrome/browser/ui/toolbar/wrench_menu_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698