| 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" |
| 11 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 11 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
| 12 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" | 12 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" |
| 13 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 13 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 14 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" | 14 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" |
| 15 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 16 #include "ui/base/base_window.h" | 16 #include "ui/base/base_window.h" |
| 17 | 17 |
| 18 ArcAppWindowLauncherItemController::ArcAppWindowLauncherItemController( | 18 ArcAppWindowLauncherItemController::ArcAppWindowLauncherItemController( |
| 19 const std::string& arc_app_id, | 19 const std::string& arc_app_id) |
| 20 ChromeLauncherController* controller) | 20 : AppWindowLauncherItemController(ash::AppLaunchId(arc_app_id)) {} |
| 21 : AppWindowLauncherItemController(ash::AppLaunchId(arc_app_id), | |
| 22 controller) {} | |
| 23 | 21 |
| 24 ArcAppWindowLauncherItemController::~ArcAppWindowLauncherItemController() {} | 22 ArcAppWindowLauncherItemController::~ArcAppWindowLauncherItemController() {} |
| 25 | 23 |
| 26 void ArcAppWindowLauncherItemController::AddTaskId(int task_id) { | 24 void ArcAppWindowLauncherItemController::AddTaskId(int task_id) { |
| 27 task_ids_.insert(task_id); | 25 task_ids_.insert(task_id); |
| 28 } | 26 } |
| 29 | 27 |
| 30 void ArcAppWindowLauncherItemController::RemoveTaskId(int task_id) { | 28 void ArcAppWindowLauncherItemController::RemoveTaskId(int task_id) { |
| 31 task_ids_.erase(task_id); | 29 task_ids_.erase(task_id); |
| 32 } | 30 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 53 } | 51 } |
| 54 arc::SetTaskActive(*task_ids_.begin()); | 52 arc::SetTaskActive(*task_ids_.begin()); |
| 55 callback.Run(ash::SHELF_ACTION_NEW_WINDOW_CREATED, base::nullopt); | 53 callback.Run(ash::SHELF_ACTION_NEW_WINDOW_CREATED, base::nullopt); |
| 56 } | 54 } |
| 57 | 55 |
| 58 void ArcAppWindowLauncherItemController::ExecuteCommand(uint32_t command_id, | 56 void ArcAppWindowLauncherItemController::ExecuteCommand(uint32_t command_id, |
| 59 int32_t event_flags) { | 57 int32_t event_flags) { |
| 60 ActivateIndexedApp(command_id); | 58 ActivateIndexedApp(command_id); |
| 61 } | 59 } |
| 62 | 60 |
| 63 MenuItemList ArcAppWindowLauncherItemController::GetAppMenuItems( | 61 ash::MenuItemList ArcAppWindowLauncherItemController::GetAppMenuItems( |
| 64 int event_flags) { | 62 int event_flags) { |
| 65 MenuItemList items; | 63 ash::MenuItemList items; |
| 66 base::string16 app_title = LauncherControllerHelper::GetAppTitle( | 64 base::string16 app_title = LauncherControllerHelper::GetAppTitle( |
| 67 launcher_controller()->profile(), app_id()); | 65 ChromeLauncherController::instance()->profile(), app_id()); |
| 68 for (auto it = windows().begin(); it != windows().end(); ++it) { | 66 for (auto it = windows().begin(); it != windows().end(); ++it) { |
| 69 // TODO(khmel): resolve correct icon here. | 67 // TODO(khmel): resolve correct icon here. |
| 70 size_t i = std::distance(windows().begin(), it); | 68 size_t i = std::distance(windows().begin(), it); |
| 71 aura::Window* window = (*it)->GetNativeWindow(); | 69 aura::Window* window = (*it)->GetNativeWindow(); |
| 72 ash::mojom::MenuItemPtr item = ash::mojom::MenuItem::New(); | 70 ash::mojom::MenuItemPtr item = ash::mojom::MenuItem::New(); |
| 73 item->command_id = base::checked_cast<uint32_t>(i); | 71 item->command_id = base::checked_cast<uint32_t>(i); |
| 74 item->label = (window && !window->GetTitle().empty()) ? window->GetTitle() | 72 item->label = (window && !window->GetTitle().empty()) ? window->GetTitle() |
| 75 : app_title; | 73 : app_title; |
| 76 items.push_back(std::move(item)); | 74 items.push_back(std::move(item)); |
| 77 } | 75 } |
| 78 return items; | 76 return items; |
| 79 } | 77 } |
| OLD | NEW |