| OLD | NEW |
| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 base::Bind(MenuItemHasLauncherContext))); | 46 base::Bind(MenuItemHasLauncherContext))); |
| 47 if (item().type == ash::TYPE_APP_SHORTCUT || item().type == ash::TYPE_APP) { | 47 if (item().type == ash::TYPE_APP_SHORTCUT || item().type == ash::TYPE_APP) { |
| 48 // V1 apps can be started from the menu - but V2 apps should not. | 48 // V1 apps can be started from the menu - but V2 apps should not. |
| 49 if (!controller()->IsPlatformApp(item().id)) { | 49 if (!controller()->IsPlatformApp(item().id)) { |
| 50 AddItem(MENU_OPEN_NEW, base::string16()); | 50 AddItem(MENU_OPEN_NEW, base::string16()); |
| 51 AddSeparator(ui::NORMAL_SEPARATOR); | 51 AddSeparator(ui::NORMAL_SEPARATOR); |
| 52 } | 52 } |
| 53 | 53 |
| 54 AddPinMenu(); | 54 AddPinMenu(); |
| 55 | 55 |
| 56 if (controller()->IsOpen(item().id) && | 56 if (controller()->IsOpen(item().id)) |
| 57 !extension_misc::IsImeMenuExtensionId( | |
| 58 controller()->GetAppIDForShelfID(item().id))) { | |
| 59 AddItemWithStringId(MENU_CLOSE, IDS_LAUNCHER_CONTEXT_MENU_CLOSE); | 57 AddItemWithStringId(MENU_CLOSE, IDS_LAUNCHER_CONTEXT_MENU_CLOSE); |
| 60 } | |
| 61 | 58 |
| 62 if (!controller()->IsPlatformApp(item().id) && | 59 if (!controller()->IsPlatformApp(item().id) && |
| 63 item().type == ash::TYPE_APP_SHORTCUT) { | 60 item().type == ash::TYPE_APP_SHORTCUT) { |
| 64 AddSeparator(ui::NORMAL_SEPARATOR); | 61 AddSeparator(ui::NORMAL_SEPARATOR); |
| 65 if (extensions::util::IsNewBookmarkAppsEnabled()) { | 62 if (extensions::util::IsNewBookmarkAppsEnabled()) { |
| 66 // With bookmark apps enabled, hosted apps launch in a window by | 63 // With bookmark apps enabled, hosted apps launch in a window by |
| 67 // 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 |
| 68 // option to launch the hosted app as a tab. | 65 // option to launch the hosted app as a tab. |
| 69 AddCheckItemWithStringId(LAUNCH_TYPE_WINDOW, | 66 AddCheckItemWithStringId(LAUNCH_TYPE_WINDOW, |
| 70 IDS_APP_CONTEXT_MENU_OPEN_WINDOW); | 67 IDS_APP_CONTEXT_MENU_OPEN_WINDOW); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 88 IDS_APP_LIST_NEW_INCOGNITO_WINDOW); | 85 IDS_APP_LIST_NEW_INCOGNITO_WINDOW); |
| 89 } | 86 } |
| 90 if (!BrowserShortcutLauncherItemController( | 87 if (!BrowserShortcutLauncherItemController( |
| 91 controller(), ash::WmShell::Get()->shelf_model()) | 88 controller(), ash::WmShell::Get()->shelf_model()) |
| 92 .IsListOfActiveBrowserEmpty()) { | 89 .IsListOfActiveBrowserEmpty()) { |
| 93 AddItem(MENU_CLOSE, | 90 AddItem(MENU_CLOSE, |
| 94 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_CLOSE)); | 91 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_CLOSE)); |
| 95 } | 92 } |
| 96 } else if (item().type == ash::TYPE_DIALOG) { | 93 } else if (item().type == ash::TYPE_DIALOG) { |
| 97 AddItemWithStringId(MENU_CLOSE, IDS_LAUNCHER_CONTEXT_MENU_CLOSE); | 94 AddItemWithStringId(MENU_CLOSE, IDS_LAUNCHER_CONTEXT_MENU_CLOSE); |
| 98 } else { | 95 } else if (controller()->IsOpen(item().id)) { |
| 99 if (controller()->IsOpen(item().id) && | 96 AddItemWithStringId(MENU_CLOSE, IDS_LAUNCHER_CONTEXT_MENU_CLOSE); |
| 100 !extension_misc::IsImeMenuExtensionId( | |
| 101 controller()->GetAppIDForShelfID(item().id))) { | |
| 102 AddItemWithStringId(MENU_CLOSE, IDS_LAUNCHER_CONTEXT_MENU_CLOSE); | |
| 103 } | |
| 104 } | 97 } |
| 105 AddSeparator(ui::NORMAL_SEPARATOR); | 98 AddSeparator(ui::NORMAL_SEPARATOR); |
| 106 if (item().type == ash::TYPE_APP_SHORTCUT || item().type == ash::TYPE_APP) { | 99 if (item().type == ash::TYPE_APP_SHORTCUT || item().type == ash::TYPE_APP) { |
| 107 const extensions::MenuItem::ExtensionKey app_key( | 100 const extensions::MenuItem::ExtensionKey app_key( |
| 108 controller()->GetAppIDForShelfID(item().id)); | 101 controller()->GetAppIDForShelfID(item().id)); |
| 109 if (!app_key.empty()) { | 102 if (!app_key.empty()) { |
| 110 int index = 0; | 103 int index = 0; |
| 111 extension_items_->AppendExtensionItems(app_key, base::string16(), &index, | 104 extension_items_->AppendExtensionItems(app_key, base::string16(), &index, |
| 112 false); // is_action_menu | 105 false); // is_action_menu |
| 113 AddSeparator(ui::NORMAL_SEPARATOR); | 106 AddSeparator(ui::NORMAL_SEPARATOR); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 if (!extension) | 221 if (!extension) |
| 229 return extensions::LAUNCH_TYPE_DEFAULT; | 222 return extensions::LAUNCH_TYPE_DEFAULT; |
| 230 | 223 |
| 231 return extensions::GetLaunchType( | 224 return extensions::GetLaunchType( |
| 232 extensions::ExtensionPrefs::Get(controller()->profile()), extension); | 225 extensions::ExtensionPrefs::Get(controller()->profile()), extension); |
| 233 } | 226 } |
| 234 | 227 |
| 235 void ExtensionLauncherContextMenu::SetLaunchType(extensions::LaunchType type) { | 228 void ExtensionLauncherContextMenu::SetLaunchType(extensions::LaunchType type) { |
| 236 extensions::SetLaunchType(controller()->profile(), item().app_id, type); | 229 extensions::SetLaunchType(controller()->profile(), item().app_id, type); |
| 237 } | 230 } |
| OLD | NEW |