| 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.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "chrome/browser/app_mode/app_mode_utils.h" | 13 #include "chrome/browser/app_mode/app_mode_utils.h" |
| 14 #include "chrome/browser/apps/per_app_settings_service.h" | |
| 15 #include "chrome/browser/apps/per_app_settings_service_factory.h" | |
| 16 #include "chrome/browser/engagement/site_engagement_service.h" | 14 #include "chrome/browser/engagement/site_engagement_service.h" |
| 17 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 18 #include "chrome/browser/extensions/launch_util.h" | 16 #include "chrome/browser/extensions/launch_util.h" |
| 19 #include "chrome/browser/extensions/tab_helper.h" | 17 #include "chrome/browser/extensions/tab_helper.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/ui/app_list/app_list_service.h" | 19 #include "chrome/browser/ui/app_list/app_list_service.h" |
| 22 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| 23 #include "chrome/browser/ui/browser_commands.h" | 21 #include "chrome/browser/ui/browser_commands.h" |
| 24 #include "chrome/browser/ui/browser_finder.h" | 22 #include "chrome/browser/ui/browser_finder.h" |
| 25 #include "chrome/browser/ui/browser_navigator_params.h" | 23 #include "chrome/browser/ui/browser_navigator_params.h" |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 const Extension* extension = GetExtension(params); | 307 const Extension* extension = GetExtension(params); |
| 310 if (!extension) | 308 if (!extension) |
| 311 return NULL; | 309 return NULL; |
| 312 Profile* profile = params.profile; | 310 Profile* profile = params.profile; |
| 313 | 311 |
| 314 WebContents* tab = NULL; | 312 WebContents* tab = NULL; |
| 315 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile); | 313 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile); |
| 316 prefs->SetActiveBit(extension->id(), true); | 314 prefs->SetActiveBit(extension->id(), true); |
| 317 | 315 |
| 318 if (CanLaunchViaEvent(extension)) { | 316 if (CanLaunchViaEvent(extension)) { |
| 319 // Remember what desktop the launch happened on so that when the app opens a | |
| 320 // window we can open them on the right desktop. | |
| 321 PerAppSettingsServiceFactory::GetForBrowserContext(profile)-> | |
| 322 SetDesktopLastLaunchedFrom(extension->id(), params.desktop_type); | |
| 323 | |
| 324 apps::LaunchPlatformAppWithCommandLine(profile, | 317 apps::LaunchPlatformAppWithCommandLine(profile, |
| 325 extension, | 318 extension, |
| 326 params.command_line, | 319 params.command_line, |
| 327 params.current_directory, | 320 params.current_directory, |
| 328 params.source); | 321 params.source); |
| 329 return NULL; | 322 return NULL; |
| 330 } | 323 } |
| 331 | 324 |
| 332 UMA_HISTOGRAM_ENUMERATION("Extensions.HostedAppLaunchContainer", | 325 UMA_HISTOGRAM_ENUMERATION("Extensions.HostedAppLaunchContainer", |
| 333 params.container, | 326 params.container, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 extensions::TabHelper::FromWebContents(tab)->UpdateShortcutOnLoadComplete(); | 410 extensions::TabHelper::FromWebContents(tab)->UpdateShortcutOnLoadComplete(); |
| 418 | 411 |
| 419 return tab; | 412 return tab; |
| 420 } | 413 } |
| 421 | 414 |
| 422 bool CanLaunchViaEvent(const extensions::Extension* extension) { | 415 bool CanLaunchViaEvent(const extensions::Extension* extension) { |
| 423 const extensions::Feature* feature = | 416 const extensions::Feature* feature = |
| 424 extensions::FeatureProvider::GetAPIFeature("app.runtime"); | 417 extensions::FeatureProvider::GetAPIFeature("app.runtime"); |
| 425 return feature->IsAvailableToExtension(extension).is_available(); | 418 return feature->IsAvailableToExtension(extension).is_available(); |
| 426 } | 419 } |
| OLD | NEW |