[email protected] | 24c81d69 | 2013-08-07 14:09:48 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
[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 | |
cylee | 988a9bb5 | 2014-11-04 16:39:16 | [diff] [blame] | 12 | #include "extensions/common/constants.h" |
| 13 | |
[email protected] | 43197ea2 | 2013-09-10 15:31:56 | [diff] [blame] | 14 | class GURL; |
[email protected] | 12e54045 | 2012-05-26 07:09:36 | [diff] [blame] | 15 | class Profile; |
| 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 | |
[email protected] | 24c81d69 | 2013-08-07 14:09:48 | [diff] [blame] | 22 | namespace extensions { |
| 23 | class Extension; |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 24 | namespace api { |
| 25 | namespace app_runtime { |
| 26 | struct ActionData; |
| 27 | } |
| 28 | } |
[email protected] | 4e04f1e | 2012-06-20 03:20:31 | [diff] [blame] | 29 | } |
| 30 | |
[email protected] | 24c81d69 | 2013-08-07 14:09:48 | [diff] [blame] | 31 | namespace apps { |
[email protected] | 12e54045 | 2012-05-26 07:09:36 | [diff] [blame] | 32 | |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 33 | // Launches the platform app |app|. Creates appropriate launch data for the |
| 34 | // |command_line| fields present. |app| and |profile| must not be NULL. An empty |
| 35 | // |command_line| means there is no launch data. If non-empty, |
[email protected] | a5a0be0 | 2012-07-18 05:51:54 | [diff] [blame] | 36 | // |current_directory| is used to expand any relative paths on the command line. |
cylee | 988a9bb5 | 2014-11-04 16:39:16 | [diff] [blame] | 37 | // |source| is one of the enumerated values which trace how the app is launched. |
[email protected] | 2a69b94 | 2013-05-31 09:37:53 | [diff] [blame] | 38 | void LaunchPlatformAppWithCommandLine(Profile* profile, |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 39 | const extensions::Extension* app, |
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 40 | const base::CommandLine& command_line, |
cylee | 988a9bb5 | 2014-11-04 16:39:16 | [diff] [blame] | 41 | const base::FilePath& current_directory, |
| 42 | extensions::AppLaunchSource source); |
[email protected] | 12e54045 | 2012-05-26 07:09:36 | [diff] [blame] | 43 | |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 44 | // Launches the platform app |app| by issuing an onLaunched event with the |
| 45 | // contents of |file_path| available through the launch data. |
[email protected] | a228c84 | 2012-09-04 10:07:05 | [diff] [blame] | 46 | void LaunchPlatformAppWithPath(Profile* profile, |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 47 | const extensions::Extension* app, |
[email protected] | a3ef483 | 2013-02-02 05:12:33 | [diff] [blame] | 48 | const base::FilePath& file_path); |
[email protected] | a228c84 | 2012-09-04 10:07:05 | [diff] [blame] | 49 | |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 50 | // Launches the platform app |app| with the specific |action_data|. |file_path| |
| 51 | // is an optional argument and if present contains the file that the app should |
| 52 | // open w.r.t. the given action. |
| 53 | void LaunchPlatformAppWithAction( |
| 54 | Profile* profile, |
| 55 | const extensions::Extension* app, |
| 56 | std::unique_ptr<extensions::api::app_runtime::ActionData> action_data, |
| 57 | const base::FilePath& file_path); |
| 58 | |
| 59 | // Launches the platform app |app|. |source| tells us how the app is launched. |
[email protected] | 24c81d69 | 2013-08-07 14:09:48 | [diff] [blame] | 60 | void LaunchPlatformApp(Profile* profile, |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 61 | const extensions::Extension* app, |
cylee | 988a9bb5 | 2014-11-04 16:39:16 | [diff] [blame] | 62 | extensions::AppLaunchSource source); |
[email protected] | 2a69b94 | 2013-05-31 09:37:53 | [diff] [blame] | 63 | |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 64 | // Launches the platform app |app| with |handler_id| and the contents of |
[email protected] | 3113a23 | 2014-06-04 09:40:29 | [diff] [blame] | 65 | // |file_paths| available through the launch data. |handler_id| corresponds to |
[email protected] | 43197ea2 | 2013-09-10 15:31:56 | [diff] [blame] | 66 | // the id of the file_handlers item in the manifest that resulted in a match |
| 67 | // that triggered this launch. |
[email protected] | 3113a23 | 2014-06-04 09:40:29 | [diff] [blame] | 68 | void LaunchPlatformAppWithFileHandler( |
| 69 | Profile* profile, |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 70 | const extensions::Extension* app, |
[email protected] | 3113a23 | 2014-06-04 09:40:29 | [diff] [blame] | 71 | const std::string& handler_id, |
| 72 | const std::vector<base::FilePath>& file_paths); |
[email protected] | af8dc08e | 2012-11-22 01:58:42 | [diff] [blame] | 73 | |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 74 | // Launches the platform app |app| with |handler_id|, |url| and |referrer_url| |
| 75 | // available through the launch data. |handler_id| corresponds to the id of the |
| 76 | // file_handlers item in the manifest that resulted in a match that triggered |
| 77 | // this launch. |
[email protected] | 43197ea2 | 2013-09-10 15:31:56 | [diff] [blame] | 78 | void LaunchPlatformAppWithUrl(Profile* profile, |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 79 | const extensions::Extension* app, |
[email protected] | 43197ea2 | 2013-09-10 15:31:56 | [diff] [blame] | 80 | const std::string& handler_id, |
| 81 | const GURL& url, |
| 82 | const GURL& referrer_url); |
| 83 | |
jdufault | 9d3e955f | 2016-08-16 22:19:11 | [diff] [blame] | 84 | void RestartPlatformApp(Profile* profile, const extensions::Extension* app); |
[email protected] | fc2a40f | 2013-03-13 13:14:57 | [diff] [blame] | 85 | |
[email protected] | 24c81d69 | 2013-08-07 14:09:48 | [diff] [blame] | 86 | } // namespace apps |
[email protected] | 12e54045 | 2012-05-26 07:09:36 | [diff] [blame] | 87 | |
[email protected] | 24c81d69 | 2013-08-07 14:09:48 | [diff] [blame] | 88 | #endif // APPS_LAUNCHER_H_ |