| 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_app_window_launcher_item_controller
.h" | 5 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller
.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 10 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 } | 27 } |
| 28 | 28 |
| 29 void ArcAppWindowLauncherItemController::RemoveTaskId(int task_id) { | 29 void ArcAppWindowLauncherItemController::RemoveTaskId(int task_id) { |
| 30 task_ids_.erase(task_id); | 30 task_ids_.erase(task_id); |
| 31 } | 31 } |
| 32 | 32 |
| 33 bool ArcAppWindowLauncherItemController::HasAnyTasks() const { | 33 bool ArcAppWindowLauncherItemController::HasAnyTasks() const { |
| 34 return !task_ids_.empty(); | 34 return !task_ids_.empty(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 ash::ShelfAction ArcAppWindowLauncherItemController::ItemSelected( | 37 void ArcAppWindowLauncherItemController::ItemSelected( |
| 38 ui::EventType event_type, | 38 std::unique_ptr<ui::Event> event, |
| 39 int event_flags, | |
| 40 int64_t display_id, | 39 int64_t display_id, |
| 41 ash::ShelfLaunchSource source) { | 40 ash::ShelfLaunchSource source, |
| 41 const ItemSelectedCallback& callback) { |
| 42 if (window_count()) { | 42 if (window_count()) { |
| 43 return AppWindowLauncherItemController::ItemSelected( | 43 AppWindowLauncherItemController::ItemSelected(std::move(event), display_id, |
| 44 event_type, event_flags, display_id, source); | 44 source, callback); |
| 45 return; |
| 45 } | 46 } |
| 46 | 47 |
| 47 if (task_ids_.empty()) { | 48 if (task_ids_.empty()) { |
| 48 NOTREACHED(); | 49 NOTREACHED(); |
| 49 return ash::SHELF_ACTION_NONE; | 50 callback.Run(ash::SHELF_ACTION_NONE, base::nullopt); |
| 51 return; |
| 50 } | 52 } |
| 51 arc::SetTaskActive(*task_ids_.begin()); | 53 arc::SetTaskActive(*task_ids_.begin()); |
| 52 return ash::SHELF_ACTION_NEW_WINDOW_CREATED; | 54 callback.Run(ash::SHELF_ACTION_NEW_WINDOW_CREATED, base::nullopt); |
| 53 } | 55 } |
| 54 | 56 |
| 55 ash::ShelfAppMenuItemList ArcAppWindowLauncherItemController::GetAppMenuItems( | 57 MenuItemList ArcAppWindowLauncherItemController::GetAppMenuItems( |
| 56 int event_flags) { | 58 int event_flags) { |
| 57 ash::ShelfAppMenuItemList items; | 59 MenuItemList items; |
| 58 base::string16 app_title = LauncherControllerHelper::GetAppTitle( | 60 base::string16 app_title = LauncherControllerHelper::GetAppTitle( |
| 59 launcher_controller()->profile(), app_id()); | 61 launcher_controller()->profile(), app_id()); |
| 60 for (auto it = windows().begin(); it != windows().end(); ++it) { | 62 for (auto it = windows().begin(); it != windows().end(); ++it) { |
| 61 // TODO(khmel): resolve correct icon here. | 63 // TODO(khmel): resolve correct icon here. |
| 62 size_t i = std::distance(windows().begin(), it); | 64 size_t i = std::distance(windows().begin(), it); |
| 63 gfx::Image image; | |
| 64 aura::Window* window = (*it)->GetNativeWindow(); | 65 aura::Window* window = (*it)->GetNativeWindow(); |
| 65 items.push_back(base::MakeUnique<ash::ShelfApplicationMenuItem>( | 66 ash::mojom::MenuItemPtr item = ash::mojom::MenuItem::New(); |
| 66 base::checked_cast<uint32_t>(i), | 67 item->command_id = base::checked_cast<uint32_t>(i); |
| 67 ((window && !window->GetTitle().empty()) ? window->GetTitle() | 68 item->label = (window && !window->GetTitle().empty()) ? window->GetTitle() |
| 68 : app_title), | 69 : app_title; |
| 69 &image)); | 70 items.push_back(std::move(item)); |
| 70 } | 71 } |
| 71 return items; | 72 return items; |
| 72 } | 73 } |
| OLD | NEW |