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

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

Issue 2483703002: Replicate feature policy headers to remote frames (Closed)
Patch Set: Addressing review comments Created 4 years 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) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
6 * (http://www.torchmobile.com/) 6 * (http://www.torchmobile.com/)
7 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 7 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
8 * Copyright (C) Research In Motion Limited 2009. All rights reserved. 8 * Copyright (C) Research In Motion Limited 2009. All rights reserved.
9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> 9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com>
10 * Copyright (C) 2011 Google Inc. All rights reserved. 10 * Copyright (C) 2011 Google Inc. All rights reserved.
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 : ContentSecurityPolicy::create()); 516 : ContentSecurityPolicy::create());
517 517
518 if (m_provisionalItem && isBackForwardLoadType(m_loadType)) { 518 if (m_provisionalItem && isBackForwardLoadType(m_loadType)) {
519 m_frame->document()->setStateForNewFormElements( 519 m_frame->document()->setStateForNewFormElements(
520 m_provisionalItem->documentState()); 520 m_provisionalItem->documentState());
521 } 521 }
522 } 522 }
523 523
524 void FrameLoader::didBeginDocument() { 524 void FrameLoader::didBeginDocument() {
525 DCHECK(m_frame); 525 DCHECK(m_frame);
526 DCHECK(m_frame->client());
526 DCHECK(m_frame->document()); 527 DCHECK(m_frame->document());
527 DCHECK(m_frame->document()->fetcher()); 528 DCHECK(m_frame->document()->fetcher());
528 529
529 if (m_documentLoader) { 530 if (m_documentLoader) {
530 String suboriginHeader = 531 String suboriginHeader =
531 m_documentLoader->response().httpHeaderField(HTTPNames::Suborigin); 532 m_documentLoader->response().httpHeaderField(HTTPNames::Suborigin);
532 if (!suboriginHeader.isNull()) { 533 if (!suboriginHeader.isNull()) {
533 Vector<String> messages; 534 Vector<String> messages;
534 Suborigin suborigin; 535 Suborigin suborigin;
535 if (parseSuboriginHeader(suboriginHeader, &suborigin, messages)) 536 if (parseSuboriginHeader(suboriginHeader, &suborigin, messages))
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 if (!headerContentLanguage.isEmpty()) { 571 if (!headerContentLanguage.isEmpty()) {
571 m_frame->document()->setContentLanguage( 572 m_frame->document()->setContentLanguage(
572 AtomicString(headerContentLanguage)); 573 AtomicString(headerContentLanguage));
573 } 574 }
574 } 575 }
575 576
576 OriginTrialContext::addTokensFromHeader( 577 OriginTrialContext::addTokensFromHeader(
577 m_frame->document(), 578 m_frame->document(),
578 m_documentLoader->response().httpHeaderField(HTTPNames::Origin_Trial)); 579 m_documentLoader->response().httpHeaderField(HTTPNames::Origin_Trial));
579 if (RuntimeEnabledFeatures::featurePolicyEnabled()) { 580 if (RuntimeEnabledFeatures::featurePolicyEnabled()) {
580 std::unique_ptr<FeaturePolicy> featurePolicy( 581 FeaturePolicy* parentFeaturePolicy =
581 FeaturePolicy::createFromParentPolicy( 582 (isLoadingMainFrame() ? nullptr
582 (isLoadingMainFrame() ? nullptr 583 : m_frame->client()
583 : m_frame->client() 584 ->parent()
584 ->parent() 585 ->securityContext()
585 ->securityContext() 586 ->getFeaturePolicy());
586 ->getFeaturePolicy()), 587 const String& featurePolicyHeader =
587 m_frame->securityContext()->getSecurityOrigin())); 588 m_documentLoader->response().httpHeaderField(
589 HTTPNames::Feature_Policy);
588 Vector<String> messages; 590 Vector<String> messages;
589 featurePolicy->setHeaderPolicy( 591 m_frame->securityContext()->setFeaturePolicyFromHeader(
590 m_documentLoader->response().httpHeaderField( 592 featurePolicyHeader, parentFeaturePolicy, &messages);
591 HTTPNames::Feature_Policy),
592 messages);
593 for (auto& message : messages) { 593 for (auto& message : messages) {
594 m_frame->document()->addConsoleMessage(ConsoleMessage::create( 594 m_frame->document()->addConsoleMessage(ConsoleMessage::create(
595 OtherMessageSource, ErrorMessageLevel, 595 OtherMessageSource, ErrorMessageLevel,
596 "Error with Feature-Policy header: " + message)); 596 "Error with Feature-Policy header: " + message));
597 } 597 }
598 m_frame->document()->setFeaturePolicy(std::move(featurePolicy)); 598 if (!featurePolicyHeader.isEmpty())
599 client()->didSetFeaturePolicyHeader(featurePolicyHeader);
599 } 600 }
600 } 601 }
601 602
602 if (m_documentLoader) { 603 if (m_documentLoader) {
603 String referrerPolicyHeader = m_documentLoader->response().httpHeaderField( 604 String referrerPolicyHeader = m_documentLoader->response().httpHeaderField(
604 HTTPNames::Referrer_Policy); 605 HTTPNames::Referrer_Policy);
605 if (!referrerPolicyHeader.isNull()) { 606 if (!referrerPolicyHeader.isNull()) {
606 m_frame->document()->parseAndSetReferrerPolicy(referrerPolicyHeader); 607 m_frame->document()->parseAndSetReferrerPolicy(referrerPolicyHeader);
607 } 608 }
608 } 609 }
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1952 m_documentLoader ? m_documentLoader->url() : String()); 1953 m_documentLoader ? m_documentLoader->url() : String());
1953 return tracedValue; 1954 return tracedValue;
1954 } 1955 }
1955 1956
1956 inline void FrameLoader::takeObjectSnapshot() const { 1957 inline void FrameLoader::takeObjectSnapshot() const {
1957 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, 1958 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this,
1958 toTracedValue()); 1959 toTracedValue());
1959 } 1960 }
1960 1961
1961 } // namespace blink 1962 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698