Move ClientHintsPreferences processing out of HTMLPreloadScanner

The ClientHintsPreferences logic in HTMLPreloadScanner has to be done on
the main thread. To prepare for experimenting with an off-main-thread
preload scanner, this changes HTMLPreloadScanner to instead collect a
list of Accept-CH meta values which are then processed by
HTMLDocumentParser. This has the added benefit of unifying all Accept-CH
processing logic in HTMLMetaElement::ProcessMetaAcceptCH().

Bug: 1329535
Change-Id: I1e9c72b3cd108f921668dc0a64920e51587a8392
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3680785
Reviewed-by: Mason Freed <masonf@chromium.org>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Reviewed-by: Yoav Weiss <yoavweiss@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1013535}
diff --git a/client-hints/accept-ch/meta/resource-in-markup-http-equiv.https.html b/client-hints/accept-ch/meta/resource-in-markup-http-equiv.https.html
new file mode 100644
index 0000000..0ef57c0
--- /dev/null
+++ b/client-hints/accept-ch/meta/resource-in-markup-http-equiv.https.html
@@ -0,0 +1,13 @@
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+
+<meta http-equiv="Accept-CH" content="sec-ch-dpr">
+
+<script src="../../resources/script-set-dpr-header.py"></script>
+
+<script>
+test(() => {
+  assert_greater_than(dprHeader.length, 0,
+                      "sec-ch-dpr header should have been received");
+}, "DPR is received in page with Accept-CH http-equiv meta tag");
+</script>
diff --git a/client-hints/accept-ch/meta/resource-in-markup-name.https.html b/client-hints/accept-ch/meta/resource-in-markup-name.https.html
new file mode 100644
index 0000000..0087df1
--- /dev/null
+++ b/client-hints/accept-ch/meta/resource-in-markup-name.https.html
@@ -0,0 +1,13 @@
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+
+<meta name="Accept-CH" content="sec-ch-dpr">
+
+<script src="../../resources/script-set-dpr-header.py"></script>
+
+<script>
+test(() => {
+  assert_greater_than(dprHeader.length, 0,
+                      "sec-ch-dpr header should have been received");
+}, "DPR is received in page with Accept-CH meta tag");
+</script>
diff --git a/client-hints/resources/script-set-dpr-header.py b/client-hints/resources/script-set-dpr-header.py
new file mode 100644
index 0000000..9a65886
--- /dev/null
+++ b/client-hints/resources/script-set-dpr-header.py
@@ -0,0 +1,4 @@
+def main(request, response):
+    headers = [(b"Content-Type", b"text/javascript")]
+    body = u'dprHeader = "%s";' % request.headers.get(b'sec-ch-dpr', '')
+    return 200, headers, body