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/extensions/application_launch.h" | 5 #include "chrome/browser/ui/extensions/application_launch.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "apps/launcher.h" | 9 #include "apps/launcher.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 chrome::ToggleFullscreenMode(browser); | 292 chrome::ToggleFullscreenMode(browser); |
293 } | 293 } |
294 #endif // USE_ASH | 294 #endif // USE_ASH |
295 return contents; | 295 return contents; |
296 } | 296 } |
297 | 297 |
298 WebContents* OpenEnabledApplication(const AppLaunchParams& params) { | 298 WebContents* OpenEnabledApplication(const AppLaunchParams& params) { |
299 const Extension* extension = GetExtension(params); | 299 const Extension* extension = GetExtension(params); |
300 if (!extension) | 300 if (!extension) |
301 return NULL; | 301 return NULL; |
| 302 Profile* profile = params.profile; |
302 | 303 |
303 WebContents* tab = NULL; | 304 WebContents* tab = NULL; |
304 ExtensionPrefs* prefs = ExtensionPrefs::Get(params.profile); | 305 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile); |
305 prefs->SetActiveBit(extension->id(), true); | 306 prefs->SetActiveBit(extension->id(), true); |
306 | 307 |
307 if (CanLaunchViaEvent(extension)) { | 308 if (CanLaunchViaEvent(extension)) { |
308 apps::LaunchPlatformAppWithCommandLine( | 309 apps::LaunchPlatformAppWithCommandLine(profile, |
309 params.profile, extension, params.command_line, | 310 extension, |
310 params.current_directory, params.source, params.play_store_status); | 311 params.command_line, |
| 312 params.current_directory, |
| 313 params.source); |
311 return NULL; | 314 return NULL; |
312 } | 315 } |
313 | 316 |
314 UMA_HISTOGRAM_ENUMERATION("Extensions.HostedAppLaunchContainer", | 317 UMA_HISTOGRAM_ENUMERATION("Extensions.HostedAppLaunchContainer", |
315 params.container, | 318 params.container, |
316 extensions::NUM_LAUNCH_CONTAINERS); | 319 extensions::NUM_LAUNCH_CONTAINERS); |
317 | 320 |
318 GURL url = UrlForExtension(extension, params.override_url); | 321 GURL url = UrlForExtension(extension, params.override_url); |
319 if (extension->from_bookmark()) { | 322 if (extension->from_bookmark()) { |
320 UMA_HISTOGRAM_ENUMERATION("Extensions.BookmarkAppLaunchContainer", | 323 UMA_HISTOGRAM_ENUMERATION("Extensions.BookmarkAppLaunchContainer", |
321 params.container, | 324 params.container, |
322 extensions::NUM_LAUNCH_CONTAINERS); | 325 extensions::NUM_LAUNCH_CONTAINERS); |
323 | 326 |
324 // Record the launch time in the site engagement service. A recent bookmark | 327 // Record the launch time in the site engagement service. A recent bookmark |
325 // app launch will provide an engagement boost to the origin. | 328 // app launch will provide an engagement boost to the origin. |
326 SiteEngagementService* service = SiteEngagementService::Get(params.profile); | 329 SiteEngagementService* service = SiteEngagementService::Get(profile); |
327 if (service) | 330 if (service) |
328 service->SetLastShortcutLaunchTime(url); | 331 service->SetLastShortcutLaunchTime(url); |
329 } | 332 } |
330 | 333 |
331 // Record v1 app launch. Platform app launch is recorded when dispatching | 334 // Record v1 app launch. Platform app launch is recorded when dispatching |
332 // the onLaunched event. | 335 // the onLaunched event. |
333 prefs->SetLastLaunchTime(extension->id(), base::Time::Now()); | 336 prefs->SetLastLaunchTime(extension->id(), base::Time::Now()); |
334 | 337 |
335 switch (params.container) { | 338 switch (params.container) { |
336 case extensions::LAUNCH_CONTAINER_NONE: { | 339 case extensions::LAUNCH_CONTAINER_NONE: { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 extensions::TabHelper::FromWebContents(tab)->UpdateShortcutOnLoadComplete(); | 401 extensions::TabHelper::FromWebContents(tab)->UpdateShortcutOnLoadComplete(); |
399 | 402 |
400 return tab; | 403 return tab; |
401 } | 404 } |
402 | 405 |
403 bool CanLaunchViaEvent(const extensions::Extension* extension) { | 406 bool CanLaunchViaEvent(const extensions::Extension* extension) { |
404 const extensions::Feature* feature = | 407 const extensions::Feature* feature = |
405 extensions::FeatureProvider::GetAPIFeature("app.runtime"); | 408 extensions::FeatureProvider::GetAPIFeature("app.runtime"); |
406 return feature && feature->IsAvailableToExtension(extension).is_available(); | 409 return feature && feature->IsAvailableToExtension(extension).is_available(); |
407 } | 410 } |
OLD | NEW |