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