Commit 65f1b9bd authored by Alan Cutter's avatar Alan Cutter Committed by Commit Bot

desktop-pwas: Remove use of GetAppScopeInternal in SiteSettingsHandler

This CL updates SiteSettingsHandler to use GetAppScope() instead of
GetAppScopeInternal(). This means it will include web apps that have no
scope and instead use their default scope.

This CL removes a behavioural difference between web apps installed via
promotion and those installed via "create shortcut".

As an extra this CL cleans up some of the naming and types of
GetInstalledApps() to better reflect the usage.

Bug: 910016
Change-Id: I1eae6c496c717ee8a5ca611d3131d2ebff6bf788
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2050221Reviewed-by: default avatarcalamity <calamity@chromium.org>
Commit-Queue: Alan Cutter <alancutter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742056}
parent a22a79ff
......@@ -146,17 +146,13 @@ void AddExceptionsGrantedByHostedApps(
}
}
base::flat_set<web_app::AppId> GetInstalledApps(
base::flat_set<std::string> GetInstalledAppOrigins(
Profile* profile,
const web_app::AppRegistrar& registrar) {
auto apps = registrar.GetAppIds();
base::flat_set<std::string> installed;
for (auto app : apps) {
base::Optional<GURL> scope = registrar.GetAppScopeInternal(app);
if (scope.has_value())
installed.insert(scope.value().GetOrigin().spec());
}
return installed;
base::flat_set<std::string> origins;
for (const web_app::AppId& app : registrar.GetAppIds())
origins.insert(registrar.GetAppScope(app).GetOrigin().spec());
return origins;
}
// Groups |url| into sets of eTLD+1s in |site_group_map|, assuming |url| is an
......@@ -228,8 +224,8 @@ void ConvertSiteGroupMapToListValue(
const web_app::AppRegistrar& registrar) {
DCHECK_EQ(base::Value::Type::LIST, list_value->type());
DCHECK(profile);
base::flat_set<web_app::AppId> installed_apps =
GetInstalledApps(profile, registrar);
base::flat_set<std::string> installed_origins =
GetInstalledAppOrigins(profile, registrar);
SiteEngagementService* engagement_service =
SiteEngagementService::Get(profile);
for (const auto& entry : site_group_map) {
......@@ -256,7 +252,7 @@ void ConvertSiteGroupMapToListValue(
origin_object.SetKey("usage", base::Value(0));
origin_object.SetKey(kNumCookies, base::Value(0));
bool is_installed = installed_apps.contains(origin);
bool is_installed = installed_origins.contains(origin);
if (is_installed)
has_installed_pwa = true;
origin_object.SetKey(kIsInstalled, base::Value(is_installed));
......
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