Commit 3c96a682 authored by Aaron Tagliaboschi's avatar Aaron Tagliaboschi Committed by Commit Bot

[Client Hints] Fix enum check for ContentSettings retrieval

Also fixed test that was exiting early because of no expiration date
instead of getting to the part that crashed.

Bug: 1018744
Change-Id: Id9df8a144f0274e83589bacdb42cb08dc4dbcea1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1884650Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Commit-Queue: Aaron Tagliaboschi <aarontag@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710395}
parent 5f234b6e
......@@ -1519,7 +1519,9 @@ IN_PROC_BROWSER_TEST_P(ClientHintsBrowserTest,
auto expiration_times_dictionary = std::make_unique<base::DictionaryValue>();
expiration_times_dictionary->SetList("client_hints",
std::move(expiration_times_list));
// Do not set |expiration_time| in the dictionary.
expiration_times_dictionary->SetDouble(
"expiration_time",
(base::Time::Now() + base::TimeDelta::FromDays(1)).ToDoubleT());
host_content_settings_map->SetWebsiteSettingDefaultScope(
without_accept_ch_without_lifetime_url(), GURL(),
CONTENT_SETTINGS_TYPE_CLIENT_HINTS, std::string(),
......
......@@ -54,9 +54,10 @@ void GetAllowedClientHintsFromSource(
base::span<const base::Value> client_hints_list = list_value->GetList();
for (const auto& client_hint : client_hints_list) {
DCHECK(client_hint.is_int());
client_hints->SetIsEnabled(
static_cast<blink::mojom::WebClientHintsType>(client_hint.GetInt()),
true);
blink::mojom::WebClientHintsType client_hint_mojo =
static_cast<blink::mojom::WebClientHintsType>(client_hint.GetInt());
if (blink::mojom::IsKnownEnumValue(client_hint_mojo))
client_hints->SetIsEnabled(client_hint_mojo, true);
}
// Match found for |url| and client hints have been set.
return;
......
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