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" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 if (!arc::IsArcPlayStoreEnabledForProfile(profile()) && | 161 if (!arc::IsArcPlayStoreEnabledForProfile(profile()) && |
162 arc::IsArcPlayStoreEnabledPreferenceManagedForProfile(profile())) | 162 arc::IsArcPlayStoreEnabledPreferenceManagedForProfile(profile())) |
163 return false; | 163 return false; |
164 } | 164 } |
165 | 165 |
166 return true; | 166 return true; |
167 } | 167 } |
168 | 168 |
169 void LauncherControllerHelper::LaunchApp(const ash::ShelfID& id, | 169 void LauncherControllerHelper::LaunchApp(const ash::ShelfID& id, |
170 ash::ShelfLaunchSource source, | 170 ash::ShelfLaunchSource source, |
171 int event_flags) { | 171 int event_flags, |
172 const aura::Window* root_window) { | |
172 const std::string& app_id = id.app_id; | 173 const std::string& app_id = id.app_id; |
173 const ArcAppListPrefs* arc_prefs = GetArcAppListPrefs(); | 174 const ArcAppListPrefs* arc_prefs = GetArcAppListPrefs(); |
174 if (arc_prefs && arc_prefs->IsRegistered(app_id)) { | 175 if (arc_prefs && arc_prefs->IsRegistered(app_id)) { |
175 arc::LaunchApp(profile_, app_id, event_flags); | 176 arc::LaunchApp(profile_, app_id, event_flags); |
176 return; | 177 return; |
177 } | 178 } |
178 | |
179 // |extension| could be null when it is being unloaded for updating. | 179 // |extension| could be null when it is being unloaded for updating. |
180 const extensions::Extension* extension = GetExtensionByID(profile_, app_id); | 180 const extensions::Extension* extension = GetExtensionByID(profile_, app_id); |
181 if (!extension) | 181 if (!extension) |
182 return; | 182 return; |
183 | 183 |
184 if (!extensions::util::IsAppLaunchableWithoutEnabling(app_id, profile_)) { | 184 if (!extensions::util::IsAppLaunchableWithoutEnabling(app_id, profile_)) { |
185 // Do nothing if there is already a running enable flow. | 185 // Do nothing if there is already a running enable flow. |
186 if (extension_enable_flow_) | 186 if (extension_enable_flow_) |
187 return; | 187 return; |
188 | 188 |
189 extension_enable_flow_.reset( | 189 extension_enable_flow_.reset( |
190 new ExtensionEnableFlow(profile_, app_id, this)); | 190 new ExtensionEnableFlow(profile_, app_id, this)); |
191 extension_enable_flow_->StartForNativeWindow(nullptr); | 191 extension_enable_flow_->StartForNativeWindow(nullptr); |
192 return; | 192 return; |
193 } | 193 } |
194 | 194 |
195 // The app will be created for the currently active profile. | 195 // The app will be created for the currently active profile. |
196 AppLaunchParams params = CreateAppLaunchParamsWithEventFlags( | 196 AppLaunchParams params = CreateAppLaunchParamsWithEventFlags( |
197 profile_, extension, event_flags, extensions::SOURCE_APP_LAUNCHER); | 197 profile_, extension, event_flags, extensions::SOURCE_APP_LAUNCHER, |
198 root_window); | |
198 if (source != ash::LAUNCH_FROM_UNKNOWN && | 199 if (source != ash::LAUNCH_FROM_UNKNOWN && |
199 app_id == extensions::kWebStoreAppId) { | 200 app_id == extensions::kWebStoreAppId) { |
200 // Get the corresponding source string. | 201 // Get the corresponding source string. |
201 std::string source_value = GetSourceFromAppListSource(source); | 202 std::string source_value = GetSourceFromAppListSource(source); |
202 | 203 |
203 // Set an override URL to include the source. | 204 // Set an override URL to include the source. |
204 GURL extension_url = extensions::AppLaunchInfo::GetFullLaunchURL(extension); | 205 GURL extension_url = extensions::AppLaunchInfo::GetFullLaunchURL(extension); |
205 params.override_url = net::AppendQueryParameter( | 206 params.override_url = net::AppendQueryParameter( |
206 extension_url, extension_urls::kWebstoreSourceField, source_value); | 207 extension_url, extension_urls::kWebstoreSourceField, source_value); |
207 } | 208 } |
208 params.launch_id = id.launch_id; | 209 params.launch_id = id.launch_id; |
209 | |
210 OpenApplication(params); | 210 OpenApplication(params); |
211 } | 211 } |
212 | 212 |
213 ArcAppListPrefs* LauncherControllerHelper::GetArcAppListPrefs() const { | 213 ArcAppListPrefs* LauncherControllerHelper::GetArcAppListPrefs() const { |
214 return ArcAppListPrefs::Get(profile_); | 214 return ArcAppListPrefs::Get(profile_); |
215 } | 215 } |
216 | 216 |
217 void LauncherControllerHelper::ExtensionEnableFlowFinished() { | 217 void LauncherControllerHelper::ExtensionEnableFlowFinished() { |
218 LaunchApp(ash::ShelfID(extension_enable_flow_->extension_id()), | 218 LaunchApp(ash::ShelfID(extension_enable_flow_->extension_id()), |
219 ash::LAUNCH_FROM_UNKNOWN, ui::EF_NONE); | 219 ash::LAUNCH_FROM_UNKNOWN, ui::EF_NONE, NULL); |
stevenjb
2017/05/22 17:55:29
nullptr
| |
220 extension_enable_flow_.reset(); | 220 extension_enable_flow_.reset(); |
221 } | 221 } |
222 | 222 |
223 void LauncherControllerHelper::ExtensionEnableFlowAborted(bool user_initiated) { | 223 void LauncherControllerHelper::ExtensionEnableFlowAborted(bool user_initiated) { |
224 extension_enable_flow_.reset(); | 224 extension_enable_flow_.reset(); |
225 } | 225 } |
OLD | NEW |