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/shelf/shelf.h" | 7 #include "ash/shelf/shelf.h" |
| 8 #include "ash/shelf/shelf_item_delegate.h" | 8 #include "ash/shelf/shelf_item_delegate.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" |
| 11 #include "chrome/browser/extensions/extension_util.h" | 11 #include "chrome/browser/extensions/extension_util.h" |
| 12 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 12 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll er.h" | 14 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll er.h" |
| 15 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 15 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 16 #include "chrome/common/extensions/extension_constants.h" | 16 #include "chrome/common/extensions/extension_constants.h" |
| 17 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
| 18 #include "content/public/common/context_menu_params.h" | 18 #include "content/public/common/context_menu_params.h" |
| 19 #include "grit/ash_strings.h" | 19 #include "grit/ash_strings.h" |
| 20 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
| 21 | 21 |
| 22 namespace ash { | |
| 23 class ShelfModel; | |
| 24 } | |
| 25 | |
| 22 namespace { | 26 namespace { |
| 23 | 27 |
| 24 bool MenuItemHasLauncherContext(const extensions::MenuItem* item) { | 28 bool MenuItemHasLauncherContext(const extensions::MenuItem* item) { |
| 25 return item->contexts().Contains(extensions::MenuItem::LAUNCHER); | 29 return item->contexts().Contains(extensions::MenuItem::LAUNCHER); |
| 26 } | 30 } |
| 27 | 31 |
| 28 } // namespace | 32 } // namespace |
| 29 | 33 |
| 30 ExtensionLauncherContextMenu::ExtensionLauncherContextMenu( | 34 ExtensionLauncherContextMenu::ExtensionLauncherContextMenu( |
| 31 ChromeLauncherController* controller, | 35 ChromeLauncherController* controller, |
| 32 const ash::ShelfItem* item, | 36 const ash::ShelfItem* item, |
| 33 ash::Shelf* shelf) | 37 ash::Shelf* shelf) |
| 34 : LauncherContextMenu(controller, item, shelf) { | 38 : LauncherContextMenu(controller, item, shelf), |
| 39 shelf_model_(shelf->shelf_model()) { | |
| 35 Init(); | 40 Init(); |
| 36 } | 41 } |
| 37 | 42 |
| 38 ExtensionLauncherContextMenu::~ExtensionLauncherContextMenu() {} | 43 ExtensionLauncherContextMenu::~ExtensionLauncherContextMenu() {} |
| 39 | 44 |
| 40 void ExtensionLauncherContextMenu::Init() { | 45 void ExtensionLauncherContextMenu::Init() { |
| 41 extension_items_.reset(new extensions::ContextMenuMatcher( | 46 extension_items_.reset(new extensions::ContextMenuMatcher( |
| 42 controller()->profile(), this, this, | 47 controller()->profile(), this, this, |
| 43 base::Bind(MenuItemHasLauncherContext))); | 48 base::Bind(MenuItemHasLauncherContext))); |
| 44 if (item().type == ash::TYPE_APP_SHORTCUT || | 49 if (item().type == ash::TYPE_APP_SHORTCUT || |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 73 AddCheckItemWithStringId(LAUNCH_TYPE_FULLSCREEN, | 78 AddCheckItemWithStringId(LAUNCH_TYPE_FULLSCREEN, |
| 74 IDS_APP_CONTEXT_MENU_OPEN_MAXIMIZED); | 79 IDS_APP_CONTEXT_MENU_OPEN_MAXIMIZED); |
| 75 } | 80 } |
| 76 } | 81 } |
| 77 } else if (item().type == ash::TYPE_BROWSER_SHORTCUT) { | 82 } else if (item().type == ash::TYPE_BROWSER_SHORTCUT) { |
| 78 AddItemWithStringId(MENU_NEW_WINDOW, IDS_APP_LIST_NEW_WINDOW); | 83 AddItemWithStringId(MENU_NEW_WINDOW, IDS_APP_LIST_NEW_WINDOW); |
| 79 if (!controller()->IsLoggedInAsGuest()) { | 84 if (!controller()->IsLoggedInAsGuest()) { |
| 80 AddItemWithStringId(MENU_NEW_INCOGNITO_WINDOW, | 85 AddItemWithStringId(MENU_NEW_INCOGNITO_WINDOW, |
| 81 IDS_APP_LIST_NEW_INCOGNITO_WINDOW); | 86 IDS_APP_LIST_NEW_INCOGNITO_WINDOW); |
| 82 } | 87 } |
| 83 if (!BrowserShortcutLauncherItemController(controller()) | 88 if (!BrowserShortcutLauncherItemController(controller(), shelf_model_) |
|
msw
2016/06/03 20:54:11
aside: yuck!
| |
| 84 .IsListOfActiveBrowserEmpty()) { | 89 .IsListOfActiveBrowserEmpty()) { |
| 85 AddItem(MENU_CLOSE, | 90 AddItem(MENU_CLOSE, |
| 86 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_CLOSE)); | 91 l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_CLOSE)); |
| 87 } | 92 } |
| 88 } else if (item().type == ash::TYPE_DIALOG) { | 93 } else if (item().type == ash::TYPE_DIALOG) { |
| 89 AddItemWithStringId(MENU_CLOSE, IDS_LAUNCHER_CONTEXT_MENU_CLOSE); | 94 AddItemWithStringId(MENU_CLOSE, IDS_LAUNCHER_CONTEXT_MENU_CLOSE); |
| 90 } else { | 95 } else { |
| 91 if (item().type == ash::TYPE_PLATFORM_APP) | 96 if (item().type == ash::TYPE_PLATFORM_APP) |
| 92 AddPinMenu(); | 97 AddPinMenu(); |
| 93 bool show_close_button = controller()->IsOpen(item().id); | 98 bool show_close_button = controller()->IsOpen(item().id); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 case MENU_NEW_INCOGNITO_WINDOW: | 222 case MENU_NEW_INCOGNITO_WINDOW: |
| 218 controller()->CreateNewIncognitoWindow(); | 223 controller()->CreateNewIncognitoWindow(); |
| 219 break; | 224 break; |
| 220 default: | 225 default: |
| 221 if (extension_items_) { | 226 if (extension_items_) { |
| 222 extension_items_->ExecuteCommand(command_id, nullptr, nullptr, | 227 extension_items_->ExecuteCommand(command_id, nullptr, nullptr, |
| 223 content::ContextMenuParams()); | 228 content::ContextMenuParams()); |
| 224 } | 229 } |
| 225 } | 230 } |
| 226 } | 231 } |
| OLD | NEW |