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

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

Issue 2523053004: Enhance chrome.app.window API for shelf integration with restore support (Closed)
Patch Set: Review v2 Created 4 years 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"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 201
202 // Set an override URL to include the source. 202 // Set an override URL to include the source.
203 GURL extension_url = extensions::AppLaunchInfo::GetFullLaunchURL(extension); 203 GURL extension_url = extensions::AppLaunchInfo::GetFullLaunchURL(extension);
204 params.override_url = net::AppendQueryParameter( 204 params.override_url = net::AppendQueryParameter(
205 extension_url, extension_urls::kWebstoreSourceField, source_value); 205 extension_url, extension_urls::kWebstoreSourceField, source_value);
206 } 206 }
207 207
208 OpenApplication(params); 208 OpenApplication(params);
209 } 209 }
210 210
211 void LauncherControllerHelper::LaunchAppWithLaunchId(
212 const std::string& app_id,
213 const std::string& launch_id,
214 ash::LaunchSource source,
215 int event_flags) {
216 const ArcAppListPrefs* arc_prefs = GetArcAppListPrefs();
217 if (arc_prefs && arc_prefs->IsRegistered(app_id)) {
218 arc::LaunchApp(profile_, app_id, event_flags);
219 return;
220 }
221
222 // |extension| could be null when it is being unloaded for updating.
223 const extensions::Extension* extension = GetExtensionByID(profile_, app_id);
224 if (!extension)
225 return;
226
227 if (!extensions::util::IsAppLaunchableWithoutEnabling(app_id, profile_)) {
228 // Do nothing if there is already a running enable flow.
229 if (extension_enable_flow_)
230 return;
231
232 extension_enable_flow_.reset(
233 new ExtensionEnableFlow(profile_, app_id, this));
234 extension_enable_flow_->StartForNativeWindow(nullptr);
235 return;
236 }
237
238 // The app will be created for the currently active profile.
239 AppLaunchParams params = CreateAppLaunchParamsWithEventFlags(
240 profile_, extension, event_flags, extensions::SOURCE_APP_LAUNCHER);
241 if (source != ash::LAUNCH_FROM_UNKNOWN &&
242 app_id == extensions::kWebStoreAppId) {
243 // Get the corresponding source string.
244 std::string source_value = GetSourceFromAppListSource(source);
245
246 // Set an override URL to include the source.
247 GURL extension_url = extensions::AppLaunchInfo::GetFullLaunchURL(extension);
248 params.override_url = net::AppendQueryParameter(
249 extension_url, extension_urls::kWebstoreSourceField, source_value);
250 }
251 params.launch_id = launch_id;
252
253 OpenApplication(params);
254 }
255
211 ArcAppListPrefs* LauncherControllerHelper::GetArcAppListPrefs() const { 256 ArcAppListPrefs* LauncherControllerHelper::GetArcAppListPrefs() const {
212 return ArcAppListPrefs::Get(profile_); 257 return ArcAppListPrefs::Get(profile_);
213 } 258 }
214 259
215 void LauncherControllerHelper::ExtensionEnableFlowFinished() { 260 void LauncherControllerHelper::ExtensionEnableFlowFinished() {
216 LaunchApp(extension_enable_flow_->extension_id(), ash::LAUNCH_FROM_UNKNOWN, 261 LaunchApp(extension_enable_flow_->extension_id(), ash::LAUNCH_FROM_UNKNOWN,
217 ui::EF_NONE); 262 ui::EF_NONE);
218 extension_enable_flow_.reset(); 263 extension_enable_flow_.reset();
219 } 264 }
220 265
221 void LauncherControllerHelper::ExtensionEnableFlowAborted(bool user_initiated) { 266 void LauncherControllerHelper::ExtensionEnableFlowAborted(bool user_initiated) {
222 extension_enable_flow_.reset(); 267 extension_enable_flow_.reset();
223 } 268 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698