OLD | NEW |
| (Empty) |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "core/fetch/ClientHintsPreferences.h" | |
6 | |
7 #include "platform/RuntimeEnabledFeatures.h" | |
8 #include "platform/network/HTTPParsers.h" | |
9 | |
10 namespace blink { | |
11 | |
12 ClientHintsPreferences::ClientHintsPreferences() | |
13 : m_shouldSendDPR(false), | |
14 m_shouldSendResourceWidth(false), | |
15 m_shouldSendViewportWidth(false) {} | |
16 | |
17 void ClientHintsPreferences::updateFrom( | |
18 const ClientHintsPreferences& preferences) { | |
19 m_shouldSendDPR = preferences.m_shouldSendDPR; | |
20 m_shouldSendResourceWidth = preferences.m_shouldSendResourceWidth; | |
21 m_shouldSendViewportWidth = preferences.m_shouldSendViewportWidth; | |
22 } | |
23 | |
24 void ClientHintsPreferences::updateFromAcceptClientHintsHeader( | |
25 const String& headerValue, | |
26 Context* context) { | |
27 if (!RuntimeEnabledFeatures::clientHintsEnabled() || headerValue.isEmpty()) | |
28 return; | |
29 | |
30 CommaDelimitedHeaderSet acceptClientHintsHeader; | |
31 parseCommaDelimitedHeader(headerValue, acceptClientHintsHeader); | |
32 if (acceptClientHintsHeader.contains("dpr")) { | |
33 if (context) | |
34 context->countClientHintsDPR(); | |
35 m_shouldSendDPR = true; | |
36 } | |
37 | |
38 if (acceptClientHintsHeader.contains("width")) { | |
39 if (context) | |
40 context->countClientHintsResourceWidth(); | |
41 m_shouldSendResourceWidth = true; | |
42 } | |
43 | |
44 if (acceptClientHintsHeader.contains("viewport-width")) { | |
45 if (context) | |
46 context->countClientHintsViewportWidth(); | |
47 m_shouldSendViewportWidth = true; | |
48 } | |
49 } | |
50 | |
51 } // namespace blink | |
OLD | NEW |