Commit ea772d32 authored by Dominick Ng's avatar Dominick Ng Committed by Commit Bot

Use the site engagement details to determine installed state for Important Sites.

The EngagementDetails struct allows consumers to determine if
a particular origin is added to home screen. The querying is
equivalent to that implemented in Important Sites - both use a 10 day
recency cutoff. All recently launched sites are recorded by the
engagement service at the exact same time as the content setting used by
the Important Sites code.

This CL removes the custom querying for installed state in Important
Sites and simply checks the EngagementDetails struct.

BUG=711041

Change-Id: I7747f0fbd08e6912cc5966f3ced678b717114547
Reviewed-on: https://chromium-review.googlesource.com/765555Reviewed-by: default avatarDaniel Murphy <dmurph@chromium.org>
Commit-Queue: Dominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516111}
parent c5ced107
......@@ -224,7 +224,10 @@ base::hash_set<std::string> GetBlacklistedImportantDomains(Profile* profile) {
return ignoring_domains;
}
void PopulateInfoMapWithSiteEngagementAndNotifications(
// Inserts origins with some engagement measure into the map, including a site
// engagement cutoff, notifications permission, and recent launches from home
// screen.
void PopulateInfoMapWithEngagement(
Profile* profile,
blink::mojom::EngagementLevel minimum_engagement,
std::map<GURL, double>* engagement_map,
......@@ -244,6 +247,12 @@ void PopulateInfoMapWithSiteEngagementAndNotifications(
output);
}
if (detail.installed_bonus > 0) {
// This origin was recently launched from the home screen.
MaybePopulateImportantInfoForReason(detail.origin, &content_origins,
ImportantReason::HOME_SCREEN, output);
}
(*engagement_map)[detail.origin] = detail.total_score;
if (!service->IsEngagementAtLeast(detail.origin, minimum_engagement))
......@@ -330,26 +339,6 @@ void PopulateInfoMapWithBookmarks(
}
}
void PopulateInfoMapWithHomeScreen(
Profile* profile,
std::map<std::string, ImportantDomainInfo>* output) {
ContentSettingsForOneType content_settings_list;
HostContentSettingsMapFactory::GetForProfile(profile)->GetSettingsForOneType(
CONTENT_SETTINGS_TYPE_APP_BANNER, content_settings::ResourceIdentifier(),
&content_settings_list);
// Extract a set of urls, using the primary pattern. We don't handle
// wildcard patterns.
std::set<GURL> content_origins;
base::Time now = base::Time::Now();
for (const ContentSettingPatternSource& site : content_settings_list) {
GURL origin(site.primary_pattern.ToString());
if (!AppBannerSettingsHelper::WasLaunchedRecently(profile, origin, now))
continue;
MaybePopulateImportantInfoForReason(origin, &content_origins,
ImportantReason::HOME_SCREEN, output);
}
}
} // namespace
std::string ImportantSitesUtil::GetRegisterableDomainOrIP(const GURL& url) {
......@@ -384,9 +373,8 @@ ImportantSitesUtil::GetImportantRegisterableDomains(Profile* profile,
std::map<std::string, ImportantDomainInfo> important_info;
std::map<GURL, double> engagement_map;
PopulateInfoMapWithSiteEngagementAndNotifications(
profile, blink::mojom::EngagementLevel::MEDIUM, &engagement_map,
&important_info);
PopulateInfoMapWithEngagement(profile, blink::mojom::EngagementLevel::MEDIUM,
&engagement_map, &important_info);
PopulateInfoMapWithContentTypeAllowed(
profile, CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, ImportantReason::DURABLE,
......@@ -394,8 +382,6 @@ ImportantSitesUtil::GetImportantRegisterableDomains(Profile* profile,
PopulateInfoMapWithBookmarks(profile, engagement_map, &important_info);
PopulateInfoMapWithHomeScreen(profile, &important_info);
base::hash_set<std::string> blacklisted_domains =
GetBlacklistedImportantDomains(profile);
......
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