Chromium Code Reviews| 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)) { |
|
sky
2016/12/12 16:06:55
remove {}
Azure Wei
2016/12/13 11:20:47
Done.
| |
| 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 } | 58 } |
| 61 | 59 |
| 62 if (!controller()->IsPlatformApp(item().id) && | 60 if (!controller()->IsPlatformApp(item().id) && |
| 63 item().type == ash::TYPE_APP_SHORTCUT) { | 61 item().type == ash::TYPE_APP_SHORTCUT) { |
| 64 AddSeparator(ui::NORMAL_SEPARATOR); | 62 AddSeparator(ui::NORMAL_SEPARATOR); |
| 65 if (extensions::util::IsNewBookmarkAppsEnabled()) { | 63 if (extensions::util::IsNewBookmarkAppsEnabled()) { |
| 66 // With bookmark apps enabled, hosted apps launch in a window by | 64 // With bookmark apps enabled, hosted apps launch in a window by |
| 67 // default. This menu item is re-interpreted as a single, toggle-able | 65 // default. This menu item is re-interpreted as a single, toggle-able |
| 68 // option to launch the hosted app as a tab. | 66 // option to launch the hosted app as a tab. |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 89 } | 87 } |
| 90 if (!BrowserShortcutLauncherItemController( | 88 if (!BrowserShortcutLauncherItemController( |
| 91 controller(), ash::WmShell::Get()->shelf_model()) | 89 controller(), ash::WmShell::Get()->shelf_model()) |
| 92 .IsListOfActiveBrowserEmpty()) { | 90 .IsListOfActiveBrowserEmpty()) { |
| 93 AddItem(MENU_CLOSE, | 91 AddItem(MENU_CLOSE, |
| 94 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_CLOSE)); | 92 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_CLOSE)); |
| 95 } | 93 } |
| 96 } else if (item().type == ash::TYPE_DIALOG) { | 94 } else if (item().type == ash::TYPE_DIALOG) { |
| 97 AddItemWithStringId(MENU_CLOSE, IDS_LAUNCHER_CONTEXT_MENU_CLOSE); | 95 AddItemWithStringId(MENU_CLOSE, IDS_LAUNCHER_CONTEXT_MENU_CLOSE); |
| 98 } else { | 96 } else { |
| 99 if (controller()->IsOpen(item().id) && | 97 if (controller()->IsOpen(item().id)) { |
|
sky
2016/12/12 16:06:55
remove {}
Azure Wei
2016/12/13 11:20:47
Done.
| |
| 100 !extension_misc::IsImeMenuExtensionId( | |
| 101 controller()->GetAppIDForShelfID(item().id))) { | |
| 102 AddItemWithStringId(MENU_CLOSE, IDS_LAUNCHER_CONTEXT_MENU_CLOSE); | 98 AddItemWithStringId(MENU_CLOSE, IDS_LAUNCHER_CONTEXT_MENU_CLOSE); |
| 103 } | 99 } |
| 104 } | 100 } |
| 105 AddSeparator(ui::NORMAL_SEPARATOR); | 101 AddSeparator(ui::NORMAL_SEPARATOR); |
| 106 if (item().type == ash::TYPE_APP_SHORTCUT || item().type == ash::TYPE_APP) { | 102 if (item().type == ash::TYPE_APP_SHORTCUT || item().type == ash::TYPE_APP) { |
| 107 const extensions::MenuItem::ExtensionKey app_key( | 103 const extensions::MenuItem::ExtensionKey app_key( |
| 108 controller()->GetAppIDForShelfID(item().id)); | 104 controller()->GetAppIDForShelfID(item().id)); |
| 109 if (!app_key.empty()) { | 105 if (!app_key.empty()) { |
| 110 int index = 0; | 106 int index = 0; |
| 111 extension_items_->AppendExtensionItems(app_key, base::string16(), &index, | 107 extension_items_->AppendExtensionItems(app_key, base::string16(), &index, |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 if (!extension) | 224 if (!extension) |
| 229 return extensions::LAUNCH_TYPE_DEFAULT; | 225 return extensions::LAUNCH_TYPE_DEFAULT; |
| 230 | 226 |
| 231 return extensions::GetLaunchType( | 227 return extensions::GetLaunchType( |
| 232 extensions::ExtensionPrefs::Get(controller()->profile()), extension); | 228 extensions::ExtensionPrefs::Get(controller()->profile()), extension); |
| 233 } | 229 } |
| 234 | 230 |
| 235 void ExtensionLauncherContextMenu::SetLaunchType(extensions::LaunchType type) { | 231 void ExtensionLauncherContextMenu::SetLaunchType(extensions::LaunchType type) { |
| 236 extensions::SetLaunchType(controller()->profile(), item().app_id, type); | 232 extensions::SetLaunchType(controller()->profile(), item().app_id, type); |
| 237 } | 233 } |
| OLD | NEW |