Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Side by Side Diff: chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller.cc

Issue 2718563008: mash: Use mojo for ShelfItemDelegate and [app] MenuItem. (Closed)
Patch Set: Address comments. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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,
51 std::vector<ash::mojom::MenuItemPtr>());
52 return;
50 } 53 }
51 arc::SetTaskActive(*task_ids_.begin()); 54 arc::SetTaskActive(*task_ids_.begin());
52 return ash::SHELF_ACTION_NEW_WINDOW_CREATED; 55 callback.Run(ash::SHELF_ACTION_NEW_WINDOW_CREATED,
56 std::vector<ash::mojom::MenuItemPtr>());
53 } 57 }
54 58
55 ash::ShelfAppMenuItemList ArcAppWindowLauncherItemController::GetAppMenuItems( 59 std::vector<ash::mojom::MenuItemPtr>
56 int event_flags) { 60 ArcAppWindowLauncherItemController::GetAppMenuItems(int event_flags) {
57 ash::ShelfAppMenuItemList items; 61 std::vector<ash::mojom::MenuItemPtr> items;
58 base::string16 app_title = LauncherControllerHelper::GetAppTitle( 62 base::string16 app_title = LauncherControllerHelper::GetAppTitle(
59 launcher_controller()->profile(), app_id()); 63 launcher_controller()->profile(), app_id());
60 for (auto it = windows().begin(); it != windows().end(); ++it) { 64 for (auto it = windows().begin(); it != windows().end(); ++it) {
61 // TODO(khmel): resolve correct icon here. 65 // TODO(khmel): resolve correct icon here.
62 size_t i = std::distance(windows().begin(), it); 66 size_t i = std::distance(windows().begin(), it);
63 gfx::Image image;
64 aura::Window* window = (*it)->GetNativeWindow(); 67 aura::Window* window = (*it)->GetNativeWindow();
65 items.push_back(base::MakeUnique<ash::ShelfApplicationMenuItem>( 68 ash::mojom::MenuItemPtr item = ash::mojom::MenuItem::New();
66 base::checked_cast<uint32_t>(i), 69 item->command_id = base::checked_cast<uint32_t>(i);
67 ((window && !window->GetTitle().empty()) ? window->GetTitle() 70 item->label = (window && !window->GetTitle().empty()) ? window->GetTitle()
68 : app_title), 71 : app_title;
69 &image)); 72 items.push_back(std::move(item));
70 } 73 }
71 return items; 74 return items;
72 } 75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698