Avi Drissman | da6cecbc | 2022-09-07 18:10:30 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors |
[email protected] | 12e54045 | 2012-05-26 07:09:36 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 24c81d69 | 2013-08-07 14:09:48 | [diff] [blame] | 5 | #ifndef APPS_LAUNCHER_H_ |
| 6 | #define APPS_LAUNCHER_H_ |
[email protected] | 12e54045 | 2012-05-26 07:09:36 | [diff] [blame] | 7 | |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 8 | #include <memory> |
[email protected] | af8dc08e | 2012-11-22 01:58:42 | [diff] [blame] | 9 | #include <string> |
[email protected] | 3113a23 | 2014-06-04 09:40:29 | [diff] [blame] | 10 | #include <vector> |
[email protected] | af8dc08e | 2012-11-22 01:58:42 | [diff] [blame] | 11 | |
rkc | 79bf63c | 2016-08-25 21:07:23 | [diff] [blame] | 12 | #include "extensions/common/api/app_runtime.h" |
cylee | 988a9bb5 | 2014-11-04 16:39:16 | [diff] [blame] | 13 | #include "extensions/common/constants.h" |
| 14 | |
[email protected] | 43197ea2 | 2013-09-10 15:31:56 | [diff] [blame] | 15 | class GURL; |
[email protected] | 12e54045 | 2012-05-26 07:09:36 | [diff] [blame] | 16 | |
[email protected] | a3ef483 | 2013-02-02 05:12:33 | [diff] [blame] | 17 | namespace base { |
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 18 | class CommandLine; |
[email protected] | a3ef483 | 2013-02-02 05:12:33 | [diff] [blame] | 19 | class FilePath; |
| 20 | } |
| 21 | |
michaelpg | 4d80e56 | 2017-04-04 01:48:14 | [diff] [blame] | 22 | namespace content { |
| 23 | class BrowserContext; |
| 24 | } |
| 25 | |
[email protected] | 24c81d69 | 2013-08-07 14:09:48 | [diff] [blame] | 26 | namespace extensions { |
| 27 | class Extension; |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 28 | namespace api { |
| 29 | namespace app_runtime { |
| 30 | struct ActionData; |
| 31 | } |
| 32 | } |
[email protected] | 4e04f1e | 2012-06-20 03:20:31 | [diff] [blame] | 33 | } |
| 34 | |
[email protected] | 24c81d69 | 2013-08-07 14:09:48 | [diff] [blame] | 35 | namespace apps { |
[email protected] | 12e54045 | 2012-05-26 07:09:36 | [diff] [blame] | 36 | |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 37 | // Launches the platform app |app|. Creates appropriate launch data for the |
michaelpg | 4d80e56 | 2017-04-04 01:48:14 | [diff] [blame] | 38 | // |command_line| fields present. |app| and |context| must not be NULL. An empty |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 39 | // |command_line| means there is no launch data. If non-empty, |
[email protected] | a5a0be0 | 2012-07-18 05:51:54 | [diff] [blame] | 40 | // |current_directory| is used to expand any relative paths on the command line. |
cylee | 988a9bb5 | 2014-11-04 16:39:16 | [diff] [blame] | 41 | // |source| is one of the enumerated values which trace how the app is launched. |
Eric Willigers | 24c3228 | 2019-06-11 05:59:14 | [diff] [blame] | 42 | void LaunchPlatformAppWithCommandLine(content::BrowserContext* context, |
| 43 | const extensions::Extension* app, |
| 44 | const base::CommandLine& command_line, |
| 45 | const base::FilePath& current_directory, |
| 46 | extensions::AppLaunchSource source); |
[email protected] | 12e54045 | 2012-05-26 07:09:36 | [diff] [blame] | 47 | |
andra.paraschiv | 4e4fb8bb | 2016-12-15 11:13:54 | [diff] [blame] | 48 | // As above but includes |launch_id|, an id that can be passed to |
| 49 | // an app when launched in order to support multiple shelf items per app. |
| 50 | void LaunchPlatformAppWithCommandLineAndLaunchId( |
michaelpg | 4d80e56 | 2017-04-04 01:48:14 | [diff] [blame] | 51 | content::BrowserContext* context, |
andra.paraschiv | 4e4fb8bb | 2016-12-15 11:13:54 | [diff] [blame] | 52 | const extensions::Extension* app, |
| 53 | const std::string& launch_id, |
| 54 | const base::CommandLine& command_line, |
| 55 | const base::FilePath& current_directory, |
Eric Willigers | 24c3228 | 2019-06-11 05:59:14 | [diff] [blame] | 56 | extensions::AppLaunchSource source); |
andra.paraschiv | 4e4fb8bb | 2016-12-15 11:13:54 | [diff] [blame] | 57 | |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 58 | // Launches the platform app |app| by issuing an onLaunched event with the |
| 59 | // contents of |file_path| available through the launch data. |
michaelpg | 4d80e56 | 2017-04-04 01:48:14 | [diff] [blame] | 60 | void LaunchPlatformAppWithPath(content::BrowserContext* context, |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 61 | const extensions::Extension* app, |
[email protected] | a3ef483 | 2013-02-02 05:12:33 | [diff] [blame] | 62 | const base::FilePath& file_path); |
[email protected] | a228c84 | 2012-09-04 10:07:05 | [diff] [blame] | 63 | |
nancylingwang | d282a5a | 2020-09-10 07:09:13 | [diff] [blame] | 64 | // Launches the platform app |app| by issuing an onLaunched event with the |
| 65 | // contents of |file_paths| available through the launch data. |
| 66 | void LaunchPlatformAppWithFilePaths( |
| 67 | content::BrowserContext* context, |
| 68 | const extensions::Extension* app, |
| 69 | const std::vector<base::FilePath>& file_paths); |
| 70 | |
Timothy Loh | d570e8a | 2022-03-07 02:23:00 | [diff] [blame] | 71 | // Launches the platform app |app| with the specific |action_data|. |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 72 | void LaunchPlatformAppWithAction( |
michaelpg | 4d80e56 | 2017-04-04 01:48:14 | [diff] [blame] | 73 | content::BrowserContext* context, |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 74 | const extensions::Extension* app, |
Claudio DeSouza | 5b653ce | 2022-09-07 04:48:26 | [diff] [blame] | 75 | extensions::api::app_runtime::ActionData action_data); |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 76 | |
| 77 | // Launches the platform app |app|. |source| tells us how the app is launched. |
michaelpg | 4d80e56 | 2017-04-04 01:48:14 | [diff] [blame] | 78 | void LaunchPlatformApp(content::BrowserContext* context, |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 79 | const extensions::Extension* app, |
cylee | 988a9bb5 | 2014-11-04 16:39:16 | [diff] [blame] | 80 | extensions::AppLaunchSource source); |
[email protected] | 2a69b94 | 2013-05-31 09:37:53 | [diff] [blame] | 81 | |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 82 | // Launches the platform app |app| with |handler_id| and the contents of |
[email protected] | 3113a23 | 2014-06-04 09:40:29 | [diff] [blame] | 83 | // |file_paths| available through the launch data. |handler_id| corresponds to |
[email protected] | 43197ea2 | 2013-09-10 15:31:56 | [diff] [blame] | 84 | // the id of the file_handlers item in the manifest that resulted in a match |
| 85 | // that triggered this launch. |
[email protected] | 3113a23 | 2014-06-04 09:40:29 | [diff] [blame] | 86 | void LaunchPlatformAppWithFileHandler( |
michaelpg | 4d80e56 | 2017-04-04 01:48:14 | [diff] [blame] | 87 | content::BrowserContext* context, |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 88 | const extensions::Extension* app, |
[email protected] | 3113a23 | 2014-06-04 09:40:29 | [diff] [blame] | 89 | const std::string& handler_id, |
| 90 | const std::vector<base::FilePath>& file_paths); |
[email protected] | af8dc08e | 2012-11-22 01:58:42 | [diff] [blame] | 91 | |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 92 | // Launches the platform app |app| with |handler_id|, |url| and |referrer_url| |
| 93 | // available through the launch data. |handler_id| corresponds to the id of the |
| 94 | // file_handlers item in the manifest that resulted in a match that triggered |
| 95 | // this launch. |
michaelpg | 4d80e56 | 2017-04-04 01:48:14 | [diff] [blame] | 96 | void LaunchPlatformAppWithUrl(content::BrowserContext* context, |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 97 | const extensions::Extension* app, |
[email protected] | 43197ea2 | 2013-09-10 15:31:56 | [diff] [blame] | 98 | const std::string& handler_id, |
| 99 | const GURL& url, |
| 100 | const GURL& referrer_url); |
| 101 | |
michaelpg | 4d80e56 | 2017-04-04 01:48:14 | [diff] [blame] | 102 | void RestartPlatformApp(content::BrowserContext* context, |
| 103 | const extensions::Extension* app); |
[email protected] | fc2a40f | 2013-03-13 13:14:57 | [diff] [blame] | 104 | |
[email protected] | 24c81d69 | 2013-08-07 14:09:48 | [diff] [blame] | 105 | } // namespace apps |
[email protected] | 12e54045 | 2012-05-26 07:09:36 | [diff] [blame] | 106 | |
[email protected] | 24c81d69 | 2013-08-07 14:09:48 | [diff] [blame] | 107 | #endif // APPS_LAUNCHER_H_ |