Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: chrome/browser/ui/ash/launcher/launcher_controller_helper.cc

Issue 1960293003: Remove OS_CHROMEOS from ui/ash code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/extensions/extension_service.h" 11 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/extensions/extension_util.h" 12 #include "chrome/browser/extensions/extension_util.h"
13 #include "chrome/browser/extensions/launch_util.h" 13 #include "chrome/browser/extensions/launch_util.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/profiles/profile_manager.h" 15 #include "chrome/browser/profiles/profile_manager.h"
16 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
17 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
16 #include "chrome/browser/ui/browser_finder.h" 18 #include "chrome/browser/ui/browser_finder.h"
17 #include "chrome/browser/ui/extensions/app_launch_params.h" 19 #include "chrome/browser/ui/extensions/app_launch_params.h"
18 #include "chrome/browser/ui/extensions/application_launch.h" 20 #include "chrome/browser/ui/extensions/application_launch.h"
19 #include "chrome/browser/ui/extensions/extension_enable_flow.h" 21 #include "chrome/browser/ui/extensions/extension_enable_flow.h"
20 #include "chrome/browser/web_applications/web_app.h" 22 #include "chrome/browser/web_applications/web_app.h"
21 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 23 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
22 #include "content/public/browser/navigation_entry.h" 24 #include "content/public/browser/navigation_entry.h"
23 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
24 #include "extensions/browser/extension_registry.h" 26 #include "extensions/browser/extension_registry.h"
25 #include "extensions/browser/extension_system.h" 27 #include "extensions/browser/extension_system.h"
26 #include "extensions/common/extension.h" 28 #include "extensions/common/extension.h"
27 #include "extensions/common/extension_set.h" 29 #include "extensions/common/extension_set.h"
28 #include "net/base/url_util.h" 30 #include "net/base/url_util.h"
29 #include "ui/events/event_constants.h" 31 #include "ui/events/event_constants.h"
30 32
31 #if defined(OS_CHROMEOS)
32 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
33 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
34 #endif
35
36 namespace { 33 namespace {
37 34
38 const extensions::Extension* GetExtensionForTab(Profile* profile, 35 const extensions::Extension* GetExtensionForTab(Profile* profile,
39 content::WebContents* tab) { 36 content::WebContents* tab) {
40 ExtensionService* extension_service = 37 ExtensionService* extension_service =
41 extensions::ExtensionSystem::Get(profile)->extension_service(); 38 extensions::ExtensionSystem::Get(profile)->extension_service();
42 if (!extension_service || !extension_service->extensions_enabled()) 39 if (!extension_service || !extension_service->extensions_enabled())
43 return nullptr; 40 return nullptr;
44 41
45 // Note: It is possible to come here after a tab got removed form the browser 42 // Note: It is possible to come here after a tab got removed form the browser
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 LauncherControllerHelper::~LauncherControllerHelper() {} 99 LauncherControllerHelper::~LauncherControllerHelper() {}
103 100
104 // static 101 // static
105 base::string16 LauncherControllerHelper::GetAppTitle( 102 base::string16 LauncherControllerHelper::GetAppTitle(
106 Profile* profile, 103 Profile* profile,
107 const std::string& app_id) { 104 const std::string& app_id) {
108 base::string16 title; 105 base::string16 title;
109 if (app_id.empty()) 106 if (app_id.empty())
110 return title; 107 return title;
111 108
112 #if defined(OS_CHROMEOS)
113 // Get title if the app is an Arc app. 109 // Get title if the app is an Arc app.
114 ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get(profile); 110 ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get(profile);
115 DCHECK(arc_prefs); 111 DCHECK(arc_prefs);
116 if (arc_prefs->IsRegistered(app_id)) { 112 if (arc_prefs->IsRegistered(app_id)) {
117 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = 113 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info =
118 arc_prefs->GetApp(app_id); 114 arc_prefs->GetApp(app_id);
119 DCHECK(app_info.get()); 115 DCHECK(app_info.get());
120 if (app_info) 116 if (app_info)
121 title = base::UTF8ToUTF16(app_info->name); 117 title = base::UTF8ToUTF16(app_info->name);
122 return title; 118 return title;
123 } 119 }
124 #endif // defined(OS_CHROMEOS)
125 120
126 const extensions::Extension* extension = GetExtensionByID(profile, app_id); 121 const extensions::Extension* extension = GetExtensionByID(profile, app_id);
127 if (extension) 122 if (extension)
128 title = base::UTF8ToUTF16(extension->name()); 123 title = base::UTF8ToUTF16(extension->name());
129 return title; 124 return title;
130 } 125 }
131 126
132 std::string LauncherControllerHelper::GetAppID(content::WebContents* tab) { 127 std::string LauncherControllerHelper::GetAppID(content::WebContents* tab) {
133 ProfileManager* profile_manager = g_browser_process->profile_manager(); 128 ProfileManager* profile_manager = g_browser_process->profile_manager();
134 if (profile_manager) { 129 if (profile_manager) {
135 const std::vector<Profile*> profile_list = 130 const std::vector<Profile*> profile_list =
136 profile_manager->GetLoadedProfiles(); 131 profile_manager->GetLoadedProfiles();
137 if (!profile_list.empty()) { 132 if (!profile_list.empty()) {
138 for (const auto& i : profile_list) { 133 for (const auto& i : profile_list) {
139 const extensions::Extension* extension = GetExtensionForTab(i, tab); 134 const extensions::Extension* extension = GetExtensionForTab(i, tab);
140 if (extension) 135 if (extension)
141 return extension->id(); 136 return extension->id();
142 } 137 }
143 return std::string(); 138 return std::string();
144 } 139 }
145 } 140 }
146 // If there is no profile manager we only use the known profile. 141 // If there is no profile manager we only use the known profile.
147 const extensions::Extension* extension = GetExtensionForTab(profile_, tab); 142 const extensions::Extension* extension = GetExtensionForTab(profile_, tab);
148 return extension ? extension->id() : std::string(); 143 return extension ? extension->id() : std::string();
149 } 144 }
150 145
151 bool LauncherControllerHelper::IsValidIDForCurrentUser(const std::string& id) { 146 bool LauncherControllerHelper::IsValidIDForCurrentUser(const std::string& id) {
152 #if defined(OS_CHROMEOS)
153 if (ArcAppListPrefs::Get(profile_)->IsRegistered(id)) 147 if (ArcAppListPrefs::Get(profile_)->IsRegistered(id))
154 return true; 148 return true;
155 #endif
156 return GetExtensionByID(profile_, id) != nullptr; 149 return GetExtensionByID(profile_, id) != nullptr;
157 } 150 }
158 151
159 void LauncherControllerHelper::SetCurrentUser(Profile* profile) { 152 void LauncherControllerHelper::SetCurrentUser(Profile* profile) {
160 profile_ = profile; 153 profile_ = profile;
161 } 154 }
162 155
163 void LauncherControllerHelper::LaunchApp(const std::string& app_id, 156 void LauncherControllerHelper::LaunchApp(const std::string& app_id,
164 ash::LaunchSource source, 157 ash::LaunchSource source,
165 int event_flags) { 158 int event_flags) {
166 #if defined(OS_CHROMEOS)
167 if (ArcAppListPrefs::Get(profile_)->IsRegistered(app_id)) { 159 if (ArcAppListPrefs::Get(profile_)->IsRegistered(app_id)) {
168 arc::LaunchApp(profile_, app_id); 160 arc::LaunchApp(profile_, app_id);
169 return; 161 return;
170 } 162 }
171 #endif
172 163
173 // |extension| could be null when it is being unloaded for updating. 164 // |extension| could be null when it is being unloaded for updating.
174 const extensions::Extension* extension = GetExtensionByID(profile_, app_id); 165 const extensions::Extension* extension = GetExtensionByID(profile_, app_id);
175 if (!extension) 166 if (!extension)
176 return; 167 return;
177 168
178 if (!extensions::util::IsAppLaunchableWithoutEnabling(app_id, profile_)) { 169 if (!extensions::util::IsAppLaunchableWithoutEnabling(app_id, profile_)) {
179 // Do nothing if there is already a running enable flow. 170 // Do nothing if there is already a running enable flow.
180 if (extension_enable_flow_) 171 if (extension_enable_flow_)
181 return; 172 return;
(...skipping 23 matching lines...) Expand all
205 196
206 void LauncherControllerHelper::ExtensionEnableFlowFinished() { 197 void LauncherControllerHelper::ExtensionEnableFlowFinished() {
207 LaunchApp(extension_enable_flow_->extension_id(), ash::LAUNCH_FROM_UNKNOWN, 198 LaunchApp(extension_enable_flow_->extension_id(), ash::LAUNCH_FROM_UNKNOWN,
208 ui::EF_NONE); 199 ui::EF_NONE);
209 extension_enable_flow_.reset(); 200 extension_enable_flow_.reset();
210 } 201 }
211 202
212 void LauncherControllerHelper::ExtensionEnableFlowAborted(bool user_initiated) { 203 void LauncherControllerHelper::ExtensionEnableFlowAborted(bool user_initiated) {
213 extension_enable_flow_.reset(); 204 extension_enable_flow_.reset();
214 } 205 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698