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