blob: 97172aca8b3fb908d96c7064ba03600134b167e1 [file] [log] [blame]
Alexey Baskakovd05bb012019-03-27 07:06:171// 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 Baskakov0b9a2ee2019-07-22 01:21:245#ifndef CHROME_BROWSER_WEB_APPLICATIONS_COMPONENTS_EXTERNAL_INSTALL_OPTIONS_H_
6#define CHROME_BROWSER_WEB_APPLICATIONS_COMPONENTS_EXTERNAL_INSTALL_OPTIONS_H_
Alexey Baskakovd05bb012019-03-27 07:06:177
8#include <iosfwd>
Giovanni Ortuño Urquidi88971892020-04-17 06:51:299#include <string>
10#include <vector>
Alexey Baskakovd05bb012019-03-27 07:06:1711
Alexey Baskakovc3fa6382019-08-01 01:47:0812#include "chrome/browser/web_applications/components/install_manager.h"
Eric Willigersd32986ad2019-11-04 00:40:0413#include "chrome/browser/web_applications/components/web_app_constants.h"
Glen Robertson271d1332020-01-28 00:16:0214#include "chrome/browser/web_applications/components/web_app_id.h"
Dominic Schulz38238af2020-07-22 02:06:4715#include "chrome/common/web_application_info.h"
Alexey Baskakovd05bb012019-03-27 07:06:1716#include "url/gurl.h"
17
18namespace web_app {
19
Dominic Schulz38238af2020-07-22 02:06:4720using WebApplicationInfoFactory =
21 base::RepeatingCallback<std::unique_ptr<WebApplicationInfo>()>;
22
Alexey Baskakov031895272019-07-18 08:19:3323enum class ExternalInstallSource;
Alexey Baskakovd05bb012019-03-27 07:06:1724
Alexey Baskakov0b9a2ee2019-07-22 01:21:2425struct ExternalInstallOptions {
Alan Cutter0cc83732020-09-02 02:26:3626 ExternalInstallOptions(const GURL& install_url,
Eric Willigersd32986ad2019-11-04 00:40:0427 DisplayMode user_display_mode,
Alexey Baskakov0b9a2ee2019-07-22 01:21:2428 ExternalInstallSource install_source);
29 ~ExternalInstallOptions();
30 ExternalInstallOptions(const ExternalInstallOptions& other);
31 ExternalInstallOptions(ExternalInstallOptions&& other);
32 ExternalInstallOptions& operator=(const ExternalInstallOptions& other);
Alexey Baskakovd05bb012019-03-27 07:06:1733
Alexey Baskakov0b9a2ee2019-07-22 01:21:2434 bool operator==(const ExternalInstallOptions& other) const;
Alexey Baskakovd05bb012019-03-27 07:06:1735
Alan Cutter0cc83732020-09-02 02:26:3636 GURL install_url;
Eric Willigersd32986ad2019-11-04 00:40:0437 DisplayMode user_display_mode;
Alexey Baskakov031895272019-07-18 08:19:3338 ExternalInstallSource install_source;
Alexey Baskakovd05bb012019-03-27 07:06:1739
Giovanni Ortuño Urquidie22f2e12019-04-01 02:43:5140 // If true, a shortcut is added to the Applications folder on macOS, and Start
Giovanni Ortuño Urquidi88971892020-04-17 06:51:2941 // Menu on Linux and Windows and launcher on Chrome OS. If false, we skip
Giovanni Ortuño Urquidie22f2e12019-04-01 02:43:5142 // 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 Baskakovd05bb012019-03-27 07:06:1756
Giovanni Ortuño Urquidi88971892020-04-17 06:51:2957 // 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 Frias5ddded62020-05-27 23:38:1865 // 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 ElAttar14d72a252020-04-21 10:59:1971 // 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 Baskakovd05bb012019-03-27 07:06:1775 // 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 Lama04e05922019-06-27 06:06:1189 bool force_reinstall = false;
Giovanni Ortuño Urquidic7e719b2019-04-03 01:33:3090
Giovanni Ortuño Urquidi68bd2a52019-04-18 12:15:2491 // 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 Urquidib6f4c5e02019-04-16 04:57:5694
Giovanni Ortuño Urquidic7e719b2019-04-03 01:33:3095 // 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 Urquidib6f4c5e02019-04-16 04:57:56101
102 // Whether we should try to reinstall the app if there is a placeholder for
103 // it.
104 bool reinstall_placeholder = false;
Christopher Lam8cd21342019-08-20 03:57:34105
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 Urquidib73eb2c502020-03-26 23:05:11109
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 Schulz38238af2020-07-22 02:06:47113
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 Baskakovd05bb012019-03-27 07:06:17119};
120
121std::ostream& operator<<(std::ostream& out,
Alexey Baskakov0b9a2ee2019-07-22 01:21:24122 const ExternalInstallOptions& install_options);
Alexey Baskakovd05bb012019-03-27 07:06:17123
Alexey Baskakovc3fa6382019-08-01 01:47:08124InstallManager::InstallParams ConvertExternalInstallOptionsToParams(
125 const ExternalInstallOptions& install_options);
126
Alexey Baskakovd05bb012019-03-27 07:06:17127} // namespace web_app
128
Alexey Baskakov0b9a2ee2019-07-22 01:21:24129#endif // CHROME_BROWSER_WEB_APPLICATIONS_COMPONENTS_EXTERNAL_INSTALL_OPTIONS_H_