| 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" |
| 11 #include "chrome/browser/apps/per_app_settings_service.h" | 11 #include "chrome/browser/apps/per_app_settings_service.h" |
| 12 #include "chrome/browser/apps/per_app_settings_service_factory.h" | 12 #include "chrome/browser/apps/per_app_settings_service_factory.h" |
| 13 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
| 14 #include "chrome/browser/extensions/tab_helper.h" | 14 #include "chrome/browser/extensions/tab_helper.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/app_list/app_list_service.h" | 16 #include "chrome/browser/ui/app_list/app_list_service.h" |
| 17 #include "chrome/browser/ui/extensions/app_launch_params.h" | 17 #include "chrome/browser/ui/extensions/app_launch_params.h" |
| 18 #include "chrome/browser/ui/extensions/application_launch_web_app.h" | 18 #include "chrome/browser/ui/extensions/application_launch_web_app.h" |
| 19 #include "chrome/browser/ui/extensions/extension_enable_flow.h" | 19 #include "chrome/browser/ui/extensions/extension_enable_flow.h" |
| 20 #include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h" | 20 #include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h" |
| 21 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 21 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
| 22 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
| 23 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 24 #include "extensions/browser/extension_prefs.h" | 24 #include "extensions/browser/extension_prefs.h" |
| 25 #include "extensions/browser/extension_registry.h" | 25 #include "extensions/browser/extension_registry.h" |
| 26 #include "extensions/browser/extension_system.h" | 26 #include "extensions/browser/extension_system.h" |
| 27 #include "extensions/common/constants.h" |
| 27 #include "extensions/common/extension.h" | 28 #include "extensions/common/extension.h" |
| 28 #include "extensions/common/features/feature.h" | 29 #include "extensions/common/features/feature.h" |
| 29 #include "extensions/common/features/feature_provider.h" | 30 #include "extensions/common/features/feature_provider.h" |
| 30 #include "extensions/common/manifest_handlers/options_page_info.h" | 31 #include "extensions/common/manifest_handlers/options_page_info.h" |
| 31 | 32 |
| 32 using content::WebContents; | 33 using content::WebContents; |
| 33 using extensions::Extension; | 34 using extensions::Extension; |
| 34 using extensions::ExtensionPrefs; | 35 using extensions::ExtensionPrefs; |
| 35 using extensions::ExtensionRegistry; | 36 using extensions::ExtensionRegistry; |
| 36 | 37 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 service, profile, extension->id(), dialog_parent_window_getter, | 214 service, profile, extension->id(), dialog_parent_window_getter, |
| 214 base::Bind(base::IgnoreResult(OpenEnabledApplication), params)))->Run(); | 215 base::Bind(base::IgnoreResult(OpenEnabledApplication), params)))->Run(); |
| 215 return; | 216 return; |
| 216 } | 217 } |
| 217 | 218 |
| 218 OpenEnabledApplication(params); | 219 OpenEnabledApplication(params); |
| 219 } | 220 } |
| 220 | 221 |
| 221 WebContents* OpenAppShortcutWindow(Profile* profile, | 222 WebContents* OpenAppShortcutWindow(Profile* profile, |
| 222 const GURL& url) { | 223 const GURL& url) { |
| 223 AppLaunchParams launch_params( | 224 AppLaunchParams launch_params(profile, |
| 224 profile, | 225 NULL, // this is a URL app. No extension. |
| 225 NULL, // this is a URL app. No extension. | 226 extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW, |
| 226 extensions::LAUNCH_CONTAINER_WINDOW, | 227 extensions::SOURCE_COMMAND_LINE); |
| 227 NEW_WINDOW); | |
| 228 launch_params.override_url = url; | 228 launch_params.override_url = url; |
| 229 | 229 |
| 230 WebContents* tab = OpenWebAppWindow(launch_params, url); | 230 WebContents* tab = OpenWebAppWindow(launch_params, url); |
| 231 | 231 |
| 232 if (!tab) | 232 if (!tab) |
| 233 return NULL; | 233 return NULL; |
| 234 | 234 |
| 235 extensions::TabHelper::FromWebContents(tab)->UpdateShortcutOnLoadComplete(); | 235 extensions::TabHelper::FromWebContents(tab)->UpdateShortcutOnLoadComplete(); |
| 236 | 236 |
| 237 return tab; | 237 return tab; |
| 238 } | 238 } |
| 239 | 239 |
| 240 bool CanLaunchViaEvent(const extensions::Extension* extension) { | 240 bool CanLaunchViaEvent(const extensions::Extension* extension) { |
| 241 const extensions::FeatureProvider* feature_provider = | 241 const extensions::FeatureProvider* feature_provider = |
| 242 extensions::FeatureProvider::GetAPIFeatures(); | 242 extensions::FeatureProvider::GetAPIFeatures(); |
| 243 extensions::Feature* feature = feature_provider->GetFeature("app.runtime"); | 243 extensions::Feature* feature = feature_provider->GetFeature("app.runtime"); |
| 244 return feature->IsAvailableToExtension(extension).is_available(); | 244 return feature->IsAvailableToExtension(extension).is_available(); |
| 245 } | 245 } |
| OLD | NEW |