| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CHROME_BROWSER_UI_EXTENSIONS_APPLICATION_LAUNCH_H_ | 5 #ifndef CHROME_BROWSER_UI_EXTENSIONS_APPLICATION_LAUNCH_WEB_APP_H_ |
| 6 #define CHROME_BROWSER_UI_EXTENSIONS_APPLICATION_LAUNCH_H_ | 6 #define CHROME_BROWSER_UI_EXTENSIONS_APPLICATION_LAUNCH_WEB_APP_H_ |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "chrome/browser/ui/extensions/app_launch_params.h" |
| 9 #include "base/files/file_path.h" | |
| 10 #include "chrome/browser/ui/host_desktop.h" | |
| 11 #include "chrome/common/extensions/extension_constants.h" | |
| 12 #include "ui/base/window_open_disposition.h" | |
| 13 #include "ui/gfx/rect.h" | |
| 14 #include "url/gurl.h" | 9 #include "url/gurl.h" |
| 15 | 10 |
| 16 class Browser; | |
| 17 class Profile; | |
| 18 | |
| 19 namespace base { | |
| 20 class CommandLine; | |
| 21 } | |
| 22 | |
| 23 namespace content { | 11 namespace content { |
| 24 class WebContents; | 12 class WebContents; |
| 25 } | 13 } |
| 26 | 14 |
| 27 namespace extensions { | 15 // Helper method to OpenApplication() which opens a web app window with |url| |
| 28 class Extension; | 16 // in the way specified by |params|. |
| 29 } | 17 content::WebContents* OpenWebAppWindow(const AppLaunchParams& params, |
| 18 const GURL& url); |
| 30 | 19 |
| 31 struct AppLaunchParams { | 20 // Helper method to OpenApplication() which opens a web app tab with |url| in |
| 32 AppLaunchParams(Profile* profile, | 21 // the way specified by |params|. |
| 33 const extensions::Extension* extension, | 22 content::WebContents* OpenWebAppTab(const AppLaunchParams& params, |
| 34 extensions::LaunchContainer container, | 23 const GURL& url); |
| 35 WindowOpenDisposition disposition); | |
| 36 | 24 |
| 37 // Helper to create AppLaunchParams using extensions::GetLaunchContainer with | 25 #endif // CHROME_BROWSER_UI_EXTENSIONS_APPLICATION_LAUNCH_WEB_APP_H_ |
| 38 // LAUNCH_TYPE_REGULAR to check for a user-configured container. | |
| 39 AppLaunchParams(Profile* profile, | |
| 40 const extensions::Extension* extension, | |
| 41 WindowOpenDisposition disposition); | |
| 42 | |
| 43 // Helper to create AppLaunchParams using event flags that allows user to | |
| 44 // override the user-configured container using modifier keys, falling back to | |
| 45 // extensions::GetLaunchContainer() with no modifiers. |desktop_type| | |
| 46 // indicates the desktop upon which to launch (Ash or Native). | |
| 47 AppLaunchParams(Profile* profile, | |
| 48 const extensions::Extension* extension, | |
| 49 int event_flags, | |
| 50 chrome::HostDesktopType desktop_type); | |
| 51 | |
| 52 ~AppLaunchParams(); | |
| 53 | |
| 54 // The profile to load the application from. | |
| 55 Profile* profile; | |
| 56 | |
| 57 // The extension to load. | |
| 58 std::string extension_id; | |
| 59 | |
| 60 // The container type to launch the application in. | |
| 61 extensions::LaunchContainer container; | |
| 62 | |
| 63 // If container is TAB, this field controls how the tab is opened. | |
| 64 WindowOpenDisposition disposition; | |
| 65 | |
| 66 // The desktop type to launch on. Uses GetActiveDesktop() if unspecified. | |
| 67 chrome::HostDesktopType desktop_type; | |
| 68 | |
| 69 // If non-empty, use override_url in place of the application's launch url. | |
| 70 GURL override_url; | |
| 71 | |
| 72 // If non-empty, use override_boudns in place of the application's default | |
| 73 // position and dimensions. | |
| 74 gfx::Rect override_bounds; | |
| 75 | |
| 76 // If non-empty, information from the command line may be passed on to the | |
| 77 // application. | |
| 78 base::CommandLine command_line; | |
| 79 | |
| 80 // If non-empty, the current directory from which any relative paths on the | |
| 81 // command line should be expanded from. | |
| 82 base::FilePath current_directory; | |
| 83 }; | |
| 84 | |
| 85 // Opens the application, possibly prompting the user to re-enable it. | |
| 86 void OpenApplicationWithReenablePrompt(const AppLaunchParams& params); | |
| 87 | |
| 88 // Open the application in a way specified by |params|. | |
| 89 content::WebContents* OpenApplication(const AppLaunchParams& params); | |
| 90 | |
| 91 // Open |url| in an app shortcut window. | |
| 92 // There are two kinds of app shortcuts: Shortcuts to a URL, | |
| 93 // and shortcuts that open an installed application. This function | |
| 94 // is used to open the former. To open the latter, use | |
| 95 // application_launch::OpenApplication(). | |
| 96 content::WebContents* OpenAppShortcutWindow(Profile* profile, | |
| 97 const GURL& url); | |
| 98 | |
| 99 // Whether the extension can be launched by sending a | |
| 100 // chrome.app.runtime.onLaunched event. | |
| 101 bool CanLaunchViaEvent(const extensions::Extension* extension); | |
| 102 | |
| 103 // Get the launch URL for a given extension, with optional override/fallback. | |
| 104 // |override_url|, if non-empty, will be preferred over the extension's | |
| 105 // launch url. | |
| 106 GURL UrlForExtension(const extensions::Extension* extension, | |
| 107 const GURL& override_url); | |
| 108 | |
| 109 #endif // CHROME_BROWSER_UI_EXTENSIONS_APPLICATION_LAUNCH_H_ | |
| OLD | NEW |