[PWA/NavCapture]: Create `NavigationCapturingSettings` interface
This CL aims to align CrOS and W/M/L link capturing architecture.
Currently, CrOS does not interact with the same link capturing
architecture as W/M/L since it does not set the link capturing
preferences for web_apps in the DB.
Creating a NavigationCapturingSettings interface that both W/M/L and
CrOS will have their own implementation. This is constructed as part of
the navigation_capturing_process.
The implementation for W/M/L and CrOS is taken from
GetWebAppControllingUrl which can then be removed.
More information found in design document:
https://docs.google.com/document/d/11KjFz_sUmXsPwzLRWGYEOVPV0oK1G7H2wz57EKLPmn8/edit?tab=t.0
Bug: 392712186
Change-Id: I5b1d369769a31bbaa87ca44408276212f3b5ac41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6230494
Reviewed-by: Daniel Murphy <[email protected]>
Reviewed-by: Marijn Kruisselbrink <[email protected]>
Commit-Queue: May Siem <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1418878}
diff --git a/chrome/browser/web_applications/navigation_capturing_settings.h b/chrome/browser/web_applications/navigation_capturing_settings.h
new file mode 100644
index 0000000..ccf046d
--- /dev/null
+++ b/chrome/browser/web_applications/navigation_capturing_settings.h
@@ -0,0 +1,49 @@
+// Copyright 2025 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_WEB_APPLICATIONS_NAVIGATION_CAPTURING_SETTINGS_H_
+#define CHROME_BROWSER_WEB_APPLICATIONS_NAVIGATION_CAPTURING_SETTINGS_H_
+
+#include <memory>
+#include <optional>
+
+#include "components/webapps/common/web_app_id.h"
+
+class Profile;
+
+namespace web_app {
+
+// This class is used by the `NavigationCapturingProcess` to get an installed
+// PWA's `apps::AppId` that captures a given url. This is abstracted behind an
+// interface because ChromeOS uses a separate storage / source of truth for this
+// information than other platforms, and has some extra constraints &
+// requirements due to needing to support ARC++ / Android apps.
+//
+// This class is used exclusively on the UI thread.
+class NavigationCapturingSettings {
+ public:
+ static std::unique_ptr<NavigationCapturingSettings> Create(Profile&);
+ virtual ~NavigationCapturingSettings() = default;
+
+ // Returns the app_id for the web app that a url should be captured in.
+ // Otherwise, return nullopt.
+ virtual std::optional<webapps::AppId> GetCapturingWebAppForUrl(
+ const GURL& url) = 0;
+
+ // Return if auxiliary contexts should be created in the same container (app
+ // or browser) that the navigation happened in. Due to breakage, this is
+ // disabled by default via feature flag, but is planned to be changed to
+ // always 'true'.
+ //
+ // In the meantime, on ChromeOS for <experiment class>, this is selectively
+ // enabled for certain cases to support that project, until we can ship the
+ // above change.
+ virtual bool ShouldAuxiliaryContextsKeepSameContainer(
+ const std::optional<webapps::AppId>& source_browser_app_id,
+ const GURL& url);
+};
+
+} // namespace web_app
+
+#endif // CHROME_BROWSER_WEB_APPLICATIONS_NAVIGATION_CAPTURING_SETTINGS_H_