| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/apps/ephemeral_app_launcher.h" | 5 #include "chrome/browser/apps/ephemeral_app_launcher.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/extensions/extension_install_checker.h" | 9 #include "chrome/browser/extensions/extension_install_checker.h" |
| 10 #include "chrome/browser/extensions/extension_install_prompt.h" | 10 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 11 #include "chrome/browser/extensions/extension_util.h" | 11 #include "chrome/browser/extensions/extension_util.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/browser_navigator.h" | 13 #include "chrome/browser/ui/browser_navigator.h" |
| 14 #include "chrome/browser/ui/extensions/app_launch_params.h" |
| 14 #include "chrome/browser/ui/extensions/application_launch.h" | 15 #include "chrome/browser/ui/extensions/application_launch.h" |
| 15 #include "chrome/browser/ui/extensions/extension_enable_flow.h" | 16 #include "chrome/browser/ui/extensions/extension_enable_flow.h" |
| 16 #include "chrome/browser/ui/native_window_tracker.h" | 17 #include "chrome/browser/ui/native_window_tracker.h" |
| 17 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 18 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
| 18 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 20 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
| 20 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 21 #include "extensions/browser/extension_prefs.h" | 22 #include "extensions/browser/extension_prefs.h" |
| 22 #include "extensions/browser/extension_registry.h" | 23 #include "extensions/browser/extension_registry.h" |
| 23 #include "extensions/browser/extension_system.h" | 24 #include "extensions/browser/extension_system.h" |
| 24 #include "extensions/browser/management_policy.h" | 25 #include "extensions/browser/management_policy.h" |
| 26 #include "extensions/common/constants.h" |
| 25 #include "extensions/common/permissions/permissions_data.h" | 27 #include "extensions/common/permissions/permissions_data.h" |
| 26 | 28 |
| 27 using content::WebContents; | 29 using content::WebContents; |
| 28 using extensions::Extension; | 30 using extensions::Extension; |
| 29 using extensions::ExtensionInstallChecker; | 31 using extensions::ExtensionInstallChecker; |
| 30 using extensions::ExtensionPrefs; | 32 using extensions::ExtensionPrefs; |
| 31 using extensions::ExtensionRegistry; | 33 using extensions::ExtensionRegistry; |
| 32 using extensions::ExtensionSystem; | 34 using extensions::ExtensionSystem; |
| 33 using extensions::ManagementPolicy; | 35 using extensions::ManagementPolicy; |
| 34 using extensions::WebstoreInstaller; | 36 using extensions::WebstoreInstaller; |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 } | 274 } |
| 273 | 275 |
| 274 InvokeCallback(result, error); | 276 InvokeCallback(result, error); |
| 275 } | 277 } |
| 276 | 278 |
| 277 void EphemeralAppLauncher::LaunchApp(const Extension* extension) const { | 279 void EphemeralAppLauncher::LaunchApp(const Extension* extension) const { |
| 278 DCHECK(extension && extension->is_app() && | 280 DCHECK(extension && extension->is_app() && |
| 279 ExtensionRegistry::Get(profile()) | 281 ExtensionRegistry::Get(profile()) |
| 280 ->GetExtensionById(extension->id(), ExtensionRegistry::ENABLED)); | 282 ->GetExtensionById(extension->id(), ExtensionRegistry::ENABLED)); |
| 281 | 283 |
| 282 AppLaunchParams params(profile(), extension, NEW_FOREGROUND_TAB); | 284 AppLaunchParams params(profile(), extension, NEW_FOREGROUND_TAB, |
| 285 extensions::SOURCE_EPHEMERAL_APP); |
| 283 params.desktop_type = | 286 params.desktop_type = |
| 284 chrome::GetHostDesktopTypeForNativeWindow(parent_window_); | 287 chrome::GetHostDesktopTypeForNativeWindow(parent_window_); |
| 285 OpenApplication(params); | 288 OpenApplication(params); |
| 286 } | 289 } |
| 287 | 290 |
| 288 bool EphemeralAppLauncher::LaunchHostedApp(const Extension* extension) const { | 291 bool EphemeralAppLauncher::LaunchHostedApp(const Extension* extension) const { |
| 289 GURL launch_url = extensions::AppLaunchInfo::GetLaunchWebURL(extension); | 292 GURL launch_url = extensions::AppLaunchInfo::GetLaunchWebURL(extension); |
| 290 if (!launch_url.is_valid()) | 293 if (!launch_url.is_valid()) |
| 291 return false; | 294 return false; |
| 292 | 295 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 | 468 |
| 466 // CompleteInstall will call Release. | 469 // CompleteInstall will call Release. |
| 467 WebstoreStandaloneInstaller::CompleteInstall(webstore_install::SUCCESS, | 470 WebstoreStandaloneInstaller::CompleteInstall(webstore_install::SUCCESS, |
| 468 std::string()); | 471 std::string()); |
| 469 } | 472 } |
| 470 | 473 |
| 471 void EphemeralAppLauncher::ExtensionEnableFlowAborted(bool user_initiated) { | 474 void EphemeralAppLauncher::ExtensionEnableFlowAborted(bool user_initiated) { |
| 472 // CompleteInstall will call Release. | 475 // CompleteInstall will call Release. |
| 473 CompleteInstall(webstore_install::USER_CANCELLED, kUserCancelledError); | 476 CompleteInstall(webstore_install::USER_CANCELLED, kUserCancelledError); |
| 474 } | 477 } |
| OLD | NEW |