msiem | adbabe3 | 2025-02-11 21:16:57 | [diff] [blame] | 1 | // Copyright 2025 The Chromium Authors |
| 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_NAVIGATION_CAPTURING_SETTINGS_H_ |
| 6 | #define CHROME_BROWSER_WEB_APPLICATIONS_NAVIGATION_CAPTURING_SETTINGS_H_ |
| 7 | |
| 8 | #include <memory> |
| 9 | #include <optional> |
| 10 | |
| 11 | #include "components/webapps/common/web_app_id.h" |
| 12 | |
| 13 | class Profile; |
| 14 | |
| 15 | namespace web_app { |
| 16 | |
| 17 | // This class is used by the `NavigationCapturingProcess` to get an installed |
| 18 | // PWA's `apps::AppId` that captures a given url. This is abstracted behind an |
| 19 | // interface because ChromeOS uses a separate storage / source of truth for this |
| 20 | // information than other platforms, and has some extra constraints & |
| 21 | // requirements due to needing to support ARC++ / Android apps. |
| 22 | // |
| 23 | // This class is used exclusively on the UI thread. |
| 24 | class NavigationCapturingSettings { |
| 25 | public: |
| 26 | static std::unique_ptr<NavigationCapturingSettings> Create(Profile&); |
| 27 | virtual ~NavigationCapturingSettings() = default; |
| 28 | |
| 29 | // Returns the app_id for the web app that a url should be captured in. |
| 30 | // Otherwise, return nullopt. |
| 31 | virtual std::optional<webapps::AppId> GetCapturingWebAppForUrl( |
| 32 | const GURL& url) = 0; |
| 33 | |
| 34 | // Return if auxiliary contexts should be created in the same container (app |
| 35 | // or browser) that the navigation happened in. Due to breakage, this is |
| 36 | // disabled by default via feature flag, but is planned to be changed to |
| 37 | // always 'true'. |
| 38 | // |
| 39 | // In the meantime, on ChromeOS for <experiment class>, this is selectively |
| 40 | // enabled for certain cases to support that project, until we can ship the |
| 41 | // above change. |
| 42 | virtual bool ShouldAuxiliaryContextsKeepSameContainer( |
| 43 | const std::optional<webapps::AppId>& source_browser_app_id, |
| 44 | const GURL& url); |
| 45 | }; |
| 46 | |
| 47 | } // namespace web_app |
| 48 | |
| 49 | #endif // CHROME_BROWSER_WEB_APPLICATIONS_NAVIGATION_CAPTURING_SETTINGS_H_ |