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/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 9 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 10 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
10 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" | 11 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" |
11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_v2app.h" | 12 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_v2app.h" |
12 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 13 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
13 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" | 14 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" |
14 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
15 #include "ui/base/base_window.h" | 16 #include "ui/base/base_window.h" |
16 | 17 |
17 ArcAppWindowLauncherItemController::ArcAppWindowLauncherItemController( | 18 ArcAppWindowLauncherItemController::ArcAppWindowLauncherItemController( |
18 const std::string& arc_app_id, | 19 const std::string& arc_app_id, |
19 ChromeLauncherController* controller) | 20 ChromeLauncherController* controller) |
20 : AppWindowLauncherItemController(TYPE_APP, | 21 : AppWindowLauncherItemController(TYPE_APP, |
21 arc_app_id, | 22 arc_app_id, |
22 arc_app_id, | 23 arc_app_id, |
23 controller) {} | 24 controller) {} |
24 | 25 |
25 ArcAppWindowLauncherItemController::~ArcAppWindowLauncherItemController() {} | 26 ArcAppWindowLauncherItemController::~ArcAppWindowLauncherItemController() {} |
26 | 27 |
| 28 void ArcAppWindowLauncherItemController::AddTaskId(int task_id) { |
| 29 task_ids_.insert(task_id); |
| 30 } |
| 31 |
| 32 void ArcAppWindowLauncherItemController::RemoveTaskId(int task_id) { |
| 33 task_ids_.erase(task_id); |
| 34 } |
| 35 |
| 36 ash::ShelfItemDelegate::PerformedAction |
| 37 ArcAppWindowLauncherItemController::ItemSelected(const ui::Event& event) { |
| 38 if (window_count()) { |
| 39 return AppWindowLauncherItemController::ItemSelected(event); |
| 40 } else { |
| 41 if (task_ids_.empty()) { |
| 42 NOTREACHED(); |
| 43 return kNoAction; |
| 44 } |
| 45 arc::SetTaskActive(*task_ids_.begin()); |
| 46 return kNewWindowCreated; |
| 47 } |
| 48 } |
| 49 |
27 base::string16 ArcAppWindowLauncherItemController::GetTitle() { | 50 base::string16 ArcAppWindowLauncherItemController::GetTitle() { |
28 ArcAppListPrefs* arc_prefs = | 51 ArcAppListPrefs* arc_prefs = |
29 ArcAppListPrefs::Get(launcher_controller()->GetProfile()); | 52 ArcAppListPrefs::Get(launcher_controller()->GetProfile()); |
30 DCHECK(arc_prefs); | 53 DCHECK(arc_prefs); |
31 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = arc_prefs->GetApp( | 54 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = arc_prefs->GetApp( |
32 ArcAppWindowLauncherController::GetArcAppIdFromShelfAppId(app_id())); | 55 ArcAppWindowLauncherController::GetArcAppIdFromShelfAppId(app_id())); |
33 if (!app_info) { | 56 if (!app_info) { |
34 NOTREACHED(); | 57 NOTREACHED(); |
35 return base::string16(); | 58 return base::string16(); |
36 } | 59 } |
(...skipping 15 matching lines...) Expand all Loading... |
52 size_t i = std::distance(windows().begin(), it); | 75 size_t i = std::distance(windows().begin(), it); |
53 gfx::Image image; | 76 gfx::Image image; |
54 aura::Window* window = (*it)->GetNativeWindow(); | 77 aura::Window* window = (*it)->GetNativeWindow(); |
55 items.push_back(new ChromeLauncherAppMenuItemV2App( | 78 items.push_back(new ChromeLauncherAppMenuItemV2App( |
56 ((window && !window->title().empty()) ? window->title() : GetTitle()), | 79 ((window && !window->title().empty()) ? window->title() : GetTitle()), |
57 &image, app_id(), launcher_controller(), i, | 80 &image, app_id(), launcher_controller(), i, |
58 i == 0 /* has_leading_separator */)); | 81 i == 0 /* has_leading_separator */)); |
59 } | 82 } |
60 return items; | 83 return items; |
61 } | 84 } |
OLD | NEW |