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 <utility> |
| 8 |
7 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
8 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 12 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
11 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 13 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
12 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" | 14 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" |
13 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 15 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
14 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" | 16 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" |
15 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
16 #include "ui/base/base_window.h" | 18 #include "ui/base/base_window.h" |
(...skipping 13 matching lines...) Expand all Loading... |
30 } | 32 } |
31 | 33 |
32 bool ArcAppWindowLauncherItemController::HasAnyTasks() const { | 34 bool ArcAppWindowLauncherItemController::HasAnyTasks() const { |
33 return !task_ids_.empty(); | 35 return !task_ids_.empty(); |
34 } | 36 } |
35 | 37 |
36 void ArcAppWindowLauncherItemController::ItemSelected( | 38 void ArcAppWindowLauncherItemController::ItemSelected( |
37 std::unique_ptr<ui::Event> event, | 39 std::unique_ptr<ui::Event> event, |
38 int64_t display_id, | 40 int64_t display_id, |
39 ash::ShelfLaunchSource source, | 41 ash::ShelfLaunchSource source, |
40 const ItemSelectedCallback& callback) { | 42 ItemSelectedCallback callback) { |
41 if (window_count()) { | 43 if (window_count()) { |
42 AppWindowLauncherItemController::ItemSelected(std::move(event), display_id, | 44 AppWindowLauncherItemController::ItemSelected(std::move(event), display_id, |
43 source, callback); | 45 source, std::move(callback)); |
44 return; | 46 return; |
45 } | 47 } |
46 | 48 |
47 if (task_ids_.empty()) { | 49 if (task_ids_.empty()) { |
48 NOTREACHED(); | 50 NOTREACHED(); |
49 callback.Run(ash::SHELF_ACTION_NONE, base::nullopt); | 51 std::move(callback).Run(ash::SHELF_ACTION_NONE, base::nullopt); |
50 return; | 52 return; |
51 } | 53 } |
52 arc::SetTaskActive(*task_ids_.begin()); | 54 arc::SetTaskActive(*task_ids_.begin()); |
53 callback.Run(ash::SHELF_ACTION_NEW_WINDOW_CREATED, base::nullopt); | 55 std::move(callback).Run(ash::SHELF_ACTION_NEW_WINDOW_CREATED, base::nullopt); |
54 } | 56 } |
55 | 57 |
56 void ArcAppWindowLauncherItemController::ExecuteCommand(uint32_t command_id, | 58 void ArcAppWindowLauncherItemController::ExecuteCommand(uint32_t command_id, |
57 int32_t event_flags) { | 59 int32_t event_flags) { |
58 ActivateIndexedApp(command_id); | 60 ActivateIndexedApp(command_id); |
59 } | 61 } |
60 | 62 |
61 ash::MenuItemList ArcAppWindowLauncherItemController::GetAppMenuItems( | 63 ash::MenuItemList ArcAppWindowLauncherItemController::GetAppMenuItems( |
62 int event_flags) { | 64 int event_flags) { |
63 ash::MenuItemList items; | 65 ash::MenuItemList items; |
64 base::string16 app_title = LauncherControllerHelper::GetAppTitle( | 66 base::string16 app_title = LauncherControllerHelper::GetAppTitle( |
65 ChromeLauncherController::instance()->profile(), app_id()); | 67 ChromeLauncherController::instance()->profile(), app_id()); |
66 for (auto it = windows().begin(); it != windows().end(); ++it) { | 68 for (auto it = windows().begin(); it != windows().end(); ++it) { |
67 // TODO(khmel): resolve correct icon here. | 69 // TODO(khmel): resolve correct icon here. |
68 size_t i = std::distance(windows().begin(), it); | 70 size_t i = std::distance(windows().begin(), it); |
69 aura::Window* window = (*it)->GetNativeWindow(); | 71 aura::Window* window = (*it)->GetNativeWindow(); |
70 ash::mojom::MenuItemPtr item = ash::mojom::MenuItem::New(); | 72 ash::mojom::MenuItemPtr item = ash::mojom::MenuItem::New(); |
71 item->command_id = base::checked_cast<uint32_t>(i); | 73 item->command_id = base::checked_cast<uint32_t>(i); |
72 item->label = (window && !window->GetTitle().empty()) ? window->GetTitle() | 74 item->label = (window && !window->GetTitle().empty()) ? window->GetTitle() |
73 : app_title; | 75 : app_title; |
74 items.push_back(std::move(item)); | 76 items.push_back(std::move(item)); |
75 } | 77 } |
76 return items; | 78 return items; |
77 } | 79 } |
OLD | NEW |