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