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

Side by Side Diff: chrome/browser/ui/ash/launcher/extension_launcher_context_menu.cc

Issue 2518423003: Combine shelf platform and windowed app types. (Closed)
Patch Set: Refinements and cleanup. Created 4 years 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ash/launcher/extension_launcher_context_menu.h" 5 #include "chrome/browser/ui/ash/launcher/extension_launcher_context_menu.h"
6 6
7 #include "ash/common/shelf/shelf_item_delegate.h" 7 #include "ash/common/shelf/shelf_item_delegate.h"
8 #include "ash/common/wm_shell.h" 8 #include "ash/common/wm_shell.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "chrome/browser/extensions/context_menu_matcher.h" 10 #include "chrome/browser/extensions/context_menu_matcher.h"
(...skipping 23 matching lines...) Expand all
34 : LauncherContextMenu(controller, item, wm_shelf) { 34 : LauncherContextMenu(controller, item, wm_shelf) {
35 Init(); 35 Init();
36 } 36 }
37 37
38 ExtensionLauncherContextMenu::~ExtensionLauncherContextMenu() {} 38 ExtensionLauncherContextMenu::~ExtensionLauncherContextMenu() {}
39 39
40 void ExtensionLauncherContextMenu::Init() { 40 void ExtensionLauncherContextMenu::Init() {
41 extension_items_.reset(new extensions::ContextMenuMatcher( 41 extension_items_.reset(new extensions::ContextMenuMatcher(
42 controller()->profile(), this, this, 42 controller()->profile(), this, this,
43 base::Bind(MenuItemHasLauncherContext))); 43 base::Bind(MenuItemHasLauncherContext)));
44 if (item().type == ash::TYPE_APP_SHORTCUT || 44 if (item().type == ash::TYPE_APP_SHORTCUT || item().type == ash::TYPE_APP) {
45 item().type == ash::TYPE_WINDOWED_APP) {
46 // V1 apps can be started from the menu - but V2 apps should not. 45 // V1 apps can be started from the menu - but V2 apps should not.
47 if (!controller()->IsPlatformApp(item().id)) { 46 if (!controller()->IsPlatformApp(item().id)) {
48 AddItem(MENU_OPEN_NEW, base::string16()); 47 AddItem(MENU_OPEN_NEW, base::string16());
49 AddSeparator(ui::NORMAL_SEPARATOR); 48 AddSeparator(ui::NORMAL_SEPARATOR);
50 } 49 }
50
51 AddPinMenu(); 51 AddPinMenu();
52 if (controller()->IsOpen(item().id)) 52
53 if (controller()->IsOpen(item().id) &&
54 !extension_misc::IsImeMenuExtensionId(
55 controller()->GetAppIDForShelfID(item().id))) {
53 AddItemWithStringId(MENU_CLOSE, IDS_LAUNCHER_CONTEXT_MENU_CLOSE); 56 AddItemWithStringId(MENU_CLOSE, IDS_LAUNCHER_CONTEXT_MENU_CLOSE);
57 }
54 58
55 if (!controller()->IsPlatformApp(item().id) && 59 if (!controller()->IsPlatformApp(item().id) &&
56 item().type != ash::TYPE_WINDOWED_APP) { 60 item().type == ash::TYPE_APP_SHORTCUT) {
57 AddSeparator(ui::NORMAL_SEPARATOR); 61 AddSeparator(ui::NORMAL_SEPARATOR);
58 if (extensions::util::IsNewBookmarkAppsEnabled()) { 62 if (extensions::util::IsNewBookmarkAppsEnabled()) {
59 // With bookmark apps enabled, hosted apps launch in a window by 63 // With bookmark apps enabled, hosted apps launch in a window by
60 // default. This menu item is re-interpreted as a single, toggle-able 64 // default. This menu item is re-interpreted as a single, toggle-able
61 // option to launch the hosted app as a tab. 65 // option to launch the hosted app as a tab.
62 AddCheckItemWithStringId(LAUNCH_TYPE_WINDOW, 66 AddCheckItemWithStringId(LAUNCH_TYPE_WINDOW,
63 IDS_APP_CONTEXT_MENU_OPEN_WINDOW); 67 IDS_APP_CONTEXT_MENU_OPEN_WINDOW);
64 } else { 68 } else {
65 AddCheckItemWithStringId(LAUNCH_TYPE_REGULAR_TAB, 69 AddCheckItemWithStringId(LAUNCH_TYPE_REGULAR_TAB,
66 IDS_APP_CONTEXT_MENU_OPEN_REGULAR); 70 IDS_APP_CONTEXT_MENU_OPEN_REGULAR);
(...skipping 15 matching lines...) Expand all
82 } 86 }
83 if (!BrowserShortcutLauncherItemController( 87 if (!BrowserShortcutLauncherItemController(
84 controller(), ash::WmShell::Get()->shelf_model()) 88 controller(), ash::WmShell::Get()->shelf_model())
85 .IsListOfActiveBrowserEmpty()) { 89 .IsListOfActiveBrowserEmpty()) {
86 AddItem(MENU_CLOSE, 90 AddItem(MENU_CLOSE,
87 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_CLOSE)); 91 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_CLOSE));
88 } 92 }
89 } else if (item().type == ash::TYPE_DIALOG) { 93 } else if (item().type == ash::TYPE_DIALOG) {
90 AddItemWithStringId(MENU_CLOSE, IDS_LAUNCHER_CONTEXT_MENU_CLOSE); 94 AddItemWithStringId(MENU_CLOSE, IDS_LAUNCHER_CONTEXT_MENU_CLOSE);
91 } else { 95 } else {
92 if (item().type == ash::TYPE_PLATFORM_APP) 96 if (controller()->IsOpen(item().id) &&
93 AddPinMenu(); 97 !extension_misc::IsImeMenuExtensionId(
Mr4D (OOO till 08-26) 2016/11/23 23:11:51 You have effectively removed the pinning option -
msw 2016/11/24 00:00:55 Pinning was only added here for TYPE_PLATFORM_APP,
Mr4D (OOO till 08-26) 2016/11/24 02:21:33 Ok. Thanks!
94 bool show_close_button = controller()->IsOpen(item().id);
95 if (extension_misc::IsImeMenuExtensionId(
96 controller()->GetAppIDForShelfID(item().id))) { 98 controller()->GetAppIDForShelfID(item().id))) {
97 show_close_button = false; 99 AddItemWithStringId(MENU_CLOSE, IDS_LAUNCHER_CONTEXT_MENU_CLOSE);
98 } 100 }
99
100 if (show_close_button)
101 AddItemWithStringId(MENU_CLOSE, IDS_LAUNCHER_CONTEXT_MENU_CLOSE);
102 } 101 }
103 AddSeparator(ui::NORMAL_SEPARATOR); 102 AddSeparator(ui::NORMAL_SEPARATOR);
104 if (item().type == ash::TYPE_APP_SHORTCUT || 103 if (item().type == ash::TYPE_APP_SHORTCUT || item().type == ash::TYPE_APP) {
105 item().type == ash::TYPE_WINDOWED_APP ||
106 item().type == ash::TYPE_PLATFORM_APP) {
107 const extensions::MenuItem::ExtensionKey app_key( 104 const extensions::MenuItem::ExtensionKey app_key(
108 controller()->GetAppIDForShelfID(item().id)); 105 controller()->GetAppIDForShelfID(item().id));
109 if (!app_key.empty()) { 106 if (!app_key.empty()) {
110 int index = 0; 107 int index = 0;
111 extension_items_->AppendExtensionItems(app_key, base::string16(), &index, 108 extension_items_->AppendExtensionItems(app_key, base::string16(), &index,
112 false); // is_action_menu 109 false); // is_action_menu
113 AddSeparator(ui::NORMAL_SEPARATOR); 110 AddSeparator(ui::NORMAL_SEPARATOR);
114 } 111 }
115 } 112 }
116 AddShelfOptionsMenu(); 113 AddShelfOptionsMenu();
117 } 114 }
118 115
119 bool ExtensionLauncherContextMenu::IsItemForCommandIdDynamic( 116 bool ExtensionLauncherContextMenu::IsItemForCommandIdDynamic(
120 int command_id) const { 117 int command_id) const {
121 return command_id == MENU_OPEN_NEW; 118 return command_id == MENU_OPEN_NEW;
122 } 119 }
123 120
124 base::string16 ExtensionLauncherContextMenu::GetLabelForCommandId( 121 base::string16 ExtensionLauncherContextMenu::GetLabelForCommandId(
125 int command_id) const { 122 int command_id) const {
126 if (command_id == MENU_OPEN_NEW) { 123 if (command_id == MENU_OPEN_NEW) {
127 if (item().type == ash::TYPE_PLATFORM_APP) 124 if (controller()->IsPlatformApp(item().id))
128 return l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_NEW_WINDOW); 125 return l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_NEW_WINDOW);
129 switch (controller()->GetLaunchType(item().id)) { 126 switch (controller()->GetLaunchType(item().id)) {
130 case extensions::LAUNCH_TYPE_PINNED: 127 case extensions::LAUNCH_TYPE_PINNED:
131 case extensions::LAUNCH_TYPE_REGULAR: 128 case extensions::LAUNCH_TYPE_REGULAR:
132 return l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_NEW_TAB); 129 return l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_NEW_TAB);
133 case extensions::LAUNCH_TYPE_FULLSCREEN: 130 case extensions::LAUNCH_TYPE_FULLSCREEN:
134 case extensions::LAUNCH_TYPE_WINDOW: 131 case extensions::LAUNCH_TYPE_WINDOW:
135 return l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_NEW_WINDOW); 132 return l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_NEW_WINDOW);
136 default: 133 default:
137 NOTREACHED(); 134 NOTREACHED();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 case MENU_NEW_INCOGNITO_WINDOW: 215 case MENU_NEW_INCOGNITO_WINDOW:
219 chrome::NewEmptyWindow(controller()->profile()->GetOffTheRecordProfile()); 216 chrome::NewEmptyWindow(controller()->profile()->GetOffTheRecordProfile());
220 break; 217 break;
221 default: 218 default:
222 if (extension_items_) { 219 if (extension_items_) {
223 extension_items_->ExecuteCommand(command_id, nullptr, nullptr, 220 extension_items_->ExecuteCommand(command_id, nullptr, nullptr,
224 content::ContextMenuParams()); 221 content::ContextMenuParams());
225 } 222 }
226 } 223 }
227 } 224 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698