Alexey Baskakov | d05bb01 | 2019-03-27 07:06:17 | [diff] [blame] | 1 | // Copyright 2019 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Alexey Baskakov | 0b9a2ee | 2019-07-22 01:21:24 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_WEB_APPLICATIONS_COMPONENTS_EXTERNAL_INSTALL_OPTIONS_H_ |
| 6 | #define CHROME_BROWSER_WEB_APPLICATIONS_COMPONENTS_EXTERNAL_INSTALL_OPTIONS_H_ |
Alexey Baskakov | d05bb01 | 2019-03-27 07:06:17 | [diff] [blame] | 7 | |
| 8 | #include <iosfwd> |
Giovanni Ortuño Urquidi | 8897189 | 2020-04-17 06:51:29 | [diff] [blame] | 9 | #include <string> |
| 10 | #include <vector> |
Alexey Baskakov | d05bb01 | 2019-03-27 07:06:17 | [diff] [blame] | 11 | |
Alexey Baskakov | c3fa638 | 2019-08-01 01:47:08 | [diff] [blame] | 12 | #include "chrome/browser/web_applications/components/install_manager.h" |
Eric Willigers | d32986ad | 2019-11-04 00:40:04 | [diff] [blame] | 13 | #include "chrome/browser/web_applications/components/web_app_constants.h" |
Glen Robertson | 271d133 | 2020-01-28 00:16:02 | [diff] [blame] | 14 | #include "chrome/browser/web_applications/components/web_app_id.h" |
Dominic Schulz | 38238af | 2020-07-22 02:06:47 | [diff] [blame] | 15 | #include "chrome/common/web_application_info.h" |
Alexey Baskakov | d05bb01 | 2019-03-27 07:06:17 | [diff] [blame] | 16 | #include "url/gurl.h" |
| 17 | |
| 18 | namespace web_app { |
| 19 | |
Dominic Schulz | 38238af | 2020-07-22 02:06:47 | [diff] [blame] | 20 | using WebApplicationInfoFactory = |
| 21 | base::RepeatingCallback<std::unique_ptr<WebApplicationInfo>()>; |
| 22 | |
Alexey Baskakov | 03189527 | 2019-07-18 08:19:33 | [diff] [blame] | 23 | enum class ExternalInstallSource; |
Alexey Baskakov | d05bb01 | 2019-03-27 07:06:17 | [diff] [blame] | 24 | |
Alexey Baskakov | 0b9a2ee | 2019-07-22 01:21:24 | [diff] [blame] | 25 | struct ExternalInstallOptions { |
Alan Cutter | 0cc8373 | 2020-09-02 02:26:36 | [diff] [blame] | 26 | ExternalInstallOptions(const GURL& install_url, |
Eric Willigers | d32986ad | 2019-11-04 00:40:04 | [diff] [blame] | 27 | DisplayMode user_display_mode, |
Alexey Baskakov | 0b9a2ee | 2019-07-22 01:21:24 | [diff] [blame] | 28 | ExternalInstallSource install_source); |
| 29 | ~ExternalInstallOptions(); |
| 30 | ExternalInstallOptions(const ExternalInstallOptions& other); |
| 31 | ExternalInstallOptions(ExternalInstallOptions&& other); |
| 32 | ExternalInstallOptions& operator=(const ExternalInstallOptions& other); |
Alexey Baskakov | d05bb01 | 2019-03-27 07:06:17 | [diff] [blame] | 33 | |
Alexey Baskakov | 0b9a2ee | 2019-07-22 01:21:24 | [diff] [blame] | 34 | bool operator==(const ExternalInstallOptions& other) const; |
Alexey Baskakov | d05bb01 | 2019-03-27 07:06:17 | [diff] [blame] | 35 | |
Alan Cutter | 0cc8373 | 2020-09-02 02:26:36 | [diff] [blame] | 36 | GURL install_url; |
Eric Willigers | d32986ad | 2019-11-04 00:40:04 | [diff] [blame] | 37 | DisplayMode user_display_mode; |
Alexey Baskakov | 03189527 | 2019-07-18 08:19:33 | [diff] [blame] | 38 | ExternalInstallSource install_source; |
Alexey Baskakov | d05bb01 | 2019-03-27 07:06:17 | [diff] [blame] | 39 | |
Giovanni Ortuño Urquidi | e22f2e1 | 2019-04-01 02:43:51 | [diff] [blame] | 40 | // If true, a shortcut is added to the Applications folder on macOS, and Start |
Giovanni Ortuño Urquidi | 8897189 | 2020-04-17 06:51:29 | [diff] [blame] | 41 | // Menu on Linux and Windows and launcher on Chrome OS. If false, we skip |
Giovanni Ortuño Urquidi | e22f2e1 | 2019-04-01 02:43:51 | [diff] [blame] | 42 | // adding a shortcut to desktop as well, regardless of the value of |
| 43 | // |add_to_desktop|. |
| 44 | // TODO(ortuno): Make adding a shortcut to the applications menu independent |
| 45 | // from adding a shortcut to desktop. |
| 46 | bool add_to_applications_menu = true; |
| 47 | |
| 48 | // If true, a shortcut is added to the desktop on Linux and Windows. Has no |
| 49 | // effect on macOS and Chrome OS. |
| 50 | bool add_to_desktop = true; |
| 51 | |
| 52 | // If true, a shortcut is added to the "quick launch bar" of the OS: the Shelf |
| 53 | // for Chrome OS, the Dock for macOS, and the Quick Launch Bar or Taskbar on |
| 54 | // Windows. Currently this only works on Chrome OS. |
| 55 | bool add_to_quick_launch_bar = true; |
Alexey Baskakov | d05bb01 | 2019-03-27 07:06:17 | [diff] [blame] | 56 | |
Giovanni Ortuño Urquidi | 8897189 | 2020-04-17 06:51:29 | [diff] [blame] | 57 | // If true, the app can be searched for on Chrome OS. Has no effect on other |
| 58 | // platforms. |
| 59 | bool add_to_search = true; |
| 60 | |
| 61 | // If true, the app is shown in App Management on Chrome OS. Has no effect on |
| 62 | // other platforms. |
| 63 | bool add_to_management = true; |
| 64 | |
Carlos Frias | 5ddded6 | 2020-05-27 23:38:18 | [diff] [blame] | 65 | // Whether the app should be registered to run on OS login. |
| 66 | // Currently this only works on Windows by adding a shortcut to the |
| 67 | // Startup Folder. |
| 68 | // TODO(crbug.com/897302): Enable for other platforms. |
| 69 | bool run_on_os_login = false; |
| 70 | |
Aya ElAttar | 14d72a25 | 2020-04-21 10:59:19 | [diff] [blame] | 71 | // If true, the app icon is displayed on Chrome OS with a blocked logo on |
| 72 | // top, and the user cannot launch the app. Has no effect on other platforms. |
| 73 | bool is_disabled = false; |
| 74 | |
Alexey Baskakov | d05bb01 | 2019-03-27 07:06:17 | [diff] [blame] | 75 | // Whether the app should be reinstalled even if the user has previously |
| 76 | // uninstalled it. |
| 77 | bool override_previous_user_uninstall = false; |
| 78 | |
| 79 | // This must only be used by pre-installed default or system apps that are |
| 80 | // valid PWAs if loading the real service worker is too costly to verify |
| 81 | // programmatically. |
| 82 | bool bypass_service_worker_check = false; |
| 83 | |
| 84 | // This should be used for installing all default apps so that good metadata |
| 85 | // is ensured. |
| 86 | bool require_manifest = false; |
| 87 | |
| 88 | // Whether the app should be reinstalled even if it is already installed. |
Christopher Lam | a04e0592 | 2019-06-27 06:06:11 | [diff] [blame] | 89 | bool force_reinstall = false; |
Giovanni Ortuño Urquidi | c7e719b | 2019-04-03 01:33:30 | [diff] [blame] | 90 | |
Giovanni Ortuño Urquidi | 68bd2a5 | 2019-04-18 12:15:24 | [diff] [blame] | 91 | // Whether we should wait for all app windows being closed before reinstalling |
| 92 | // the placeholder. |
| 93 | bool wait_for_windows_closed = false; |
Giovanni Ortuño Urquidi | b6f4c5e0 | 2019-04-16 04:57:56 | [diff] [blame] | 94 | |
Giovanni Ortuño Urquidi | c7e719b | 2019-04-03 01:33:30 | [diff] [blame] | 95 | // Whether a placeholder app should be installed if we fail to retrieve the |
| 96 | // metadata for the app. A placeholder app uses: |
| 97 | // - The default Chrome App icon for the icon |
| 98 | // - |url| as the start_url |
| 99 | // - |url| as the app name |
| 100 | bool install_placeholder = false; |
Giovanni Ortuño Urquidi | b6f4c5e0 | 2019-04-16 04:57:56 | [diff] [blame] | 101 | |
| 102 | // Whether we should try to reinstall the app if there is a placeholder for |
| 103 | // it. |
| 104 | bool reinstall_placeholder = false; |
Christopher Lam | 8cd2134 | 2019-08-20 03:57:34 | [diff] [blame] | 105 | |
| 106 | // A list of app_ids that the Web App System should attempt to uninstall and |
| 107 | // replace with this app (e.g maintain shelf pins, app list positions). |
| 108 | std::vector<AppId> uninstall_and_replace; |
Giovanni Ortuño Urquidi | b73eb2c50 | 2020-03-26 23:05:11 | [diff] [blame] | 109 | |
| 110 | // Additional keywords that will be used by the OS when searching for the app. |
| 111 | // Only affects Chrome OS. |
| 112 | std::vector<std::string> additional_search_terms; |
Dominic Schulz | 38238af | 2020-07-22 02:06:47 | [diff] [blame] | 113 | |
| 114 | // A factory callback that returns a unique_ptr<WebApplicationInfo>. If this |
| 115 | // is present, the generated WebApplicationInfo is used to install the app |
| 116 | // instead of loading the url, retrieving the manifest, and installing from |
| 117 | // that. |
| 118 | WebApplicationInfoFactory app_info_factory; |
Alexey Baskakov | d05bb01 | 2019-03-27 07:06:17 | [diff] [blame] | 119 | }; |
| 120 | |
| 121 | std::ostream& operator<<(std::ostream& out, |
Alexey Baskakov | 0b9a2ee | 2019-07-22 01:21:24 | [diff] [blame] | 122 | const ExternalInstallOptions& install_options); |
Alexey Baskakov | d05bb01 | 2019-03-27 07:06:17 | [diff] [blame] | 123 | |
Alexey Baskakov | c3fa638 | 2019-08-01 01:47:08 | [diff] [blame] | 124 | InstallManager::InstallParams ConvertExternalInstallOptionsToParams( |
| 125 | const ExternalInstallOptions& install_options); |
| 126 | |
Alexey Baskakov | d05bb01 | 2019-03-27 07:06:17 | [diff] [blame] | 127 | } // namespace web_app |
| 128 | |
Alexey Baskakov | 0b9a2ee | 2019-07-22 01:21:24 | [diff] [blame] | 129 | #endif // CHROME_BROWSER_WEB_APPLICATIONS_COMPONENTS_EXTERNAL_INSTALL_OPTIONS_H_ |