| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" | |
| 6 | |
| 7 #include "base/command_line.h" | |
| 8 #include "base/i18n/number_formatting.h" | |
| 9 #include "chrome/app/chrome_command_ids.h" | |
| 10 #include "chrome/browser/chromeos/login/user_manager.h" | |
| 11 #include "chrome/browser/task_manager/task_manager.h" | |
| 12 #include "chrome/common/chrome_switches.h" | |
| 13 #include "grit/chromium_strings.h" | |
| 14 #include "grit/generated_resources.h" | |
| 15 #include "grit/theme_resources.h" | |
| 16 #include "ui/base/l10n/l10n_util.h" | |
| 17 #include "ui/base/resource/resource_bundle.h" | |
| 18 | |
| 19 void WrenchMenuModel::Build() { | |
| 20 AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); | |
| 21 AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW); | |
| 22 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) | |
| 23 AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW); | |
| 24 | |
| 25 AddSeparator(); | |
| 26 CreateCutCopyPaste(); | |
| 27 | |
| 28 AddSeparator(); | |
| 29 CreateZoomFullscreen(); | |
| 30 | |
| 31 AddSeparator(); | |
| 32 AddItemWithStringId(IDC_SAVE_PAGE, IDS_SAVE_PAGE); | |
| 33 AddItemWithStringId(IDC_FIND, IDS_FIND); | |
| 34 AddItemWithStringId(IDC_PRINT, IDS_PRINT); | |
| 35 | |
| 36 tools_menu_model_.reset(new ToolsMenuModel(this, browser_)); | |
| 37 AddSubMenuWithStringId(IDC_ZOOM_MENU, IDS_TOOLS_MENU, | |
| 38 tools_menu_model_.get()); | |
| 39 | |
| 40 AddSeparator(); | |
| 41 | |
| 42 bookmark_sub_menu_model_.reset(new BookmarkSubMenuModel(this, browser_)); | |
| 43 AddSubMenuWithStringId(IDC_BOOKMARKS_MENU, IDS_BOOKMARKS_MENU, | |
| 44 bookmark_sub_menu_model_.get()); | |
| 45 AddItemWithStringId(IDC_SHOW_HISTORY, IDS_SHOW_HISTORY); | |
| 46 AddItemWithStringId(IDC_SHOW_DOWNLOADS, IDS_SHOW_DOWNLOADS); | |
| 47 | |
| 48 AddSeparator(); | |
| 49 | |
| 50 AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS); | |
| 51 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); | |
| 52 string16 num_background_pages = base::FormatNumber( | |
| 53 TaskManager::GetBackgroundPageCount()); | |
| 54 AddItem(IDC_VIEW_BACKGROUND_PAGES, | |
| 55 l10n_util::GetStringFUTF16(IDS_VIEW_BACKGROUND_PAGES, | |
| 56 num_background_pages)); | |
| 57 AddItem(IDC_VIEW_INCOMPATIBILITIES, | |
| 58 l10n_util::GetStringUTF16(IDS_VIEW_INCOMPATIBILITIES)); | |
| 59 | |
| 60 // Use an icon for IDC_HELP_PAGE menu item. | |
| 61 AddItemWithStringId(IDC_HELP_PAGE, IDS_HELP_PAGE); | |
| 62 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | |
| 63 SetIcon(GetIndexOfCommandId(IDC_HELP_PAGE), | |
| 64 *rb.GetBitmapNamed(IDR_HELP_MENU)); | |
| 65 | |
| 66 // Show IDC_FEEDBACK in top-tier wrench menu for ChromeOS. | |
| 67 AddItemWithStringId(IDC_FEEDBACK, IDS_FEEDBACK); | |
| 68 | |
| 69 AddGlobalErrorMenuItems(); | |
| 70 | |
| 71 #if !defined(USE_ASH) | |
| 72 AddSeparator(); | |
| 73 | |
| 74 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { | |
| 75 AddItemWithStringId(IDC_EXIT, IDS_EXIT_GUEST_MODE); | |
| 76 AddItemWithStringId(IDC_SHUTDOWN, IDS_SHUTDOWN_BUTTON); | |
| 77 } else if (chromeos::UserManager::Get()->IsLoggedInAsDemoUser()) { | |
| 78 AddItemWithStringId(IDC_EXIT, IDS_SIGN_OUT); | |
| 79 } else { | |
| 80 AddItemWithStringId(IDC_LOCK_SCREEN, IDS_LOCK_SCREEN); | |
| 81 AddItemWithStringId(IDC_EXIT, IDS_SIGN_OUT); | |
| 82 AddItemWithStringId(IDC_SHUTDOWN, IDS_SHUTDOWN_BUTTON); | |
| 83 } | |
| 84 #endif | |
| 85 } | |
| 86 | |
| OLD | NEW |