| 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 17 matching lines...) Expand all Loading... |
| 28 } | 28 } |
| 29 | 29 |
| 30 void ArcAppWindowLauncherItemController::RemoveTaskId(int task_id) { | 30 void ArcAppWindowLauncherItemController::RemoveTaskId(int task_id) { |
| 31 task_ids_.erase(task_id); | 31 task_ids_.erase(task_id); |
| 32 } | 32 } |
| 33 | 33 |
| 34 bool ArcAppWindowLauncherItemController::HasAnyTasks() const { | 34 bool ArcAppWindowLauncherItemController::HasAnyTasks() const { |
| 35 return !task_ids_.empty(); | 35 return !task_ids_.empty(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 ash::ShelfItemDelegate::PerformedAction | 38 ash::ShelfAction ArcAppWindowLauncherItemController::ItemSelected( |
| 39 ArcAppWindowLauncherItemController::ItemSelected(const ui::Event& event) { | 39 ui::EventType event_type, |
| 40 int event_flags, |
| 41 int64_t display_id, |
| 42 ash::ShelfLaunchSource source) { |
| 40 if (window_count()) { | 43 if (window_count()) { |
| 41 return AppWindowLauncherItemController::ItemSelected(event); | 44 return AppWindowLauncherItemController::ItemSelected( |
| 42 } else { | 45 event_type, event_flags, display_id, source); |
| 43 if (task_ids_.empty()) { | |
| 44 NOTREACHED(); | |
| 45 return kNoAction; | |
| 46 } | |
| 47 arc::SetTaskActive(*task_ids_.begin()); | |
| 48 return kNewWindowCreated; | |
| 49 } | 46 } |
| 47 |
| 48 if (task_ids_.empty()) { |
| 49 NOTREACHED(); |
| 50 return ash::kNoAction; |
| 51 } |
| 52 arc::SetTaskActive(*task_ids_.begin()); |
| 53 return ash::kNewWindowCreated; |
| 50 } | 54 } |
| 51 | 55 |
| 52 ash::ShelfAppMenuItemList ArcAppWindowLauncherItemController::GetAppMenuItems( | 56 ash::ShelfAppMenuItemList ArcAppWindowLauncherItemController::GetAppMenuItems( |
| 53 int event_flags) { | 57 int event_flags) { |
| 54 ash::ShelfAppMenuItemList items; | 58 ash::ShelfAppMenuItemList items; |
| 55 base::string16 app_title = LauncherControllerHelper::GetAppTitle( | 59 base::string16 app_title = LauncherControllerHelper::GetAppTitle( |
| 56 launcher_controller()->profile(), app_id()); | 60 launcher_controller()->profile(), app_id()); |
| 57 for (auto it = windows().begin(); it != windows().end(); ++it) { | 61 for (auto it = windows().begin(); it != windows().end(); ++it) { |
| 58 // TODO(khmel): resolve correct icon here. | 62 // TODO(khmel): resolve correct icon here. |
| 59 size_t i = std::distance(windows().begin(), it); | 63 size_t i = std::distance(windows().begin(), it); |
| 60 gfx::Image image; | 64 gfx::Image image; |
| 61 aura::Window* window = (*it)->GetNativeWindow(); | 65 aura::Window* window = (*it)->GetNativeWindow(); |
| 62 items.push_back(base::MakeUnique<ChromeLauncherAppMenuItemV2App>( | 66 items.push_back(base::MakeUnique<ChromeLauncherAppMenuItemV2App>( |
| 63 ((window && !window->GetTitle().empty()) ? window->GetTitle() | 67 ((window && !window->GetTitle().empty()) ? window->GetTitle() |
| 64 : app_title), | 68 : app_title), |
| 65 &image, app_id(), launcher_controller(), i)); | 69 &image, app_id(), launcher_controller(), i)); |
| 66 } | 70 } |
| 67 return items; | 71 return items; |
| 68 } | 72 } |
| OLD | NEW |