Commit 370f8ae7 authored by Daniel Murphy's avatar Daniel Murphy Committed by Commit Bot

Speculative fix for InstallableUtils crash

The WebAppProvider can be uninitialized. Dependencies should use the
on_registry_ready() signal. This change is a quick & mergeable fix for
a related crash, after which the codepaths will be turned async if
possible.

TBR-ing dominick so this change can get a canary roll, and they can
look at it when they get in on Monday. Patch is very low-risk -
resolving crash when there used to be a crash.

R=pwnall@chromium.org

TBR: dominickn@chromium.org
Bug: 1129921
Change-Id: I57c6d4f181f28c178df85c60626423a5619f9494
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2419537
Commit-Queue: Daniel Murphy <dmurph@chromium.org>
Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808617}
parent dbd6172e
...@@ -41,6 +41,10 @@ bool DoesOriginContainAnyInstalledWebApp( ...@@ -41,6 +41,10 @@ bool DoesOriginContainAnyInstalledWebApp(
#else #else
auto* provider = web_app::WebAppProviderFactory::GetForProfile( auto* provider = web_app::WebAppProviderFactory::GetForProfile(
Profile::FromBrowserContext(browser_context)); Profile::FromBrowserContext(browser_context));
// TODO: Change this method to async, or document that the caller must know
// that WebAppProvider is started.
if (!provider || !provider->on_registry_ready().is_signaled())
return false;
return provider->registrar().DoesScopeContainAnyApp(origin); return provider->registrar().DoesScopeContainAnyApp(origin);
#endif #endif
} }
...@@ -50,9 +54,13 @@ std::set<GURL> GetOriginsWithInstalledWebApps( ...@@ -50,9 +54,13 @@ std::set<GURL> GetOriginsWithInstalledWebApps(
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
return ShortcutHelper::GetOriginsWithInstalledWebApksOrTwas(); return ShortcutHelper::GetOriginsWithInstalledWebApksOrTwas();
#else #else
const web_app::AppRegistrar& registrar = auto* provider = web_app::WebAppProvider::Get(
web_app::WebAppProvider::Get(Profile::FromBrowserContext(browser_context)) Profile::FromBrowserContext(browser_context));
->registrar(); // TODO: Change this method to async, or document that the caller must know
// that WebAppProvider is started.
if (!provider || !provider->on_registry_ready().is_signaled())
return std::set<GURL>();
const web_app::AppRegistrar& registrar = provider->registrar();
auto app_ids = registrar.GetAppIds(); auto app_ids = registrar.GetAppIds();
std::set<GURL> installed_origins; std::set<GURL> installed_origins;
for (auto& app_id : app_ids) { for (auto& app_id : app_ids) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment