Index: chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc |
diff --git a/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc b/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc |
index ef9ff8e8bc59b2b8dc5b701eefafe8aaa6ca0af9..85997a3ef0b507d42f0f376fbf60d9b4f34f2da7 100644 |
--- a/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc |
+++ b/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc |
@@ -6,7 +6,6 @@ |
#include <stddef.h> |
-#include "ash/public/cpp/shelf_application_menu_item.h" |
#include "ash/wm/window_util.h" |
#include "base/memory/ptr_util.h" |
#include "chrome/browser/chromeos/arc/arc_support_host.h" |
@@ -93,51 +92,59 @@ AppShortcutLauncherItemController::AppShortcutLauncherItemController( |
AppShortcutLauncherItemController::~AppShortcutLauncherItemController() {} |
-ash::ShelfAction AppShortcutLauncherItemController::ItemSelected( |
- ui::EventType event_type, |
- int event_flags, |
+void AppShortcutLauncherItemController::ItemSelected( |
+ std::unique_ptr<ui::Event> event, |
int64_t display_id, |
- ash::ShelfLaunchSource source) { |
+ ash::ShelfLaunchSource source, |
+ const ItemSelectedCallback& callback) { |
// In case of a keyboard event, we were called by a hotkey. In that case we |
// activate the next item in line if an item of our list is already active. |
- if (event_type == ui::ET_KEY_RELEASED && AdvanceToNextApp()) |
- return ash::SHELF_ACTION_WINDOW_ACTIVATED; |
+ if (event && event->type() == ui::ET_KEY_RELEASED && AdvanceToNextApp()) { |
+ callback.Run(ash::SHELF_ACTION_WINDOW_ACTIVATED, MenuItemList()); |
+ return; |
+ } |
content::WebContents* content = GetLRUApplication(); |
+ MenuItemList items = GetAppMenuItems(event ? event->flags() : ui::EF_NONE); |
James Cook
2017/03/09 01:09:47
optional: maybe just do this in the two cases belo
msw
2017/03/10 06:17:57
Done.
|
if (!content) { |
// Ideally we come here only once. After that ShellLauncherItemController |
// will take over when the shell window gets opened. However there are apps |
// which take a lot of time for pre-processing (like the files app) before |
// they open a window. Since there is currently no other way to detect if an |
// app was started we suppress any further clicks within a special time out. |
- if (IsV2App() && !AllowNextLaunchAttempt()) |
- return ash::SHELF_ACTION_NONE; |
+ if (IsV2App() && !AllowNextLaunchAttempt()) { |
+ callback.Run(ash::SHELF_ACTION_NONE, std::move(items)); |
+ return; |
+ } |
// Launching some items replaces this item controller instance, which |
// destroys the app and launch id strings; making copies avoid crashes. |
launcher_controller()->LaunchApp(ash::AppLauncherId(app_id(), launch_id()), |
source, ui::EF_NONE); |
- return ash::SHELF_ACTION_NEW_WINDOW_CREATED; |
+ callback.Run(ash::SHELF_ACTION_NEW_WINDOW_CREATED, MenuItemList()); |
+ return; |
} |
- return ActivateContent(content); |
+ |
+ callback.Run(ActivateContent(content), std::move(items)); |
James Cook
2017/03/09 01:09:47
optional nit: maybe put the result of ActivateCont
msw
2017/03/10 06:17:57
Done.
|
} |
-ash::ShelfAppMenuItemList AppShortcutLauncherItemController::GetAppMenuItems( |
- int event_flags) { |
- ash::ShelfAppMenuItemList items; |
+ash::ShelfItemDelegate::MenuItemList |
+AppShortcutLauncherItemController::GetAppMenuItems(int event_flags) { |
+ MenuItemList items; |
app_menu_items_ = GetRunningApplications(); |
for (size_t i = 0; i < app_menu_items_.size(); i++) { |
- content::WebContents* web_contents = app_menu_items_[i]; |
- gfx::Image icon = launcher_controller()->GetAppListIcon(web_contents); |
- base::string16 title = launcher_controller()->GetAppListTitle(web_contents); |
- items.push_back(base::MakeUnique<ash::ShelfApplicationMenuItem>( |
- base::checked_cast<uint32_t>(i), title, &icon)); |
+ content::WebContents* tab = app_menu_items_[i]; |
+ ash::mojom::MenuItemPtr item(ash::mojom::MenuItem::New()); |
+ item->command_id = base::checked_cast<uint32_t>(i); |
+ item->label = launcher_controller()->GetAppListTitle(tab); |
+ item->image = *launcher_controller()->GetAppListIcon(tab).ToSkBitmap(); |
+ items.push_back(std::move(item)); |
} |
return items; |
} |
void AppShortcutLauncherItemController::ExecuteCommand(uint32_t command_id, |
- int event_flags) { |
+ int32_t event_flags) { |
if (static_cast<size_t>(command_id) >= app_menu_items_.size()) { |
app_menu_items_.clear(); |
return; |