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/scoped_tabbed_browser_displayer.h" | 17 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
17 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 19 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
19 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
20 #include "extensions/browser/extension_prefs.h" | 21 #include "extensions/browser/extension_prefs.h" |
21 #include "extensions/browser/extension_registry.h" | 22 #include "extensions/browser/extension_registry.h" |
22 #include "extensions/browser/extension_system.h" | 23 #include "extensions/browser/extension_system.h" |
23 #include "extensions/browser/management_policy.h" | 24 #include "extensions/browser/management_policy.h" |
| 25 #include "extensions/common/constants.h" |
24 #include "extensions/common/permissions/permissions_data.h" | 26 #include "extensions/common/permissions/permissions_data.h" |
25 | 27 |
26 using content::WebContents; | 28 using content::WebContents; |
27 using extensions::Extension; | 29 using extensions::Extension; |
28 using extensions::ExtensionInstallChecker; | 30 using extensions::ExtensionInstallChecker; |
29 using extensions::ExtensionPrefs; | 31 using extensions::ExtensionPrefs; |
30 using extensions::ExtensionRegistry; | 32 using extensions::ExtensionRegistry; |
31 using extensions::ExtensionSystem; | 33 using extensions::ExtensionSystem; |
32 using extensions::ManagementPolicy; | 34 using extensions::ManagementPolicy; |
33 using extensions::WebstoreInstaller; | 35 using extensions::WebstoreInstaller; |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 } | 271 } |
270 | 272 |
271 InvokeCallback(result, error); | 273 InvokeCallback(result, error); |
272 } | 274 } |
273 | 275 |
274 void EphemeralAppLauncher::LaunchApp(const Extension* extension) const { | 276 void EphemeralAppLauncher::LaunchApp(const Extension* extension) const { |
275 DCHECK(extension && extension->is_app() && | 277 DCHECK(extension && extension->is_app() && |
276 ExtensionRegistry::Get(profile()) | 278 ExtensionRegistry::Get(profile()) |
277 ->GetExtensionById(extension->id(), ExtensionRegistry::ENABLED)); | 279 ->GetExtensionById(extension->id(), ExtensionRegistry::ENABLED)); |
278 | 280 |
279 AppLaunchParams params(profile(), extension, NEW_FOREGROUND_TAB); | 281 AppLaunchParams params(profile(), extension, NEW_FOREGROUND_TAB, |
| 282 extensions::SOURCE_EPHEMERAL); |
280 params.desktop_type = | 283 params.desktop_type = |
281 chrome::GetHostDesktopTypeForNativeWindow(parent_window_); | 284 chrome::GetHostDesktopTypeForNativeWindow(parent_window_); |
282 OpenApplication(params); | 285 OpenApplication(params); |
283 } | 286 } |
284 | 287 |
285 bool EphemeralAppLauncher::LaunchHostedApp(const Extension* extension) const { | 288 bool EphemeralAppLauncher::LaunchHostedApp(const Extension* extension) const { |
286 GURL launch_url = extensions::AppLaunchInfo::GetLaunchWebURL(extension); | 289 GURL launch_url = extensions::AppLaunchInfo::GetLaunchWebURL(extension); |
287 if (!launch_url.is_valid()) | 290 if (!launch_url.is_valid()) |
288 return false; | 291 return false; |
289 | 292 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 | 458 |
456 // CompleteInstall will call Release. | 459 // CompleteInstall will call Release. |
457 WebstoreStandaloneInstaller::CompleteInstall(webstore_install::SUCCESS, | 460 WebstoreStandaloneInstaller::CompleteInstall(webstore_install::SUCCESS, |
458 std::string()); | 461 std::string()); |
459 } | 462 } |
460 | 463 |
461 void EphemeralAppLauncher::ExtensionEnableFlowAborted(bool user_initiated) { | 464 void EphemeralAppLauncher::ExtensionEnableFlowAborted(bool user_initiated) { |
462 // CompleteInstall will call Release. | 465 // CompleteInstall will call Release. |
463 CompleteInstall(webstore_install::USER_CANCELLED, kUserCancelledError); | 466 CompleteInstall(webstore_install::USER_CANCELLED, kUserCancelledError); |
464 } | 467 } |
OLD | NEW |