| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/tabs/tab_menu_model.h" | 5 #include "chrome/browser/ui/tabs/tab_menu_model.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/tabs/tab_strip_model.h" | 8 #include "chrome/browser/tabs/tab_strip_model.h" |
| 9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
| 10 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // static | 25 // static |
| 26 bool TabMenuModel::AreVerticalTabsEnabled() { | 26 bool TabMenuModel::AreVerticalTabsEnabled() { |
| 27 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) || defined(OS_CHROMEOS) | 27 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) || defined(OS_CHROMEOS) |
| 28 return CommandLine::ForCurrentProcess()->HasSwitch( | 28 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 29 switches::kEnableVerticalTabs); | 29 switches::kEnableVerticalTabs); |
| 30 #else | 30 #else |
| 31 return false; | 31 return false; |
| 32 #endif | 32 #endif |
| 33 } | 33 } |
| 34 | 34 |
| 35 bool TabMenuModel::IsCompactNavigationModeEnabled() { |
| 36 #if defined(TOOLKIT_VIEWS) |
| 37 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 38 switches::kEnableCompactNavigation); |
| 39 #else |
| 40 return false; |
| 41 #endif |
| 42 } |
| 43 |
| 44 |
| 35 void TabMenuModel::Build(bool is_pinned) { | 45 void TabMenuModel::Build(bool is_pinned) { |
| 36 AddItemWithStringId(TabStripModel::CommandNewTab, IDS_TAB_CXMENU_NEWTAB); | 46 AddItemWithStringId(TabStripModel::CommandNewTab, IDS_TAB_CXMENU_NEWTAB); |
| 37 AddSeparator(); | 47 AddSeparator(); |
| 38 AddItemWithStringId(TabStripModel::CommandReload, IDS_TAB_CXMENU_RELOAD); | 48 AddItemWithStringId(TabStripModel::CommandReload, IDS_TAB_CXMENU_RELOAD); |
| 39 AddItemWithStringId(TabStripModel::CommandDuplicate, | 49 AddItemWithStringId(TabStripModel::CommandDuplicate, |
| 40 IDS_TAB_CXMENU_DUPLICATE); | 50 IDS_TAB_CXMENU_DUPLICATE); |
| 41 AddItemWithStringId( | 51 AddItemWithStringId( |
| 42 TabStripModel::CommandTogglePinned, | 52 TabStripModel::CommandTogglePinned, |
| 43 is_pinned ? IDS_TAB_CXMENU_UNPIN_TAB : IDS_TAB_CXMENU_PIN_TAB); | 53 is_pinned ? IDS_TAB_CXMENU_UNPIN_TAB : IDS_TAB_CXMENU_PIN_TAB); |
| 44 AddSeparator(); | 54 AddSeparator(); |
| 45 AddItemWithStringId(TabStripModel::CommandCloseTab, | 55 AddItemWithStringId(TabStripModel::CommandCloseTab, |
| 46 IDS_TAB_CXMENU_CLOSETAB); | 56 IDS_TAB_CXMENU_CLOSETAB); |
| 47 AddItemWithStringId(TabStripModel::CommandCloseOtherTabs, | 57 AddItemWithStringId(TabStripModel::CommandCloseOtherTabs, |
| 48 IDS_TAB_CXMENU_CLOSEOTHERTABS); | 58 IDS_TAB_CXMENU_CLOSEOTHERTABS); |
| 49 AddItemWithStringId(TabStripModel::CommandCloseTabsToRight, | 59 AddItemWithStringId(TabStripModel::CommandCloseTabsToRight, |
| 50 IDS_TAB_CXMENU_CLOSETABSTORIGHT); | 60 IDS_TAB_CXMENU_CLOSETABSTORIGHT); |
| 51 AddSeparator(); | 61 AddSeparator(); |
| 52 AddItemWithStringId(TabStripModel::CommandRestoreTab, IDS_RESTORE_TAB); | 62 AddItemWithStringId(TabStripModel::CommandRestoreTab, IDS_RESTORE_TAB); |
| 53 AddItemWithStringId(TabStripModel::CommandBookmarkAllTabs, | 63 AddItemWithStringId(TabStripModel::CommandBookmarkAllTabs, |
| 54 IDS_TAB_CXMENU_BOOKMARK_ALL_TABS); | 64 IDS_TAB_CXMENU_BOOKMARK_ALL_TABS); |
| 55 if (AreVerticalTabsEnabled()) { | 65 if (AreVerticalTabsEnabled() || IsCompactNavigationModeEnabled()) { |
| 56 AddSeparator(); | 66 AddSeparator(); |
| 57 AddCheckItemWithStringId(TabStripModel::CommandUseVerticalTabs, | 67 if (AreVerticalTabsEnabled()) { |
| 58 IDS_TAB_CXMENU_USE_VERTICAL_TABS); | 68 AddCheckItemWithStringId(TabStripModel::CommandUseVerticalTabs, |
| 69 IDS_TAB_CXMENU_USE_VERTICAL_TABS); |
| 70 } |
| 71 if (IsCompactNavigationModeEnabled()) { |
| 72 AddCheckItemWithStringId(TabStripModel::CommandUseCompactNavigationBar, |
| 73 IDS_TAB_CXMENU_USE_COMPACT_NAVIGATION_BAR); |
| 74 } |
| 59 } | 75 } |
| 60 } | 76 } |
| 61 | 77 |
| 62 void TabMenuModel::Build(TabStripModel* tab_strip, int index) { | 78 void TabMenuModel::Build(TabStripModel* tab_strip, int index) { |
| 63 bool affects_multiple_tabs = | 79 bool affects_multiple_tabs = |
| 64 (tab_strip->IsTabSelected(index) && | 80 (tab_strip->IsTabSelected(index) && |
| 65 tab_strip->selection_model().selected_indices().size() > 1); | 81 tab_strip->selection_model().selected_indices().size() > 1); |
| 66 AddItemWithStringId(TabStripModel::CommandNewTab, IDS_TAB_CXMENU_NEWTAB); | 82 AddItemWithStringId(TabStripModel::CommandNewTab, IDS_TAB_CXMENU_NEWTAB); |
| 67 AddSeparator(); | 83 AddSeparator(); |
| 68 AddItemWithStringId(TabStripModel::CommandReload, IDS_TAB_CXMENU_RELOAD); | 84 AddItemWithStringId(TabStripModel::CommandReload, IDS_TAB_CXMENU_RELOAD); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 87 IDS_TAB_CXMENU_CLOSETAB); | 103 IDS_TAB_CXMENU_CLOSETAB); |
| 88 } | 104 } |
| 89 AddItemWithStringId(TabStripModel::CommandCloseOtherTabs, | 105 AddItemWithStringId(TabStripModel::CommandCloseOtherTabs, |
| 90 IDS_TAB_CXMENU_CLOSEOTHERTABS); | 106 IDS_TAB_CXMENU_CLOSEOTHERTABS); |
| 91 AddItemWithStringId(TabStripModel::CommandCloseTabsToRight, | 107 AddItemWithStringId(TabStripModel::CommandCloseTabsToRight, |
| 92 IDS_TAB_CXMENU_CLOSETABSTORIGHT); | 108 IDS_TAB_CXMENU_CLOSETABSTORIGHT); |
| 93 AddSeparator(); | 109 AddSeparator(); |
| 94 AddItemWithStringId(TabStripModel::CommandRestoreTab, IDS_RESTORE_TAB); | 110 AddItemWithStringId(TabStripModel::CommandRestoreTab, IDS_RESTORE_TAB); |
| 95 AddItemWithStringId(TabStripModel::CommandBookmarkAllTabs, | 111 AddItemWithStringId(TabStripModel::CommandBookmarkAllTabs, |
| 96 IDS_TAB_CXMENU_BOOKMARK_ALL_TABS); | 112 IDS_TAB_CXMENU_BOOKMARK_ALL_TABS); |
| 97 if (AreVerticalTabsEnabled()) { | 113 if (AreVerticalTabsEnabled() || IsCompactNavigationModeEnabled()) { |
| 98 AddSeparator(); | 114 AddSeparator(); |
| 99 AddCheckItemWithStringId(TabStripModel::CommandUseVerticalTabs, | 115 if (AreVerticalTabsEnabled()) { |
| 100 IDS_TAB_CXMENU_USE_VERTICAL_TABS); | 116 AddCheckItemWithStringId(TabStripModel::CommandUseVerticalTabs, |
| 117 IDS_TAB_CXMENU_USE_VERTICAL_TABS); |
| 118 } |
| 119 if (IsCompactNavigationModeEnabled()) { |
| 120 AddCheckItemWithStringId(TabStripModel::CommandUseCompactNavigationBar, |
| 121 IDS_TAB_CXMENU_USE_COMPACT_NAVIGATION_BAR); |
| 122 } |
| 101 } | 123 } |
| 102 if (CommandLine::ForCurrentProcess()->HasSwitch( | 124 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 103 switches::kEnableTabGroupsContextMenu)) { | 125 switches::kEnableTabGroupsContextMenu)) { |
| 104 AddSeparator(); | 126 AddSeparator(); |
| 105 AddItemWithStringId(TabStripModel::CommandSelectByDomain, | 127 AddItemWithStringId(TabStripModel::CommandSelectByDomain, |
| 106 IDS_TAB_CXMENU_SELECT_BY_DOMAIN); | 128 IDS_TAB_CXMENU_SELECT_BY_DOMAIN); |
| 107 AddItemWithStringId(TabStripModel::CommandSelectByOpener, | 129 AddItemWithStringId(TabStripModel::CommandSelectByOpener, |
| 108 IDS_TAB_CXMENU_SELECT_BY_OPENER); | 130 IDS_TAB_CXMENU_SELECT_BY_OPENER); |
| 109 } | 131 } |
| 110 } | 132 } |
| OLD | NEW |