Chromium Code Reviews| 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/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 const Extension* extension = GetExtension(params); | 137 const Extension* extension = GetExtension(params); |
| 138 if (!extension) | 138 if (!extension) |
| 139 return NULL; | 139 return NULL; |
| 140 Profile* profile = params.profile; | 140 Profile* profile = params.profile; |
| 141 | 141 |
| 142 WebContents* tab = NULL; | 142 WebContents* tab = NULL; |
| 143 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile); | 143 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile); |
| 144 prefs->SetActiveBit(extension->id(), true); | 144 prefs->SetActiveBit(extension->id(), true); |
| 145 | 145 |
| 146 UMA_HISTOGRAM_ENUMERATION( | 146 UMA_HISTOGRAM_ENUMERATION( |
| 147 "Extensions.AppLaunchContainer", params.container, 100); | 147 "Extensions.AppLaunchContainer", params.container, 100); |
|
tapted
2014/11/28 00:35:16
Should we just delete this? params.container doesn
| |
| 148 | 148 |
| 149 if (CanLaunchViaEvent(extension)) { | 149 if (CanLaunchViaEvent(extension)) { |
| 150 // Remember what desktop the launch happened on so that when the app opens a | 150 // Remember what desktop the launch happened on so that when the app opens a |
| 151 // window we can open them on the right desktop. | 151 // window we can open them on the right desktop. |
| 152 PerAppSettingsServiceFactory::GetForBrowserContext(profile)-> | 152 PerAppSettingsServiceFactory::GetForBrowserContext(profile)-> |
| 153 SetDesktopLastLaunchedFrom(extension->id(), params.desktop_type); | 153 SetDesktopLastLaunchedFrom(extension->id(), params.desktop_type); |
| 154 | 154 |
| 155 apps::LaunchPlatformAppWithCommandLine(profile, | 155 apps::LaunchPlatformAppWithCommandLine(profile, |
| 156 extension, | 156 extension, |
| 157 params.command_line, | 157 params.command_line, |
| 158 params.current_directory, | 158 params.current_directory, |
| 159 params.source); | 159 params.source); |
| 160 return NULL; | 160 return NULL; |
| 161 } | 161 } |
| 162 | 162 |
| 163 UMA_HISTOGRAM_ENUMERATION( | |
| 164 "Extensions.HostedAppLaunchContainer", params.container, 100); | |
| 165 | |
| 163 // Record v1 app launch. Platform app launch is recorded when dispatching | 166 // Record v1 app launch. Platform app launch is recorded when dispatching |
| 164 // the onLaunched event. | 167 // the onLaunched event. |
| 165 prefs->SetLastLaunchTime(extension->id(), base::Time::Now()); | 168 prefs->SetLastLaunchTime(extension->id(), base::Time::Now()); |
| 166 | 169 |
| 167 GURL url = UrlForExtension(extension, params.override_url); | 170 GURL url = UrlForExtension(extension, params.override_url); |
| 168 switch (params.container) { | 171 switch (params.container) { |
| 169 case extensions::LAUNCH_CONTAINER_NONE: { | 172 case extensions::LAUNCH_CONTAINER_NONE: { |
| 170 NOTREACHED(); | 173 NOTREACHED(); |
| 171 break; | 174 break; |
| 172 } | 175 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 | 239 |
| 237 return tab; | 240 return tab; |
| 238 } | 241 } |
| 239 | 242 |
| 240 bool CanLaunchViaEvent(const extensions::Extension* extension) { | 243 bool CanLaunchViaEvent(const extensions::Extension* extension) { |
| 241 const extensions::FeatureProvider* feature_provider = | 244 const extensions::FeatureProvider* feature_provider = |
| 242 extensions::FeatureProvider::GetAPIFeatures(); | 245 extensions::FeatureProvider::GetAPIFeatures(); |
| 243 extensions::Feature* feature = feature_provider->GetFeature("app.runtime"); | 246 extensions::Feature* feature = feature_provider->GetFeature("app.runtime"); |
| 244 return feature->IsAvailableToExtension(extension).is_available(); | 247 return feature->IsAvailableToExtension(extension).is_available(); |
| 245 } | 248 } |
| OLD | NEW |