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

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

Issue 2109633002: Executed HTTPS upgrade before notifying the start of the provisional load. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplified cross site URL code. Created 4 years, 5 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
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 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 { 662 {
663 if (frame()->document()) 663 if (frame()->document())
664 frame()->document()->addConsoleMessage(ConsoleMessage::create(JSMessageS ource, ErrorMessageLevel, message)); 664 frame()->document()->addConsoleMessage(ConsoleMessage::create(JSMessageS ource, ErrorMessageLevel, message));
665 } 665 }
666 666
667 SecurityOrigin* FrameFetchContext::getSecurityOrigin() const 667 SecurityOrigin* FrameFetchContext::getSecurityOrigin() const
668 { 668 {
669 return m_document ? m_document->getSecurityOrigin() : nullptr; 669 return m_document ? m_document->getSecurityOrigin() : nullptr;
670 } 670 }
671 671
672 void FrameFetchContext::upgradeInsecureRequest(FetchRequest& fetchRequest) 672 void FrameFetchContext::upgradeInsecureRequest(ResourceRequest& resourceRequest)
673 { 673 {
674 KURL url = fetchRequest.resourceRequest().url();
675
676 // Tack an 'Upgrade-Insecure-Requests' header to outgoing navigational reque sts, as described in 674 // Tack an 'Upgrade-Insecure-Requests' header to outgoing navigational reque sts, as described in
677 // https://w3c.github.io/webappsec/specs/upgrade/#feature-detect 675 // https://w3c.github.io/webappsec/specs/upgrade/#feature-detect
678 if (fetchRequest.resourceRequest().frameType() != WebURLRequest::FrameTypeNo ne) 676 if (resourceRequest.frameType() != WebURLRequest::FrameTypeNone) {
679 fetchRequest.mutableResourceRequest().addHTTPHeaderField("Upgrade-Insecu re-Requests", "1"); 677
678 // Early return if the request has already been upgraded.
679 if (resourceRequest.httpHeaderField("Upgrade-Insecure-Requests") == Atom icString("1"))
680 return;
681
682 resourceRequest.addHTTPHeaderField("Upgrade-Insecure-Requests", "1");
683 }
684
685 KURL url = resourceRequest.url();
680 686
681 // If we don't yet have an |m_document| (because we're loading an iframe, fo r instance), check the FrameLoader's policy. 687 // If we don't yet have an |m_document| (because we're loading an iframe, fo r instance), check the FrameLoader's policy.
682 WebInsecureRequestPolicy relevantPolicy = m_document ? m_document->getInsecu reRequestPolicy() : frame()->loader().getInsecureRequestPolicy(); 688 WebInsecureRequestPolicy relevantPolicy = m_document ? m_document->getInsecu reRequestPolicy() : frame()->loader().getInsecureRequestPolicy();
683 SecurityContext::InsecureNavigationsSet* relevantNavigationSet = m_document ? m_document->insecureNavigationsToUpgrade() : frame()->loader().insecureNavigat ionsToUpgrade(); 689 SecurityContext::InsecureNavigationsSet* relevantNavigationSet = m_document ? m_document->insecureNavigationsToUpgrade() : frame()->loader().insecureNavigat ionsToUpgrade();
684 690
685 if (url.protocolIs("http") && relevantPolicy & kUpgradeInsecureRequests) { 691 if (url.protocolIs("http") && relevantPolicy & kUpgradeInsecureRequests) {
686 // We always upgrade requests that meet any of the following criteria: 692 // We always upgrade requests that meet any of the following criteria:
687 // 693 //
688 // 1. Are for subresources (including nested frames). 694 // 1. Are for subresources (including nested frames).
689 // 2. Are form submissions. 695 // 2. Are form submissions.
690 // 3. Whose hosts are contained in the document's InsecureNavigationSet. 696 // 3. Whose hosts are contained in the document's InsecureNavigationSet.
691 const ResourceRequest& request = fetchRequest.resourceRequest(); 697 if (resourceRequest.frameType() == WebURLRequest::FrameTypeNone
692 if (request.frameType() == WebURLRequest::FrameTypeNone 698 || resourceRequest.frameType() == WebURLRequest::FrameTypeNested
693 || request.frameType() == WebURLRequest::FrameTypeNested 699 || resourceRequest.requestContext() == WebURLRequest::RequestContext Form
694 || request.requestContext() == WebURLRequest::RequestContextForm 700 || (!url.host().isNull() && relevantNavigationSet->contains(url.host ().impl()->hash()))) {
695 || (!url.host().isNull() && relevantNavigationSet->contains(url.host ().impl()->hash())))
696 {
697 UseCounter::count(m_document, UseCounter::UpgradeInsecureRequestsUpg radedRequest); 701 UseCounter::count(m_document, UseCounter::UpgradeInsecureRequestsUpg radedRequest);
698 url.setProtocol("https"); 702 url.setProtocol("https");
699 if (url.port() == 80) 703 if (url.port() == 80)
700 url.setPort(443); 704 url.setPort(443);
701 fetchRequest.mutableResourceRequest().setURL(url); 705 resourceRequest.setURL(url);
702 } 706 }
703 } 707 }
704 } 708 }
705 709
706 void FrameFetchContext::addClientHintsIfNecessary(FetchRequest& fetchRequest) 710 void FrameFetchContext::addClientHintsIfNecessary(FetchRequest& fetchRequest)
707 { 711 {
708 if (!RuntimeEnabledFeatures::clientHintsEnabled() || !m_document) 712 if (!RuntimeEnabledFeatures::clientHintsEnabled() || !m_document)
709 return; 713 return;
710 714
711 bool shouldSendDPR = m_document->clientHintsPreferences().shouldSendDPR() || fetchRequest.clientHintsPreferences().shouldSendDPR(); 715 bool shouldSendDPR = m_document->clientHintsPreferences().shouldSendDPR() || fetchRequest.clientHintsPreferences().shouldSendDPR();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 } 787 }
784 788
785 DEFINE_TRACE(FrameFetchContext) 789 DEFINE_TRACE(FrameFetchContext)
786 { 790 {
787 visitor->trace(m_document); 791 visitor->trace(m_document);
788 visitor->trace(m_documentLoader); 792 visitor->trace(m_documentLoader);
789 FetchContext::trace(visitor); 793 FetchContext::trace(visitor);
790 } 794 }
791 795
792 } // namespace blink 796 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698