| 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" |
| 11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 12 #include "base/time/time.h" |
| 12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 13 #include "chrome/browser/app_mode/app_mode_utils.h" | 14 #include "chrome/browser/app_mode/app_mode_utils.h" |
| 15 #include "chrome/browser/banners/app_banner_settings_helper.h" |
| 14 #include "chrome/browser/engagement/site_engagement_service.h" | 16 #include "chrome/browser/engagement/site_engagement_service.h" |
| 15 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
| 16 #include "chrome/browser/extensions/launch_util.h" | 18 #include "chrome/browser/extensions/launch_util.h" |
| 17 #include "chrome/browser/extensions/tab_helper.h" | 19 #include "chrome/browser/extensions/tab_helper.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/ui/app_list/app_list_service.h" | 21 #include "chrome/browser/ui/app_list/app_list_service.h" |
| 20 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
| 21 #include "chrome/browser/ui/browser_commands.h" | 23 #include "chrome/browser/ui/browser_commands.h" |
| 22 #include "chrome/browser/ui/browser_finder.h" | 24 #include "chrome/browser/ui/browser_finder.h" |
| 23 #include "chrome/browser/ui/browser_navigator_params.h" | 25 #include "chrome/browser/ui/browser_navigator_params.h" |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 params.profile, extension, params.launch_id, params.command_line, | 311 params.profile, extension, params.launch_id, params.command_line, |
| 310 params.current_directory, params.source, params.play_store_status); | 312 params.current_directory, params.source, params.play_store_status); |
| 311 return NULL; | 313 return NULL; |
| 312 } | 314 } |
| 313 | 315 |
| 314 UMA_HISTOGRAM_ENUMERATION("Extensions.HostedAppLaunchContainer", | 316 UMA_HISTOGRAM_ENUMERATION("Extensions.HostedAppLaunchContainer", |
| 315 params.container, | 317 params.container, |
| 316 extensions::NUM_LAUNCH_CONTAINERS); | 318 extensions::NUM_LAUNCH_CONTAINERS); |
| 317 | 319 |
| 318 GURL url = UrlForExtension(extension, params.override_url); | 320 GURL url = UrlForExtension(extension, params.override_url); |
| 319 if (extension->from_bookmark()) { | |
| 320 UMA_HISTOGRAM_ENUMERATION("Extensions.BookmarkAppLaunchContainer", | |
| 321 params.container, | |
| 322 extensions::NUM_LAUNCH_CONTAINERS); | |
| 323 | |
| 324 // Record the launch time in the site engagement service. A recent bookmark | |
| 325 // app launch will provide an engagement boost to the origin. | |
| 326 SiteEngagementService* service = SiteEngagementService::Get(params.profile); | |
| 327 service->SetLastShortcutLaunchTime(url); | |
| 328 } | |
| 329 | 321 |
| 330 // Record v1 app launch. Platform app launch is recorded when dispatching | 322 // Record v1 app launch. Platform app launch is recorded when dispatching |
| 331 // the onLaunched event. | 323 // the onLaunched event. |
| 332 prefs->SetLastLaunchTime(extension->id(), base::Time::Now()); | 324 prefs->SetLastLaunchTime(extension->id(), base::Time::Now()); |
| 333 | 325 |
| 334 switch (params.container) { | 326 switch (params.container) { |
| 335 case extensions::LAUNCH_CONTAINER_NONE: { | 327 case extensions::LAUNCH_CONTAINER_NONE: { |
| 336 NOTREACHED(); | 328 NOTREACHED(); |
| 337 break; | 329 break; |
| 338 } | 330 } |
| 339 case extensions::LAUNCH_CONTAINER_PANEL: | 331 case extensions::LAUNCH_CONTAINER_PANEL: |
| 340 case extensions::LAUNCH_CONTAINER_WINDOW: | 332 case extensions::LAUNCH_CONTAINER_WINDOW: |
| 341 tab = OpenApplicationWindow(params, url); | 333 tab = OpenApplicationWindow(params, url); |
| 342 break; | 334 break; |
| 343 case extensions::LAUNCH_CONTAINER_TAB: { | 335 case extensions::LAUNCH_CONTAINER_TAB: { |
| 344 tab = OpenApplicationTab(params, url); | 336 tab = OpenApplicationTab(params, url); |
| 345 break; | 337 break; |
| 346 } | 338 } |
| 347 default: | 339 default: |
| 348 NOTREACHED(); | 340 NOTREACHED(); |
| 349 break; | 341 break; |
| 350 } | 342 } |
| 343 |
| 344 if (extension->from_bookmark()) { |
| 345 UMA_HISTOGRAM_ENUMERATION("Extensions.BookmarkAppLaunchContainer", |
| 346 params.container, |
| 347 extensions::NUM_LAUNCH_CONTAINERS); |
| 348 |
| 349 // Record the launch time in the site engagement service. A recent bookmark |
| 350 // app launch will provide an engagement boost to the origin. |
| 351 SiteEngagementService* service = SiteEngagementService::Get(params.profile); |
| 352 service->SetLastShortcutLaunchTime(url); |
| 353 |
| 354 // Refresh the app banner added to homescreen event. The user may have |
| 355 // cleared their browsing data since installing the app, which removes the |
| 356 // event and will potentially permit a banner to be shown for the site. |
| 357 AppBannerSettingsHelper::RecordBannerEvent( |
| 358 tab, url, url.spec(), |
| 359 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, |
| 360 base::Time::Now()); |
| 361 } |
| 351 return tab; | 362 return tab; |
| 352 } | 363 } |
| 353 | 364 |
| 354 } // namespace | 365 } // namespace |
| 355 | 366 |
| 356 WebContents* OpenApplication(const AppLaunchParams& params) { | 367 WebContents* OpenApplication(const AppLaunchParams& params) { |
| 357 return OpenEnabledApplication(params); | 368 return OpenEnabledApplication(params); |
| 358 } | 369 } |
| 359 | 370 |
| 360 void OpenApplicationWithReenablePrompt(const AppLaunchParams& params) { | 371 void OpenApplicationWithReenablePrompt(const AppLaunchParams& params) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 extensions::TabHelper::FromWebContents(tab)->UpdateShortcutOnLoadComplete(); | 409 extensions::TabHelper::FromWebContents(tab)->UpdateShortcutOnLoadComplete(); |
| 399 | 410 |
| 400 return tab; | 411 return tab; |
| 401 } | 412 } |
| 402 | 413 |
| 403 bool CanLaunchViaEvent(const extensions::Extension* extension) { | 414 bool CanLaunchViaEvent(const extensions::Extension* extension) { |
| 404 const extensions::Feature* feature = | 415 const extensions::Feature* feature = |
| 405 extensions::FeatureProvider::GetAPIFeature("app.runtime"); | 416 extensions::FeatureProvider::GetAPIFeature("app.runtime"); |
| 406 return feature && feature->IsAvailableToExtension(extension).is_available(); | 417 return feature && feature->IsAvailableToExtension(extension).is_available(); |
| 407 } | 418 } |
| OLD | NEW |