| 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/arc_launcher_context_menu.h" | 5 #include "chrome/browser/ui/ash/launcher/arc_launcher_context_menu.h" |
| 6 | 6 |
| 7 #include "ash/common/shelf/shelf_item_types.h" | 7 #include "ash/common/shelf/shelf_item_types.h" |
| 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 8 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" | 10 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" |
| 9 #include "chrome/grit/generated_resources.h" | 11 #include "chrome/grit/generated_resources.h" |
| 10 | 12 |
| 11 ArcLauncherContextMenu::ArcLauncherContextMenu( | 13 ArcLauncherContextMenu::ArcLauncherContextMenu( |
| 12 ChromeLauncherControllerImpl* controller, | 14 ChromeLauncherControllerImpl* controller, |
| 13 const ash::ShelfItem* item, | 15 const ash::ShelfItem* item, |
| 14 ash::WmShelf* wm_shelf) | 16 ash::WmShelf* wm_shelf) |
| 15 : LauncherContextMenu(controller, item, wm_shelf) { | 17 : LauncherContextMenu(controller, item, wm_shelf) { |
| 16 Init(); | 18 Init(); |
| 17 } | 19 } |
| 18 | 20 |
| 19 ArcLauncherContextMenu::~ArcLauncherContextMenu() {} | 21 ArcLauncherContextMenu::~ArcLauncherContextMenu() {} |
| 20 | 22 |
| 21 void ArcLauncherContextMenu::Init() { | 23 void ArcLauncherContextMenu::Init() { |
| 24 const ArcAppListPrefs* arc_list_prefs = |
| 25 ArcAppListPrefs::Get(controller()->GetProfile()); |
| 26 DCHECK(arc_list_prefs); |
| 27 |
| 28 const std::string app_id = controller()->GetAppIDForShelfID(item().id); |
| 29 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = |
| 30 arc_list_prefs->GetApp(app_id); |
| 31 if (!app_info) { |
| 32 NOTREACHED(); |
| 33 return; |
| 34 } |
| 35 |
| 22 const bool app_is_open = controller()->IsOpen(item().id); | 36 const bool app_is_open = controller()->IsOpen(item().id); |
| 23 if (!app_is_open) { | 37 if (!app_is_open) { |
| 38 DCHECK(app_info->launchable); |
| 24 AddItemWithStringId(MENU_OPEN_NEW, IDS_APP_CONTEXT_MENU_ACTIVATE_ARC); | 39 AddItemWithStringId(MENU_OPEN_NEW, IDS_APP_CONTEXT_MENU_ACTIVATE_ARC); |
| 25 AddSeparator(ui::NORMAL_SEPARATOR); | 40 AddSeparator(ui::NORMAL_SEPARATOR); |
| 26 } | 41 } |
| 27 AddPinMenu(); | 42 |
| 43 if (app_info->launchable) |
| 44 AddPinMenu(); |
| 45 |
| 28 if (app_is_open) | 46 if (app_is_open) |
| 29 AddItemWithStringId(MENU_CLOSE, IDS_LAUNCHER_CONTEXT_MENU_CLOSE); | 47 AddItemWithStringId(MENU_CLOSE, IDS_LAUNCHER_CONTEXT_MENU_CLOSE); |
| 30 AddSeparator(ui::NORMAL_SEPARATOR); | 48 AddSeparator(ui::NORMAL_SEPARATOR); |
| 31 AddShelfOptionsMenu(); | 49 AddShelfOptionsMenu(); |
| 32 } | 50 } |
| 33 | 51 |
| 34 bool ArcLauncherContextMenu::IsCommandIdEnabled(int command_id) const { | 52 bool ArcLauncherContextMenu::IsCommandIdEnabled(int command_id) const { |
| 35 if (command_id == MENU_OPEN_NEW) | 53 if (command_id == MENU_OPEN_NEW) |
| 36 return true; | 54 return true; |
| 37 return LauncherContextMenu::IsCommandIdEnabled(command_id); | 55 return LauncherContextMenu::IsCommandIdEnabled(command_id); |
| 38 } | 56 } |
| OLD | NEW |