Commit d9530b08 authored by Christian Dullweber's avatar Christian Dullweber Committed by Commit Bot

Remove GetWebsiteSettings call from imporant_sites util

It shouldn't be necessary to fetch each WebsiteSetting individually as
they are already fetched GetSettingsForOneType and we don't have
important sites settings that override other settings (e.g. based on
scope, different provider or incognito mode).

Change-Id: Ieb3c7aba739746daa782e0c31175e4e103b76bc2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2403480Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Christian Dullweber <dullweber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806128}
parent ba7450e8
...@@ -107,21 +107,21 @@ void RecordIgnore(base::DictionaryValue* dict) { ...@@ -107,21 +107,21 @@ void RecordIgnore(base::DictionaryValue* dict) {
} }
// If we should blacklist the item with the given dictionary ignored record. // If we should blacklist the item with the given dictionary ignored record.
bool ShouldSuppressItem(base::DictionaryValue* dict) { bool ShouldSuppressItem(base::Value* dict) {
double last_ignored_time = 0; base::Optional<double> last_ignored_time =
if (dict->GetDouble(kTimeLastIgnored, &last_ignored_time)) { dict->FindDoubleKey(kTimeLastIgnored);
if (last_ignored_time) {
base::TimeDelta diff = base::TimeDelta diff =
base::Time::Now() - base::Time::FromDoubleT(last_ignored_time); base::Time::Now() - base::Time::FromDoubleT(*last_ignored_time);
if (diff >= base::TimeDelta::FromDays(kBlacklistExpirationTimeDays)) { if (diff >= base::TimeDelta::FromDays(kBlacklistExpirationTimeDays)) {
dict->SetInteger(kNumTimesIgnoredName, 0); dict->SetIntKey(kNumTimesIgnoredName, 0);
dict->Remove(kTimeLastIgnored, nullptr); dict->RemoveKey(kTimeLastIgnored);
return false; return false;
} }
} }
int times_ignored = 0; base::Optional<int> times_ignored = dict->FindIntKey(kNumTimesIgnoredName);
return dict->GetInteger(kNumTimesIgnoredName, &times_ignored) && return times_ignored && *times_ignored >= kTimesIgnoredForBlacklist;
times_ignored >= kTimesIgnoredForBlacklist;
} }
CrossedReason GetCrossedReasonFromBitfield(int32_t reason_bitfield) { CrossedReason GetCrossedReasonFromBitfield(int32_t reason_bitfield) {
...@@ -218,21 +218,16 @@ std::unordered_set<std::string> GetBlacklistedImportantDomains( ...@@ -218,21 +218,16 @@ std::unordered_set<std::string> GetBlacklistedImportantDomains(
content_settings::ResourceIdentifier(), content_settings::ResourceIdentifier(),
&content_settings_list); &content_settings_list);
std::unordered_set<std::string> ignoring_domains; std::unordered_set<std::string> ignoring_domains;
for (const ContentSettingPatternSource& site : content_settings_list) { for (ContentSettingPatternSource& site : content_settings_list) {
GURL origin(site.primary_pattern.ToString()); GURL origin(site.primary_pattern.ToString());
if (!origin.is_valid() || base::Contains(ignoring_domains, origin.host())) { if (!origin.is_valid() || base::Contains(ignoring_domains, origin.host())) {
continue; continue;
} }
std::unique_ptr<base::DictionaryValue> dict = if (!site.setting_value.is_dict())
base::DictionaryValue::From(map->GetWebsiteSetting(
origin, origin, ContentSettingsType::IMPORTANT_SITE_INFO, "",
nullptr));
if (!dict)
continue; continue;
if (ShouldSuppressItem(dict.get())) if (ShouldSuppressItem(&site.setting_value))
ignoring_domains.insert(origin.host()); ignoring_domains.insert(origin.host());
} }
return ignoring_domains; return ignoring_domains;
......
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