Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / tabs / tab_menu_model.cc
blobba70eac9ac2c9f5cb39d408af6ccbf112950d374
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.
5 #include "chrome/browser/ui/tabs/tab_menu_model.h"
7 #include "base/command_line.h"
8 #include "chrome/browser/ui/tabs/tab_strip_model.h"
9 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h"
10 #include "chrome/browser/ui/tabs/tab_utils.h"
11 #include "chrome/grit/generated_resources.h"
13 TabMenuModel::TabMenuModel(ui::SimpleMenuModel::Delegate* delegate,
14 TabStripModel* tab_strip,
15 int index)
16 : ui::SimpleMenuModel(delegate) {
17 Build(tab_strip, index);
20 void TabMenuModel::Build(TabStripModel* tab_strip, int index) {
21 bool affects_multiple_tabs =
22 (tab_strip->IsTabSelected(index) &&
23 tab_strip->selection_model().selected_indices().size() > 1);
24 AddItemWithStringId(TabStripModel::CommandNewTab, IDS_TAB_CXMENU_NEWTAB);
25 AddSeparator(ui::NORMAL_SEPARATOR);
26 AddItemWithStringId(TabStripModel::CommandReload, IDS_TAB_CXMENU_RELOAD);
27 AddItemWithStringId(TabStripModel::CommandDuplicate,
28 IDS_TAB_CXMENU_DUPLICATE);
29 bool will_pin = tab_strip->WillContextMenuPin(index);
30 if (affects_multiple_tabs) {
31 AddItemWithStringId(
32 TabStripModel::CommandTogglePinned,
33 will_pin ? IDS_TAB_CXMENU_PIN_TABS : IDS_TAB_CXMENU_UNPIN_TABS);
34 } else {
35 AddItemWithStringId(
36 TabStripModel::CommandTogglePinned,
37 will_pin ? IDS_TAB_CXMENU_PIN_TAB : IDS_TAB_CXMENU_UNPIN_TAB);
39 if (chrome::IsTabAudioMutingFeatureEnabled()) {
40 if (affects_multiple_tabs) {
41 const bool will_mute = !chrome::AreAllTabsMuted(
42 *tab_strip, tab_strip->selection_model().selected_indices());
43 AddItemWithStringId(
44 TabStripModel::CommandToggleTabAudioMuted,
45 will_mute ? IDS_TAB_CXMENU_AUDIO_MUTE_TABS :
46 IDS_TAB_CXMENU_AUDIO_UNMUTE_TABS);
47 } else {
48 const bool will_mute =
49 !chrome::IsTabAudioMuted(tab_strip->GetWebContentsAt(index));
50 AddItemWithStringId(
51 TabStripModel::CommandToggleTabAudioMuted,
52 will_mute ? IDS_TAB_CXMENU_AUDIO_MUTE_TAB :
53 IDS_TAB_CXMENU_AUDIO_UNMUTE_TAB);
56 AddSeparator(ui::NORMAL_SEPARATOR);
57 if (affects_multiple_tabs) {
58 AddItemWithStringId(TabStripModel::CommandCloseTab,
59 IDS_TAB_CXMENU_CLOSETABS);
60 } else {
61 AddItemWithStringId(TabStripModel::CommandCloseTab,
62 IDS_TAB_CXMENU_CLOSETAB);
64 AddItemWithStringId(TabStripModel::CommandCloseOtherTabs,
65 IDS_TAB_CXMENU_CLOSEOTHERTABS);
66 AddItemWithStringId(TabStripModel::CommandCloseTabsToRight,
67 IDS_TAB_CXMENU_CLOSETABSTORIGHT);
68 AddSeparator(ui::NORMAL_SEPARATOR);
69 const bool is_window = tab_strip->delegate()->GetRestoreTabType() ==
70 TabStripModelDelegate::RESTORE_WINDOW;
71 AddItemWithStringId(TabStripModel::CommandRestoreTab,
72 is_window ? IDS_RESTORE_WINDOW : IDS_RESTORE_TAB);
73 AddItemWithStringId(TabStripModel::CommandBookmarkAllTabs,
74 IDS_TAB_CXMENU_BOOKMARK_ALL_TABS);