OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 } | 609 } |
610 } | 610 } |
611 } | 611 } |
612 | 612 |
613 void FrameFetchContext::addClientHintsIfNecessary(FetchRequest& fetchRequest) | 613 void FrameFetchContext::addClientHintsIfNecessary(FetchRequest& fetchRequest) |
614 { | 614 { |
615 if (!RuntimeEnabledFeatures::clientHintsEnabled() || !m_document) | 615 if (!RuntimeEnabledFeatures::clientHintsEnabled() || !m_document) |
616 return; | 616 return; |
617 | 617 |
618 bool shouldSendDPR = m_document->clientHintsPreferences().shouldSendDPR() ||
fetchRequest.clientHintsPreferences().shouldSendDPR(); | 618 bool shouldSendDPR = m_document->clientHintsPreferences().shouldSendDPR() ||
fetchRequest.clientHintsPreferences().shouldSendDPR(); |
619 bool shouldSendRW = m_document->clientHintsPreferences().shouldSendRW() || f
etchRequest.clientHintsPreferences().shouldSendRW(); | 619 bool shouldSendResourceWidth = m_document->clientHintsPreferences().shouldSe
ndResourceWidth() || fetchRequest.clientHintsPreferences().shouldSendResourceWid
th(); |
| 620 bool shouldSendViewportWidth = m_document->clientHintsPreferences().shouldSe
ndViewportWidth() || fetchRequest.clientHintsPreferences().shouldSendViewportWid
th(); |
620 | 621 |
621 if (shouldSendDPR) | 622 if (shouldSendDPR) |
622 fetchRequest.mutableResourceRequest().addHTTPHeaderField("DPR", AtomicSt
ring(String::number(m_document->devicePixelRatio()))); | 623 fetchRequest.mutableResourceRequest().addHTTPHeaderField("DPR", AtomicSt
ring(String::number(m_document->devicePixelRatio()))); |
623 | 624 |
624 if (shouldSendRW && frame()->view()) { | 625 if (shouldSendResourceWidth) { |
625 FetchRequest::ResourceWidth resourceWidth = fetchRequest.resourceWidth()
; | 626 FetchRequest::ResourceWidth resourceWidth = fetchRequest.resourceWidth()
; |
626 float usedResourceWidth = resourceWidth.isSet ? resourceWidth.width : fr
ame()->view()->viewportWidth(); | 627 if (resourceWidth.isSet) |
627 fetchRequest.mutableResourceRequest().addHTTPHeaderField("RW", AtomicStr
ing(String::number(ceil(usedResourceWidth)))); | 628 fetchRequest.mutableResourceRequest().addHTTPHeaderField("Width", At
omicString(String::number(ceil(resourceWidth.width)))); |
628 } | 629 } |
| 630 |
| 631 if (shouldSendViewportWidth && frame()->view()) |
| 632 fetchRequest.mutableResourceRequest().addHTTPHeaderField("Viewport-Width
", AtomicString(String::number(frame()->view()->viewportWidth()))); |
629 } | 633 } |
630 | 634 |
631 void FrameFetchContext::addCSPHeaderIfNecessary(Resource::Type type, FetchReques
t& fetchRequest) | 635 void FrameFetchContext::addCSPHeaderIfNecessary(Resource::Type type, FetchReques
t& fetchRequest) |
632 { | 636 { |
633 if (!m_document) | 637 if (!m_document) |
634 return; | 638 return; |
635 | 639 |
636 const ContentSecurityPolicy* csp = m_document->contentSecurityPolicy(); | 640 const ContentSecurityPolicy* csp = m_document->contentSecurityPolicy(); |
637 if (csp->shouldSendCSPHeader(type)) | 641 if (csp->shouldSendCSPHeader(type)) |
638 fetchRequest.mutableResourceRequest().addHTTPHeaderField("CSP", "active"
); | 642 fetchRequest.mutableResourceRequest().addHTTPHeaderField("CSP", "active"
); |
639 } | 643 } |
640 | 644 |
641 DEFINE_TRACE(FrameFetchContext) | 645 DEFINE_TRACE(FrameFetchContext) |
642 { | 646 { |
643 visitor->trace(m_document); | 647 visitor->trace(m_document); |
644 FetchContext::trace(visitor); | 648 FetchContext::trace(visitor); |
645 } | 649 } |
646 | 650 |
647 } // namespace blink | 651 } // namespace blink |
OLD | NEW |