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_app_menu_item_v2app.h" | 13 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_v2app.h" |
14 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 14 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
15 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" | 15 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" |
| 16 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" |
16 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
17 #include "ui/base/base_window.h" | 18 #include "ui/base/base_window.h" |
18 | 19 |
19 ArcAppWindowLauncherItemController::ArcAppWindowLauncherItemController( | 20 ArcAppWindowLauncherItemController::ArcAppWindowLauncherItemController( |
20 const std::string& arc_app_id, | 21 const std::string& arc_app_id, |
21 ChromeLauncherController* controller) | 22 ChromeLauncherController* controller) |
22 : AppWindowLauncherItemController(arc_app_id, "", controller) {} | 23 : AppWindowLauncherItemController(arc_app_id, "", controller) {} |
23 | 24 |
24 ArcAppWindowLauncherItemController::~ArcAppWindowLauncherItemController() {} | 25 ArcAppWindowLauncherItemController::~ArcAppWindowLauncherItemController() {} |
25 | 26 |
(...skipping 16 matching lines...) Expand all Loading... |
42 } else { | 43 } else { |
43 if (task_ids_.empty()) { | 44 if (task_ids_.empty()) { |
44 NOTREACHED(); | 45 NOTREACHED(); |
45 return kNoAction; | 46 return kNoAction; |
46 } | 47 } |
47 arc::SetTaskActive(*task_ids_.begin()); | 48 arc::SetTaskActive(*task_ids_.begin()); |
48 return kNewWindowCreated; | 49 return kNewWindowCreated; |
49 } | 50 } |
50 } | 51 } |
51 | 52 |
52 base::string16 ArcAppWindowLauncherItemController::GetTitle() { | |
53 ArcAppListPrefs* arc_prefs = | |
54 ArcAppListPrefs::Get(launcher_controller()->profile()); | |
55 DCHECK(arc_prefs); | |
56 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = arc_prefs->GetApp( | |
57 ArcAppWindowLauncherController::GetArcAppIdFromShelfAppId(app_id())); | |
58 if (!app_info) { | |
59 NOTREACHED(); | |
60 return base::string16(); | |
61 } | |
62 | |
63 return base::UTF8ToUTF16(app_info->name); | |
64 } | |
65 | |
66 ash::ShelfMenuModel* ArcAppWindowLauncherItemController::CreateApplicationMenu( | 53 ash::ShelfMenuModel* ArcAppWindowLauncherItemController::CreateApplicationMenu( |
67 int event_flags) { | 54 int event_flags) { |
68 return new LauncherApplicationMenuItemModel(GetApplicationList(event_flags)); | 55 return new LauncherApplicationMenuItemModel(GetApplicationList(event_flags)); |
69 } | 56 } |
70 | 57 |
71 ChromeLauncherAppMenuItems | 58 ChromeLauncherAppMenuItems |
72 ArcAppWindowLauncherItemController::GetApplicationList(int event_flags) { | 59 ArcAppWindowLauncherItemController::GetApplicationList(int event_flags) { |
73 ChromeLauncherAppMenuItems items = | 60 ChromeLauncherAppMenuItems items = |
74 AppWindowLauncherItemController::GetApplicationList(event_flags); | 61 AppWindowLauncherItemController::GetApplicationList(event_flags); |
| 62 base::string16 app_title = LauncherControllerHelper::GetAppTitle( |
| 63 launcher_controller()->profile(), app_id()); |
75 for (auto it = windows().begin(); it != windows().end(); ++it) { | 64 for (auto it = windows().begin(); it != windows().end(); ++it) { |
76 // TODO(khmel): resolve correct icon here. | 65 // TODO(khmel): resolve correct icon here. |
77 size_t i = std::distance(windows().begin(), it); | 66 size_t i = std::distance(windows().begin(), it); |
78 gfx::Image image; | 67 gfx::Image image; |
79 aura::Window* window = (*it)->GetNativeWindow(); | 68 aura::Window* window = (*it)->GetNativeWindow(); |
80 items.push_back(base::MakeUnique<ChromeLauncherAppMenuItemV2App>( | 69 items.push_back(base::MakeUnique<ChromeLauncherAppMenuItemV2App>( |
81 ((window && !window->GetTitle().empty()) ? window->GetTitle() | 70 ((window && !window->GetTitle().empty()) ? window->GetTitle() |
82 : GetTitle()), | 71 : app_title), |
83 &image, app_id(), launcher_controller(), i, | 72 &image, app_id(), launcher_controller(), i, |
84 i == 0 /* has_leading_separator */)); | 73 i == 0 /* has_leading_separator */)); |
85 } | 74 } |
86 return items; | 75 return items; |
87 } | 76 } |
OLD | NEW |