OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/launcher_controller_helper.h" | 5 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/chromeos/arc/arc_support_host.h" | 11 #include "chrome/browser/chromeos/arc/arc_support_host.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/extensions/extension_util.h" | 13 #include "chrome/browser/extensions/extension_util.h" |
14 #include "chrome/browser/extensions/launch_util.h" | 14 #include "chrome/browser/extensions/launch_util.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
17 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 17 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
18 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 18 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
| 19 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" |
19 #include "chrome/browser/ui/browser_finder.h" | 20 #include "chrome/browser/ui/browser_finder.h" |
20 #include "chrome/browser/ui/extensions/app_launch_params.h" | 21 #include "chrome/browser/ui/extensions/app_launch_params.h" |
21 #include "chrome/browser/ui/extensions/application_launch.h" | 22 #include "chrome/browser/ui/extensions/application_launch.h" |
22 #include "chrome/browser/ui/extensions/extension_enable_flow.h" | 23 #include "chrome/browser/ui/extensions/extension_enable_flow.h" |
23 #include "chrome/browser/web_applications/web_app.h" | 24 #include "chrome/browser/web_applications/web_app.h" |
24 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 25 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
25 #include "content/public/browser/navigation_entry.h" | 26 #include "content/public/browser/navigation_entry.h" |
26 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
27 #include "extensions/browser/extension_registry.h" | 28 #include "extensions/browser/extension_registry.h" |
28 #include "extensions/browser/extension_system.h" | 29 #include "extensions/browser/extension_system.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 97 |
97 LauncherControllerHelper::LauncherControllerHelper(Profile* profile) | 98 LauncherControllerHelper::LauncherControllerHelper(Profile* profile) |
98 : profile_(profile) {} | 99 : profile_(profile) {} |
99 | 100 |
100 LauncherControllerHelper::~LauncherControllerHelper() {} | 101 LauncherControllerHelper::~LauncherControllerHelper() {} |
101 | 102 |
102 // static | 103 // static |
103 base::string16 LauncherControllerHelper::GetAppTitle( | 104 base::string16 LauncherControllerHelper::GetAppTitle( |
104 Profile* profile, | 105 Profile* profile, |
105 const std::string& app_id) { | 106 const std::string& app_id) { |
106 base::string16 title; | |
107 if (app_id.empty()) | 107 if (app_id.empty()) |
108 return title; | 108 return base::string16(); |
109 | 109 |
110 // Get title if the app is an Arc app. | 110 // Get the title if the app is an Arc app. |
111 ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get(profile); | 111 ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get(profile); |
112 if (arc_prefs && arc_prefs->IsRegistered(app_id)) { | 112 const std::string arc_app_id = |
| 113 ArcAppWindowLauncherController::GetArcAppIdFromShelfAppId(app_id); |
| 114 if (arc_prefs && arc_prefs->IsRegistered(arc_app_id)) { |
113 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = | 115 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = |
114 arc_prefs->GetApp(app_id); | 116 arc_prefs->GetApp(arc_app_id); |
115 DCHECK(app_info.get()); | 117 DCHECK(app_info.get()); |
116 if (app_info) | 118 if (app_info) |
117 title = base::UTF8ToUTF16(app_info->name); | 119 return base::UTF8ToUTF16(app_info->name); |
118 return title; | |
119 } | 120 } |
120 | 121 |
121 const extensions::Extension* extension = GetExtensionByID(profile, app_id); | 122 const extensions::Extension* extension = GetExtensionByID(profile, app_id); |
122 if (extension) | 123 if (extension) |
123 title = base::UTF8ToUTF16(extension->name()); | 124 return base::UTF8ToUTF16(extension->name()); |
124 return title; | 125 return base::string16(); |
125 } | 126 } |
126 | 127 |
127 std::string LauncherControllerHelper::GetAppID(content::WebContents* tab) { | 128 std::string LauncherControllerHelper::GetAppID(content::WebContents* tab) { |
128 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 129 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
129 if (profile_manager) { | 130 if (profile_manager) { |
130 const std::vector<Profile*> profile_list = | 131 const std::vector<Profile*> profile_list = |
131 profile_manager->GetLoadedProfiles(); | 132 profile_manager->GetLoadedProfiles(); |
132 if (!profile_list.empty()) { | 133 if (!profile_list.empty()) { |
133 for (auto* i : profile_list) { | 134 for (auto* i : profile_list) { |
134 const extensions::Extension* extension = GetExtensionForTab(i, tab); | 135 const extensions::Extension* extension = GetExtensionForTab(i, tab); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 224 |
224 void LauncherControllerHelper::ExtensionEnableFlowFinished() { | 225 void LauncherControllerHelper::ExtensionEnableFlowFinished() { |
225 LaunchApp(extension_enable_flow_->extension_id(), ash::LAUNCH_FROM_UNKNOWN, | 226 LaunchApp(extension_enable_flow_->extension_id(), ash::LAUNCH_FROM_UNKNOWN, |
226 ui::EF_NONE); | 227 ui::EF_NONE); |
227 extension_enable_flow_.reset(); | 228 extension_enable_flow_.reset(); |
228 } | 229 } |
229 | 230 |
230 void LauncherControllerHelper::ExtensionEnableFlowAborted(bool user_initiated) { | 231 void LauncherControllerHelper::ExtensionEnableFlowAborted(bool user_initiated) { |
231 extension_enable_flow_.reset(); | 232 extension_enable_flow_.reset(); |
232 } | 233 } |
OLD | NEW |