Avi Drissman | 4a8573c | 2022-09-09 19:35:54 | [diff] [blame] | 1 | // Copyright 2018 The Chromium Authors |
Nigel Tao | 192c330 | 2018-07-19 15:17:28 | [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 | |
| 5 | #ifndef CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_PROVIDER_H_ |
| 6 | #define CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_PROVIDER_H_ |
| 7 | |
| 8 | #include <memory> |
| 9 | |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 10 | #include "base/memory/raw_ptr.h" |
Glen Robertson | 7f21d6d8 | 2023-07-04 01:54:43 | [diff] [blame] | 11 | #include "base/memory/scoped_refptr.h" |
Dominick Ng | 7b4ad0b8 | 2018-08-03 15:29:10 | [diff] [blame] | 12 | #include "base/memory/weak_ptr.h" |
Eric Willigers | 2cd3192 | 2019-06-26 00:53:34 | [diff] [blame] | 13 | #include "base/one_shot_event.h" |
Glen Robertson | 38c4f7db | 2023-07-25 00:30:12 | [diff] [blame] | 14 | #include "base/types/pass_key.h" |
| 15 | #include "build/build_config.h" |
Song Fangzhen | 59c5ae28 | 2021-07-13 07:36:27 | [diff] [blame] | 16 | #include "components/keyed_service/core/keyed_service.h" |
Nigel Tao | 192c330 | 2018-07-19 15:17:28 | [diff] [blame] | 17 | |
| 18 | class Profile; |
| 19 | |
Alexey Baskakov | fd3894e | 2018-10-16 06:09:58 | [diff] [blame] | 20 | namespace content { |
| 21 | class WebContents; |
| 22 | } |
| 23 | |
Nigel Tao | 192c330 | 2018-07-19 15:17:28 | [diff] [blame] | 24 | namespace web_app { |
| 25 | |
Glen Robertson | aaddfad | 2022-03-24 03:37:46 | [diff] [blame] | 26 | class AbstractWebAppDatabaseFactory; |
Zelin Liu | 5cc0e1e | 2023-06-30 20:26:49 | [diff] [blame] | 27 | class ExtensionsManager; |
Glen Robertson | 38c4f7db | 2023-07-25 00:30:12 | [diff] [blame] | 28 | class ExternallyManagedAppManager; |
Daniel Murphy | 6572be0 | 2024-01-17 17:35:03 | [diff] [blame] | 29 | class FakeWebAppProvider; |
Glen Robertson | 38c4f7db | 2023-07-25 00:30:12 | [diff] [blame] | 30 | class FileUtilsWrapper; |
Alan Cutter | 56f3cd3 | 2023-09-20 00:29:36 | [diff] [blame] | 31 | class GeneratedIconFixManager; |
Zelin Liu | 51615d1 | 2023-08-29 18:13:39 | [diff] [blame] | 32 | class IsolatedWebAppInstallationManager; |
Simon Hangl | c019732 | 2024-11-27 19:03:44 | [diff] [blame] | 33 | class IsolatedWebAppPolicyManager; |
Christian Flach | 42b091fd | 2023-10-11 12:16:15 | [diff] [blame] | 34 | class IsolatedWebAppUpdateManager; |
Alan Cutter | f2d2485f | 2019-09-05 07:11:13 | [diff] [blame] | 35 | class ManifestUpdateManager; |
Daniel Murphy | 9b630c5 | 2024-09-19 01:21:10 | [diff] [blame] | 36 | class NavigationCapturingLog; |
phillis | 550e371 | 2020-06-19 02:17:27 | [diff] [blame] | 37 | class OsIntegrationManager; |
Daniel Murphy | 22f66f1 | 2023-05-26 20:35:02 | [diff] [blame] | 38 | class PreinstalledWebAppManager; |
Daniel Murphy | 2e5932d | 2024-09-18 16:23:39 | [diff] [blame] | 39 | class VisitedManifestManager; |
Daniel Murphy | 22f66f1 | 2023-05-26 20:35:02 | [diff] [blame] | 40 | class WebAppAudioFocusIdMap; |
Phillis Tang | 52b1ec4b | 2022-04-13 01:14:31 | [diff] [blame] | 41 | class WebAppCommandManager; |
Phillis Tang | 549802e | 2022-09-30 19:40:31 | [diff] [blame] | 42 | class WebAppCommandScheduler; |
Daniel Murphy | 22f66f1 | 2023-05-26 20:35:02 | [diff] [blame] | 43 | class WebAppIconManager; |
| 44 | class WebAppInstallFinalizer; |
| 45 | class WebAppInstallManager; |
Lu Huang | 9cbbdd9 | 2023-04-18 19:14:56 | [diff] [blame] | 46 | class WebAppOriginAssociationManager; |
Daniel Murphy | 22f66f1 | 2023-05-26 20:35:02 | [diff] [blame] | 47 | class WebAppPolicyManager; |
Glen Robertson | 38c4f7db | 2023-07-25 00:30:12 | [diff] [blame] | 48 | class WebAppRegistrar; |
| 49 | class WebAppRegistrarMutable; |
Daniel Murphy | 22f66f1 | 2023-05-26 20:35:02 | [diff] [blame] | 50 | class WebAppSyncBridge; |
| 51 | class WebAppTranslationManager; |
| 52 | class WebAppUiManager; |
| 53 | class WebContentsManager; |
Dibyajyoti Pal | 2ff5a926 | 2024-12-07 01:08:35 | [diff] [blame] | 54 | class WebAppProfileDeletionManager; |
Alexey Baskakov | fd3894e | 2018-10-16 06:09:58 | [diff] [blame] | 55 | |
Glen Robertson | 38c4f7db | 2023-07-25 00:30:12 | [diff] [blame] | 56 | #if BUILDFLAG(IS_CHROMEOS) |
Glen Robertson | 38c4f7db | 2023-07-25 00:30:12 | [diff] [blame] | 57 | class WebAppRunOnOsLoginManager; |
Irina | 9887326 | 2025-04-28 19:19:24 | [diff] [blame] | 58 | class IwaBundleCacheManager; |
Glen Robertson | 38c4f7db | 2023-07-25 00:30:12 | [diff] [blame] | 59 | #endif |
| 60 | |
Alan Cutter | 30aacee5 | 2022-08-17 05:36:48 | [diff] [blame] | 61 | // WebAppProvider is the heart of Chrome web app code. |
| 62 | // |
Nigel Tao | 192c330 | 2018-07-19 15:17:28 | [diff] [blame] | 63 | // Connects Web App features, such as the installation of default and |
| 64 | // policy-managed web apps, with Profiles (as WebAppProvider is a |
| 65 | // Profile-linked KeyedService) and their associated PrefService. |
Christopher Lam | a45ea6d | 2019-07-08 07:22:05 | [diff] [blame] | 66 | // |
| 67 | // Lifecycle notes: |
Alan Cutter | 30aacee5 | 2022-08-17 05:36:48 | [diff] [blame] | 68 | // - WebAppProvider and its sub-managers are not ready for use until the |
| 69 | // on_registry_ready() event has fired. Its database must be loaded from |
| 70 | // disk before it can be interacted with. |
| 71 | // Example of waiting for on_registry_ready(): |
| 72 | // WebAppProvider* provider = WebAppProvider::GetForWebApps(profile); |
| 73 | // provider->on_registry_ready().Post( |
| 74 | // FROM_HERE, |
| 75 | // base::BindOnce([](WebAppProvider& provider) { |
| 76 | // ... |
Simon Hangl | be287e910 | 2025-03-17 10:13:58 | [diff] [blame] | 77 | // }, std::ref(*provider))); |
Alan Cutter | 30aacee5 | 2022-08-17 05:36:48 | [diff] [blame] | 78 | // - All subsystems are constructed independently of each other in the |
| 79 | // WebAppProvider constructor. |
| 80 | // - Subsystem construction should have no side effects and start no tasks. |
| 81 | // - Tests can replace any of the subsystems before Start() is called. |
| 82 | // - Similarly, in destruction, subsystems should not refer to each other. |
Song Fangzhen | 59c5ae28 | 2021-07-13 07:36:27 | [diff] [blame] | 83 | class WebAppProvider : public KeyedService { |
Nigel Tao | 192c330 | 2018-07-19 15:17:28 | [diff] [blame] | 84 | public: |
Alexey Baskakov | 50792c1 | 2022-05-26 04:34:13 | [diff] [blame] | 85 | // Deprecated: Use GetForWebApps instead. |
Eric Willigers | 607ca105 | 2021-09-01 05:23:32 | [diff] [blame] | 86 | static WebAppProvider* GetDeprecated(Profile* profile); |
Jiewei Qian | b6cfe54 | 2021-05-31 07:45:45 | [diff] [blame] | 87 | |
Daniel Murphy | 9280ab22 | 2025-01-16 01:23:05 | [diff] [blame] | 88 | // This returns a WebAppProvider for the given `profile`, or `nullptr` if |
| 89 | // installed web apps are not supported on the given `profile`. Use |
| 90 | // `web_app::AreWebAppsEnabled` to determine if web apps are supported on a |
| 91 | // profile. |
| 92 | // Note: On ChromeOS, to support the system web app implementation, this also |
| 93 | // considers the `profile`'s 'original' profile, if `AreWebAppsEnabled` |
| 94 | // returns `false` for `profile`. |
Daniel Murphy | 4203862 | 2024-12-18 20:00:32 | [diff] [blame] | 95 | // TODO(https://crbug.com/384063076): Stop returning the WebAppProvider for |
Daniel Murphy | 9280ab22 | 2025-01-16 01:23:05 | [diff] [blame] | 96 | // profiles where `AreWebAppsEnabled` returns `false` to support CrOS system |
| 97 | // web apps. |
Jiewei Qian | b6cfe54 | 2021-05-31 07:45:45 | [diff] [blame] | 98 | static WebAppProvider* GetForWebApps(Profile* profile); |
| 99 | |
Georg Neis | 251cf6f | 2025-02-19 05:23:19 | [diff] [blame] | 100 | // Returns the WebAppProvider for the current process. |
Raymes Khoury | 588aef4 | 2021-08-24 05:20:28 | [diff] [blame] | 101 | // |
Alexey Baskakov | 50792c1 | 2022-05-26 04:34:13 | [diff] [blame] | 102 | // Avoid using this function where possible and prefer GetForWebApps which |
Georg Neis | 251cf6f | 2025-02-19 05:23:19 | [diff] [blame] | 103 | // provides a guarantee they are being called from the correct process. |
Daniel Murphy | 4203862 | 2024-12-18 20:00:32 | [diff] [blame] | 104 | // TODO(https://crbug.com/384063076): Stop returning the WebAppProvider for |
Daniel Murphy | 9280ab22 | 2025-01-16 01:23:05 | [diff] [blame] | 105 | // profiles where `AreWebAppsEnabled` returns `false` to support CrOS system |
| 106 | // web apps. |
Raymes Khoury | 588aef4 | 2021-08-24 05:20:28 | [diff] [blame] | 107 | static WebAppProvider* GetForLocalAppsUnchecked(Profile* profile); |
Eric Willigers | f428378 | 2021-08-07 04:05:55 | [diff] [blame] | 108 | |
Georg Neis | 251cf6f | 2025-02-19 05:23:19 | [diff] [blame] | 109 | // Return the WebAppProvider for tests. Blocks if the web app registry is not |
| 110 | // yet ready. |
Daniel Murphy | 9280ab22 | 2025-01-16 01:23:05 | [diff] [blame] | 111 | // This returns `nullptr` if installed web apps are not supported on the |
| 112 | // given `profile`. Use `web_app::AreWebAppsEnabled` to determine if web apps |
| 113 | // are supported on a profile. |
| 114 | // Note: On ChromeOS, to support the system web app implementation, this also |
| 115 | // considers the `profile`'s 'original' profile, if `AreWebAppsEnabled` |
| 116 | // returns `false` for `profile`. |
Daniel Murphy | 4203862 | 2024-12-18 20:00:32 | [diff] [blame] | 117 | // TODO(https://crbug.com/384063076): Stop returning the WebAppProvider for |
Daniel Murphy | 9280ab22 | 2025-01-16 01:23:05 | [diff] [blame] | 118 | // profiles where `AreWebAppsEnabled` returns `false` to support CrOS system |
| 119 | // web apps. |
Raymes Khoury | 0be37da5 | 2021-08-19 07:15:47 | [diff] [blame] | 120 | static WebAppProvider* GetForTest(Profile* profile); |
| 121 | |
Daniel Murphy | 9280ab22 | 2025-01-16 01:23:05 | [diff] [blame] | 122 | // See `GetForWebApps` above for when this returns `nullptr`. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 123 | static WebAppProvider* GetForWebContents(content::WebContents* web_contents); |
Nigel Tao | 192c330 | 2018-07-19 15:17:28 | [diff] [blame] | 124 | |
Alan Cutter | f3d9aba7 | 2020-12-03 10:19:31 | [diff] [blame] | 125 | using OsIntegrationManagerFactory = |
| 126 | std::unique_ptr<OsIntegrationManager> (*)(Profile*); |
Alan Cutter | f3d9aba7 | 2020-12-03 10:19:31 | [diff] [blame] | 127 | |
Giovanni Ortuño Urquidi | 8ea2f1e | 2018-08-06 01:13:05 | [diff] [blame] | 128 | explicit WebAppProvider(Profile* profile); |
Haben Foto | e3d073b | 2020-10-06 01:22:58 | [diff] [blame] | 129 | WebAppProvider(const WebAppProvider&) = delete; |
| 130 | WebAppProvider& operator=(const WebAppProvider&) = delete; |
Alexey Baskakov | d039275 | 2019-01-10 08:38:28 | [diff] [blame] | 131 | ~WebAppProvider() override; |
| 132 | |
Christopher Lam | 4ce340fd | 2019-07-23 08:07:32 | [diff] [blame] | 133 | // Start the Web App system. This will run subsystem startup tasks. |
| 134 | void Start(); |
Nigel Tao | 192c330 | 2018-07-19 15:17:28 | [diff] [blame] | 135 | |
Phillis Tang | 549802e | 2022-09-30 19:40:31 | [diff] [blame] | 136 | // Read/write to web app system should use `scheduler()` to guarantee safe |
| 137 | // access. This is safe to access even if the `WebAppProvider` is not ready. |
| 138 | WebAppCommandScheduler& scheduler(); |
Daniel Murphy | 8e0d889 | 2022-11-08 13:30:04 | [diff] [blame] | 139 | // This is safe to access even if the `WebAppProvider` is not ready. |
| 140 | WebAppCommandManager& command_manager(); |
Phillis Tang | 549802e | 2022-09-30 19:40:31 | [diff] [blame] | 141 | |
| 142 | // Web App sub components. These should only be accessed after |
| 143 | // `on_registry_ready()` is signaled. |
| 144 | |
Camden King | 7f851df | 2022-12-07 19:29:27 | [diff] [blame] | 145 | // Unsafe access to the app registry model. For safe access use locks (see |
| 146 | // chrome/browser/web_applications/locks/ for more info). |
| 147 | WebAppRegistrar& registrar_unsafe(); |
| 148 | const WebAppRegistrar& registrar_unsafe() const; |
Glen Robertson | 7f21d6d8 | 2023-07-04 01:54:43 | [diff] [blame] | 149 | // Must be exclusively accessed by WebAppSyncBridge. |
Alan Cutter | bd7803c | 2023-06-29 07:38:43 | [diff] [blame] | 150 | WebAppRegistrarMutable& registrar_mutable(base::PassKey<WebAppSyncBridge>); |
Camden King | 9bf43ed | 2022-12-21 22:38:25 | [diff] [blame] | 151 | // Unsafe access to the WebAppSyncBridge. Reading or data from here should be |
| 152 | // considered an 'uncommitted read', and writing data is unsafe and could |
| 153 | // interfere with other operations. For safe access use locks to ensure no |
| 154 | // operations (like install/update/uninstall/etc) are currently running. See |
| 155 | // chrome/browser/web_applications/locks/ for more info. |
Camden King | 7f851df | 2022-12-07 19:29:27 | [diff] [blame] | 156 | WebAppSyncBridge& sync_bridge_unsafe(); |
Song Fangzhen | 1182ac9c | 2021-07-28 18:05:54 | [diff] [blame] | 157 | // UIs can use WebAppInstallManager for user-initiated Web Apps install. |
| 158 | WebAppInstallManager& install_manager(); |
Song Fangzhen | 59c5ae28 | 2021-07-13 07:36:27 | [diff] [blame] | 159 | // Implements persistence for Web Apps install. |
Song Fangzhen | b60b44f4 | 2021-08-11 08:49:23 | [diff] [blame] | 160 | WebAppInstallFinalizer& install_finalizer(); |
Song Fangzhen | 59c5ae28 | 2021-07-13 07:36:27 | [diff] [blame] | 161 | // Keeps app metadata up to date with site manifests. |
| 162 | ManifestUpdateManager& manifest_update_manager(); |
| 163 | // Clients can use ExternallyManagedAppManager to install, uninstall, and |
| 164 | // update Web Apps. |
| 165 | ExternallyManagedAppManager& externally_managed_app_manager(); |
| 166 | // Clients can use WebAppPolicyManager to request updates of policy installed |
| 167 | // Web Apps. |
| 168 | WebAppPolicyManager& policy_manager(); |
Zelin Liu | 51615d1 | 2023-08-29 18:13:39 | [diff] [blame] | 169 | // `IsolatedWebAppInstallationManager` is the entry point for Isolated Web App |
| 170 | // installation. |
| 171 | IsolatedWebAppInstallationManager& isolated_web_app_installation_manager(); |
Christian Flach | e17ea92 | 2023-07-04 10:03:49 | [diff] [blame] | 172 | // Keeps Isolated Web Apps up to date by regularly checking for updates, |
| 173 | // downloading them, and applying them. |
Christian Flach | e17ea92 | 2023-07-04 10:03:49 | [diff] [blame] | 174 | IsolatedWebAppUpdateManager& iwa_update_manager(); |
Sebastian Fiß | e8beb044 | 2023-08-23 14:13:18 | [diff] [blame] | 175 | |
Christian Flach | 42b091fd | 2023-10-11 12:16:15 | [diff] [blame] | 176 | #if BUILDFLAG(IS_CHROMEOS) |
Sebastian Fiß | e8beb044 | 2023-08-23 14:13:18 | [diff] [blame] | 177 | // Runs web apps on OS login. |
| 178 | WebAppRunOnOsLoginManager& run_on_os_login_manager(); |
Irina | 9887326 | 2025-04-28 19:19:24 | [diff] [blame] | 179 | |
| 180 | // Isolated Web App bundle cache manager. |
| 181 | IwaBundleCacheManager& iwa_cache_manager(); |
Christian Flach | e17ea92 | 2023-07-04 10:03:49 | [diff] [blame] | 182 | #endif |
Song Fangzhen | 59c5ae28 | 2021-07-13 07:36:27 | [diff] [blame] | 183 | |
Simon Hangl | c019732 | 2024-11-27 19:03:44 | [diff] [blame] | 184 | IsolatedWebAppPolicyManager& iwa_policy_manager(); |
| 185 | |
Song Fangzhen | 59c5ae28 | 2021-07-13 07:36:27 | [diff] [blame] | 186 | WebAppUiManager& ui_manager(); |
| 187 | |
| 188 | WebAppAudioFocusIdMap& audio_focus_id_map(); |
| 189 | |
Glen Robertson | 7f21d6d8 | 2023-07-04 01:54:43 | [diff] [blame] | 190 | // Interface for file access, allowing mocking for tests. `scoped_refptr` for |
| 191 | // thread safety as this is used on other task runners. |
| 192 | scoped_refptr<FileUtilsWrapper> file_utils(); |
| 193 | |
Song Fangzhen | 59c5ae28 | 2021-07-13 07:36:27 | [diff] [blame] | 194 | // Implements fetching of app icons. |
Song Fangzhen | cffb885 | 2021-08-05 03:51:18 | [diff] [blame] | 195 | WebAppIconManager& icon_manager(); |
Song Fangzhen | 59c5ae28 | 2021-07-13 07:36:27 | [diff] [blame] | 196 | |
Louise Brett | 9a07d83 | 2022-02-10 05:52:33 | [diff] [blame] | 197 | WebAppTranslationManager& translation_manager(); |
| 198 | |
Song Fangzhen | 59c5ae28 | 2021-07-13 07:36:27 | [diff] [blame] | 199 | // Manage all OS hooks that need to be deployed during Web Apps install |
| 200 | OsIntegrationManager& os_integration_manager(); |
Daniel d'Andrada | d8ed51a | 2022-01-11 09:49:51 | [diff] [blame] | 201 | const OsIntegrationManager& os_integration_manager() const; |
Alexey Baskakov | 5f15de1 | 2019-07-10 00:36:15 | [diff] [blame] | 202 | |
Lu Huang | 9cbbdd9 | 2023-04-18 19:14:56 | [diff] [blame] | 203 | WebAppOriginAssociationManager& origin_association_manager(); |
| 204 | |
Daniel Murphy | 22f66f1 | 2023-05-26 20:35:02 | [diff] [blame] | 205 | WebContentsManager& web_contents_manager(); |
| 206 | |
Alan Cutter | bd7803c | 2023-06-29 07:38:43 | [diff] [blame] | 207 | PreinstalledWebAppManager& preinstalled_web_app_manager(); |
| 208 | |
Zelin Liu | 5cc0e1e | 2023-06-30 20:26:49 | [diff] [blame] | 209 | ExtensionsManager& extensions_manager(); |
| 210 | |
Alan Cutter | 56f3cd3 | 2023-09-20 00:29:36 | [diff] [blame] | 211 | GeneratedIconFixManager& generated_icon_fix_manager(); |
| 212 | |
Alan Cutter | bd7803c | 2023-06-29 07:38:43 | [diff] [blame] | 213 | AbstractWebAppDatabaseFactory& database_factory(); |
| 214 | |
Daniel Murphy | 2e5932d | 2024-09-18 16:23:39 | [diff] [blame] | 215 | VisitedManifestManager& visited_manifest_manager(); |
| 216 | |
Daniel Murphy | 9b630c5 | 2024-09-19 01:21:10 | [diff] [blame] | 217 | NavigationCapturingLog& navigation_capturing_log(); |
| 218 | |
Christopher Lam | 342a6f8 | 2019-05-17 05:48:35 | [diff] [blame] | 219 | // KeyedService: |
| 220 | void Shutdown() override; |
| 221 | |
Eric Willigers | 2cd3192 | 2019-06-26 00:53:34 | [diff] [blame] | 222 | // Signals when app registry becomes ready. |
| 223 | const base::OneShotEvent& on_registry_ready() const { |
| 224 | return on_registry_ready_; |
| 225 | } |
Alexey Baskakov | 7f4bffa | 2019-01-08 02:12:38 | [diff] [blame] | 226 | |
Daniel Murphy | 8e0d889 | 2022-11-08 13:30:04 | [diff] [blame] | 227 | // Signals when external app managers have finished calling |
| 228 | // `SynchronizeInstalledApps`, which means that all installs or uninstalls for |
| 229 | // external managers have been scheduled. Specifically these calls are |
| 230 | // triggered from the PreinstalledWebAppManager and the WebAppPolicyManager. |
| 231 | // Note: This does not include the call from the ChromeOS SystemWebAppManager, |
| 232 | // which is a separate keyed service. |
| 233 | const base::OneShotEvent& on_external_managers_synchronized() const { |
| 234 | return on_external_managers_synchronized_; |
| 235 | } |
| 236 | |
Daseul Lee | f3b62d5 | 2022-02-11 22:46:12 | [diff] [blame] | 237 | // Returns whether the app registry is ready. |
Eric Willigers | 94f8550b | 2022-02-28 00:18:31 | [diff] [blame] | 238 | bool is_registry_ready() const { return is_registry_ready_; } |
Daseul Lee | f3b62d5 | 2022-02-11 22:46:12 | [diff] [blame] | 239 | |
Dibyajyoti Pal | c8f0780 | 2023-07-21 22:37:33 | [diff] [blame] | 240 | base::WeakPtr<WebAppProvider> AsWeakPtr(); |
| 241 | |
Daniel Murphy | 6572be0 | 2024-01-17 17:35:03 | [diff] [blame] | 242 | // Returns a nullptr in the default implementation |
| 243 | virtual FakeWebAppProvider* AsFakeWebAppProviderForTesting(); |
| 244 | |
yuncong zhuang | 89759a7b | 2025-05-09 02:31:54 | [diff] [blame] | 245 | #if BUILDFLAG(IS_MAC) |
| 246 | void DoDelayedPostStartupWork(); |
| 247 | #endif |
| 248 | |
Alexey Baskakov | d039275 | 2019-01-10 08:38:28 | [diff] [blame] | 249 | protected: |
Christopher Lam | 4ce340fd | 2019-07-23 08:07:32 | [diff] [blame] | 250 | virtual void StartImpl(); |
| 251 | |
Alexey Baskakov | 84539e9c | 2021-09-03 07:51:49 | [diff] [blame] | 252 | void CreateSubsystems(Profile* profile); |
Alexey Baskakov | ecee2944 | 2020-11-05 07:30:20 | [diff] [blame] | 253 | |
Christopher Lam | 4ce340fd | 2019-07-23 08:07:32 | [diff] [blame] | 254 | // Wire together subsystems but do not start them (yet). |
Christopher Lam | a45ea6d | 2019-07-08 07:22:05 | [diff] [blame] | 255 | void ConnectSubsystems(); |
| 256 | |
Song Fangzhen | d521784 | 2021-08-24 11:18:22 | [diff] [blame] | 257 | // Start sync bridge. All other subsystems depend on it. |
| 258 | void StartSyncBridge(); |
| 259 | void OnSyncBridgeReady(); |
Alexey Baskakov | 7f4bffa | 2019-01-08 02:12:38 | [diff] [blame] | 260 | |
Alexey Baskakov | 0818deee | 2019-08-06 18:33:33 | [diff] [blame] | 261 | void CheckIsConnected() const; |
| 262 | |
Glen Robertson | aaddfad | 2022-03-24 03:37:46 | [diff] [blame] | 263 | std::unique_ptr<AbstractWebAppDatabaseFactory> database_factory_; |
Alan Cutter | bd7803c | 2023-06-29 07:38:43 | [diff] [blame] | 264 | std::unique_ptr<WebAppRegistrarMutable> registrar_; |
Song Fangzhen | d521784 | 2021-08-24 11:18:22 | [diff] [blame] | 265 | std::unique_ptr<WebAppSyncBridge> sync_bridge_; |
Daniel Murphy | 3657906d | 2021-04-13 20:33:12 | [diff] [blame] | 266 | std::unique_ptr<PreinstalledWebAppManager> preinstalled_web_app_manager_; |
Song Fangzhen | cffb885 | 2021-08-05 03:51:18 | [diff] [blame] | 267 | std::unique_ptr<WebAppIconManager> icon_manager_; |
Louise Brett | 9a07d83 | 2022-02-10 05:52:33 | [diff] [blame] | 268 | std::unique_ptr<WebAppTranslationManager> translation_manager_; |
Song Fangzhen | b60b44f4 | 2021-08-11 08:49:23 | [diff] [blame] | 269 | std::unique_ptr<WebAppInstallFinalizer> install_finalizer_; |
Alan Cutter | f2d2485f | 2019-09-05 07:11:13 | [diff] [blame] | 270 | std::unique_ptr<ManifestUpdateManager> manifest_update_manager_; |
Daniel Murphy | 6294817d | 2021-04-13 22:28:13 | [diff] [blame] | 271 | std::unique_ptr<ExternallyManagedAppManager> externally_managed_app_manager_; |
Alan Cutter | 6e07e3b | 2019-08-09 05:11:58 | [diff] [blame] | 272 | std::unique_ptr<WebAppAudioFocusIdMap> audio_focus_id_map_; |
| 273 | std::unique_ptr<WebAppInstallManager> install_manager_; |
Nigel Tao | 192c330 | 2018-07-19 15:17:28 | [diff] [blame] | 274 | std::unique_ptr<WebAppPolicyManager> web_app_policy_manager_; |
Zelin Liu | 51615d1 | 2023-08-29 18:13:39 | [diff] [blame] | 275 | std::unique_ptr<IsolatedWebAppInstallationManager> |
| 276 | isolated_web_app_installation_manager_; |
Christian Flach | e17ea92 | 2023-07-04 10:03:49 | [diff] [blame] | 277 | std::unique_ptr<IsolatedWebAppUpdateManager> iwa_update_manager_; |
Simon Hangl | c019732 | 2024-11-27 19:03:44 | [diff] [blame] | 278 | std::unique_ptr<IsolatedWebAppPolicyManager> isolated_web_app_policy_manager_; |
Christian Flach | 42b091fd | 2023-10-11 12:16:15 | [diff] [blame] | 279 | #if BUILDFLAG(IS_CHROMEOS) |
Sebastian Fiß | 32571959 | 2023-03-07 07:57:58 | [diff] [blame] | 280 | std::unique_ptr<WebAppRunOnOsLoginManager> web_app_run_on_os_login_manager_; |
Irina | 9887326 | 2025-04-28 19:19:24 | [diff] [blame] | 281 | std::unique_ptr<IwaBundleCacheManager> iwa_cache_manager_; |
Sebastian Fiß | 32571959 | 2023-03-07 07:57:58 | [diff] [blame] | 282 | #endif // BUILDFLAG(IS_CHROMEOS) |
Alan Cutter | 6e07e3b | 2019-08-09 05:11:58 | [diff] [blame] | 283 | std::unique_ptr<WebAppUiManager> ui_manager_; |
phillis | 550e371 | 2020-06-19 02:17:27 | [diff] [blame] | 284 | std::unique_ptr<OsIntegrationManager> os_integration_manager_; |
Phillis Tang | 52b1ec4b | 2022-04-13 01:14:31 | [diff] [blame] | 285 | std::unique_ptr<WebAppCommandManager> command_manager_; |
Phillis Tang | 549802e | 2022-09-30 19:40:31 | [diff] [blame] | 286 | std::unique_ptr<WebAppCommandScheduler> command_scheduler_; |
Lu Huang | 9cbbdd9 | 2023-04-18 19:14:56 | [diff] [blame] | 287 | std::unique_ptr<WebAppOriginAssociationManager> origin_association_manager_; |
Daniel Murphy | 22f66f1 | 2023-05-26 20:35:02 | [diff] [blame] | 288 | std::unique_ptr<WebContentsManager> web_contents_manager_; |
Zelin Liu | 5cc0e1e | 2023-06-30 20:26:49 | [diff] [blame] | 289 | std::unique_ptr<ExtensionsManager> extensions_manager_; |
Alan Cutter | 56f3cd3 | 2023-09-20 00:29:36 | [diff] [blame] | 290 | std::unique_ptr<GeneratedIconFixManager> generated_icon_fix_manager_; |
Glen Robertson | 7f21d6d8 | 2023-07-04 01:54:43 | [diff] [blame] | 291 | scoped_refptr<FileUtilsWrapper> file_utils_; |
Daniel Murphy | 2e5932d | 2024-09-18 16:23:39 | [diff] [blame] | 292 | std::unique_ptr<VisitedManifestManager> visited_manifest_manager_; |
Daniel Murphy | 9b630c5 | 2024-09-19 01:21:10 | [diff] [blame] | 293 | std::unique_ptr<NavigationCapturingLog> navigation_capturing_log_; |
Dibyajyoti Pal | 2ff5a926 | 2024-12-07 01:08:35 | [diff] [blame] | 294 | std::unique_ptr<WebAppProfileDeletionManager> profile_deletion_manager_; |
Nigel Tao | 192c330 | 2018-07-19 15:17:28 | [diff] [blame] | 295 | |
Eric Willigers | 2cd3192 | 2019-06-26 00:53:34 | [diff] [blame] | 296 | base::OneShotEvent on_registry_ready_; |
Daniel Murphy | 8e0d889 | 2022-11-08 13:30:04 | [diff] [blame] | 297 | base::OneShotEvent on_external_managers_synchronized_; |
Alexey Baskakov | 7f4bffa | 2019-01-08 02:12:38 | [diff] [blame] | 298 | |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 299 | const raw_ptr<Profile> profile_; |
Alexey Baskakov | da22037 | 2019-01-08 00:21:16 | [diff] [blame] | 300 | |
Christopher Lam | 4ce340fd | 2019-07-23 08:07:32 | [diff] [blame] | 301 | // Ensures that ConnectSubsystems() is not called after Start(). |
Christopher Lam | a45ea6d | 2019-07-08 07:22:05 | [diff] [blame] | 302 | bool started_ = false; |
Christopher Lam | 4ce340fd | 2019-07-23 08:07:32 | [diff] [blame] | 303 | bool connected_ = false; |
Daseul Lee | f3b62d5 | 2022-02-11 22:46:12 | [diff] [blame] | 304 | bool is_registry_ready_ = false; |
Christopher Lam | a45ea6d | 2019-07-08 07:22:05 | [diff] [blame] | 305 | |
Dominick Ng | 7b4ad0b8 | 2018-08-03 15:29:10 | [diff] [blame] | 306 | base::WeakPtrFactory<WebAppProvider> weak_ptr_factory_{this}; |
Nigel Tao | 192c330 | 2018-07-19 15:17:28 | [diff] [blame] | 307 | }; |
| 308 | |
| 309 | } // namespace web_app |
| 310 | |
| 311 | #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_PROVIDER_H_ |