Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: Source/core/loader/FrameFetchContext.cpp

Issue 1010893003: Upgrade insecure requests: Pipe navigational hosts down into nested documents. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 return; 623 return;
624 624
625 KURL url = fetchRequest.resourceRequest().url(); 625 KURL url = fetchRequest.resourceRequest().url();
626 626
627 // Tack a 'Prefer' header to outgoing navigational requests, as described in 627 // Tack a 'Prefer' header to outgoing navigational requests, as described in
628 // https://w3c.github.io/webappsec/specs/upgrade/#feature-detect 628 // https://w3c.github.io/webappsec/specs/upgrade/#feature-detect
629 if (fetchRequest.resourceRequest().frameType() != WebURLRequest::FrameTypeNo ne && !SecurityOrigin::isSecure(url)) 629 if (fetchRequest.resourceRequest().frameType() != WebURLRequest::FrameTypeNo ne && !SecurityOrigin::isSecure(url))
630 fetchRequest.mutableResourceRequest().addHTTPHeaderField("Prefer", "retu rn=secure-representation"); 630 fetchRequest.mutableResourceRequest().addHTTPHeaderField("Prefer", "retu rn=secure-representation");
631 631
632 if (m_document->insecureRequestsPolicy() == SecurityContext::InsecureRequest sUpgrade && url.protocolIs("http")) { 632 if (m_document->insecureRequestsPolicy() == SecurityContext::InsecureRequest sUpgrade && url.protocolIs("http")) {
633 // We always upgrade subresource requests and nested frames, we always u pgrade form 633 ASSERT(m_document->insecureNavigationsToUpgrade());
634 // submissions, and we always upgrade requests whose host matches the ho st of the 634
635 // containing document's security origin. 635 // We always upgrade requests that meet any of the following criteria:
636 // 636 //
637 // FIXME: We need to check the document that set the policy, not the cur rent document. 637 // 1. Are for subresources (including nested frames).
638 // 2. Are form submissions.
639 // 3. Whose hosts are contained in the document's InsecureNavigationSet.
638 const ResourceRequest& request = fetchRequest.resourceRequest(); 640 const ResourceRequest& request = fetchRequest.resourceRequest();
639 if (request.frameType() == WebURLRequest::FrameTypeNone 641 if (request.frameType() == WebURLRequest::FrameTypeNone
640 || request.frameType() == WebURLRequest::FrameTypeNested 642 || request.frameType() == WebURLRequest::FrameTypeNested
641 || request.requestContext() == WebURLRequest::RequestContextForm 643 || request.requestContext() == WebURLRequest::RequestContextForm
642 || url.host() == document()->securityOrigin()->host()) 644 || (!url.host().isNull() && m_document->insecureNavigationsToUpgrade ()->contains(url.host().impl()->hash())))
643 { 645 {
644 url.setProtocol("https"); 646 url.setProtocol("https");
645 if (url.port() == 80) 647 if (url.port() == 80)
646 url.setPort(443); 648 url.setPort(443);
647 fetchRequest.mutableResourceRequest().setURL(url); 649 fetchRequest.mutableResourceRequest().setURL(url);
648 } 650 }
649 } 651 }
650 } 652 }
651 653
652 void FrameFetchContext::addClientHintsIfNecessary(FetchRequest& fetchRequest) 654 void FrameFetchContext::addClientHintsIfNecessary(FetchRequest& fetchRequest)
653 { 655 {
654 if (!frame() || !RuntimeEnabledFeatures::clientHintsEnabled() || !m_document ) 656 if (!frame() || !RuntimeEnabledFeatures::clientHintsEnabled() || !m_document )
655 return; 657 return;
656 658
657 if (frame()->shouldSendDPRHint()) 659 if (frame()->shouldSendDPRHint())
658 fetchRequest.mutableResourceRequest().addHTTPHeaderField("DPR", AtomicSt ring(String::number(m_document->devicePixelRatio()))); 660 fetchRequest.mutableResourceRequest().addHTTPHeaderField("DPR", AtomicSt ring(String::number(m_document->devicePixelRatio())));
659 661
660 // FIXME: Send the RW hint based on the actual resource width, when we have it. 662 // FIXME: Send the RW hint based on the actual resource width, when we have it.
661 if (frame()->shouldSendRWHint() && frame()->view()) 663 if (frame()->shouldSendRWHint() && frame()->view())
662 fetchRequest.mutableResourceRequest().addHTTPHeaderField("RW", AtomicStr ing(String::number(frame()->view()->viewportWidth()))); 664 fetchRequest.mutableResourceRequest().addHTTPHeaderField("RW", AtomicStr ing(String::number(frame()->view()->viewportWidth())));
663 } 665 }
664 666
665 DEFINE_TRACE(FrameFetchContext) 667 DEFINE_TRACE(FrameFetchContext)
666 { 668 {
667 visitor->trace(m_document); 669 visitor->trace(m_document);
668 FetchContext::trace(visitor); 670 FetchContext::trace(visitor);
669 } 671 }
670 672
671 } // namespace blink 673 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698