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