[PWA] AreWebAppsEnabled returns false for incognito.
Web apps are not usable in off-the-record profiles, and usage of
AreWebAppsEnabled generally assumes it will return false for profiles
where web apps are not running. This was changed in the past for CrOS
'guest' profiles a bit.
Multiple bugs have occurred where functionality was accidentally on for
OTR profiles due to this returning 'true'.
Due to all callers of this almost always wanting it to return 'false'
for non-supported profiles (where it doesn't look at the 'original
profile'), this patch fixes this. It is the responsibility of callers
now to check the original profile if the caller wants to support OTR.
After this patch, the only difference between
ebAppProvider::GetForWebApps and AreWebAppsEnabled is now that the
former will also still look at the 'original' profile.
See crbug.com/384063076 for that follow-up.
Bug: 383858627,b:383360269, b:374351946
Change-Id: Ifb7f0629d463f151583fb760c5fdc54f8c9c6cc6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6090262
Reviewed-by: Dibyajyoti Pal <[email protected]>
Commit-Queue: Daniel Murphy <[email protected]>
Reviewed-by: Stefan Kuhne <[email protected]>
Auto-Submit: Daniel Murphy <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1398134}
diff --git a/chrome/browser/web_applications/web_app_provider.h b/chrome/browser/web_applications/web_app_provider.h
index fae072c..a5bcff8b 100644
--- a/chrome/browser/web_applications/web_app_provider.h
+++ b/chrome/browser/web_applications/web_app_provider.h
@@ -82,11 +82,14 @@
class WebAppProvider : public KeyedService {
public:
// Deprecated: Use GetForWebApps instead.
+ // TODO(https://crbug.com/384063076): Stop returning the WebAppProvider for
+ // profiles where `AreWebAppsEnabled` returns `false`.
static WebAppProvider* GetDeprecated(Profile* profile);
- // On Windows, Mac and Linux, always returns a WebAppProvider.
- // On Chrome OS: In Ash, returns nullptr if Lacros Web App (WebAppsCrosapi) is
- // enabled and it is not the Shimless RMA app profile.
+ // This always returns a WebAppProvider, even if this is in an incognito
+ // profile (it gets the one from the parent).
+ // TODO(https://crbug.com/384063076): Stop returning the WebAppProvider for
+ // profiles where `AreWebAppsEnabled` returns `false`.
static WebAppProvider* GetForWebApps(Profile* profile);
// Returns the WebAppProvider for the current process. In particular:
@@ -98,12 +101,19 @@
// provides a guarantee they are being called from the correct process. Only
// use this if the calling code is shared between Ash and Lacros and expects
// the PWA WebAppProvider in Lacros and the SWA WebAppProvider in Ash.
+ // TODO(https://crbug.com/384063076): Stop returning the WebAppProvider for
+ // profiles where `AreWebAppsEnabled` returns `false`.
static WebAppProvider* GetForLocalAppsUnchecked(Profile* profile);
// Return the WebAppProvider for tests, regardless of whether this is running
// in Lacros/Ash. Blocks if the web app registry is not yet ready.
+ // TODO(https://crbug.com/384063076): Stop returning the WebAppProvider for
+ // profiles where `AreWebAppsEnabled` returns `false`.
static WebAppProvider* GetForTest(Profile* profile);
+ // TODO(https://crbug.com/384063076): Stop returning the WebAppProvider for
+ // profiles where `AreWebAppsEnabled` returns `false` for the web content's
+ // browser.
static WebAppProvider* GetForWebContents(content::WebContents* web_contents);
using OsIntegrationManagerFactory =