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

Side by Side Diff: third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp

Issue 1913983002: Use document referrer policy when preloading (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add test expectation Created 4 years, 7 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) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/ 3 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/
4 * Copyright (C) 2010 Google Inc. All Rights Reserved. 4 * Copyright (C) 2010 Google Inc. All Rights Reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 , m_inScript(false) 477 , m_inScript(false)
478 , m_isAppCacheEnabled(false) 478 , m_isAppCacheEnabled(false)
479 , m_isCSPEnabled(false) 479 , m_isCSPEnabled(false)
480 , m_templateCount(0) 480 , m_templateCount(0)
481 , m_documentParameters(documentParameters) 481 , m_documentParameters(documentParameters)
482 , m_mediaValues(MediaValuesCached::create(mediaValuesCachedData)) 482 , m_mediaValues(MediaValuesCached::create(mediaValuesCachedData))
483 , m_didRewind(false) 483 , m_didRewind(false)
484 { 484 {
485 ASSERT(m_documentParameters.get()); 485 ASSERT(m_documentParameters.get());
486 ASSERT(m_mediaValues.get()); 486 ASSERT(m_mediaValues.get());
487 m_cssScanner.setReferrerPolicy(m_documentParameters->referrerPolicy);
487 } 488 }
488 489
489 TokenPreloadScanner::~TokenPreloadScanner() 490 TokenPreloadScanner::~TokenPreloadScanner()
490 { 491 {
491 } 492 }
492 493
493 TokenPreloadScannerCheckpoint TokenPreloadScanner::createCheckpoint() 494 TokenPreloadScannerCheckpoint TokenPreloadScanner::createCheckpoint()
494 { 495 {
495 TokenPreloadScannerCheckpoint checkpoint = m_checkpoints.size(); 496 TokenPreloadScannerCheckpoint checkpoint = m_checkpoints.size();
496 m_checkpoints.append(Checkpoint(m_predictedBaseElementURL, m_inStyle, m_inSc ript, m_isAppCacheEnabled, m_isCSPEnabled, m_templateCount)); 497 m_checkpoints.append(Checkpoint(m_predictedBaseElementURL, m_inStyle, m_inSc ript, m_isAppCacheEnabled, m_isCSPEnabled, m_templateCount));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 viewport->description = description; 535 viewport->description = description;
535 viewport->set = true; 536 viewport->set = true;
536 } 537 }
537 FloatSize initialViewport(mediaValues->deviceWidth(), mediaValues->deviceHei ght()); 538 FloatSize initialViewport(mediaValues->deviceWidth(), mediaValues->deviceHei ght());
538 PageScaleConstraints constraints = description.resolve(initialViewport, docu mentParameters->defaultViewportMinWidth); 539 PageScaleConstraints constraints = description.resolve(initialViewport, docu mentParameters->defaultViewportMinWidth);
539 mediaValues->overrideViewportDimensions(constraints.layoutSize.width(), cons traints.layoutSize.height()); 540 mediaValues->overrideViewportDimensions(constraints.layoutSize.width(), cons traints.layoutSize.height());
540 } 541 }
541 542
542 static void handleMetaReferrer(const String& attributeValue, CachedDocumentParam eters* documentParameters, CSSPreloadScanner* cssScanner) 543 static void handleMetaReferrer(const String& attributeValue, CachedDocumentParam eters* documentParameters, CSSPreloadScanner* cssScanner)
543 { 544 {
544 if (attributeValue.isEmpty() || attributeValue.isNull() || !SecurityPolicy:: referrerPolicyFromString(attributeValue, &documentParameters->referrerPolicy)) { 545 ReferrerPolicy metaReferrerPolicy = ReferrerPolicyDefault;
545 documentParameters->referrerPolicy = ReferrerPolicyDefault; 546 if (!attributeValue.isEmpty() && !attributeValue.isNull() && SecurityPolicy: :referrerPolicyFromString(attributeValue, &metaReferrerPolicy)) {
547 documentParameters->referrerPolicy = metaReferrerPolicy;
546 } 548 }
547 cssScanner->setReferrerPolicy(documentParameters->referrerPolicy); 549 cssScanner->setReferrerPolicy(documentParameters->referrerPolicy);
548 } 550 }
549 551
550 template <typename Token> 552 template <typename Token>
551 static void handleMetaNameAttribute(const Token& token, CachedDocumentParameters * documentParameters, MediaValuesCached* mediaValues, CSSPreloadScanner* cssScan ner, ViewportDescriptionWrapper* viewport) 553 static void handleMetaNameAttribute(const Token& token, CachedDocumentParameters * documentParameters, MediaValuesCached* mediaValues, CSSPreloadScanner* cssScan ner, ViewportDescriptionWrapper* viewport)
552 { 554 {
553 const typename Token::Attribute* nameAttribute = token.getAttributeItem(name Attr); 555 const typename Token::Attribute* nameAttribute = token.getAttributeItem(name Attr);
554 if (!nameAttribute) 556 if (!nameAttribute)
555 return; 557 return;
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 794
793 CachedDocumentParameters::CachedDocumentParameters(Document* document) 795 CachedDocumentParameters::CachedDocumentParameters(Document* document)
794 { 796 {
795 ASSERT(isMainThread()); 797 ASSERT(isMainThread());
796 ASSERT(document); 798 ASSERT(document);
797 doHtmlPreloadScanning = !document->settings() || document->settings()->doHtm lPreloadScanning(); 799 doHtmlPreloadScanning = !document->settings() || document->settings()->doHtm lPreloadScanning();
798 doDocumentWritePreloadScanning = doHtmlPreloadScanning && document->frame() && document->frame()->isMainFrame(); 800 doDocumentWritePreloadScanning = doHtmlPreloadScanning && document->frame() && document->frame()->isMainFrame();
799 defaultViewportMinWidth = document->viewportDefaultMinWidth(); 801 defaultViewportMinWidth = document->viewportDefaultMinWidth();
800 viewportMetaZeroValuesQuirk = document->settings() && document->settings()-> viewportMetaZeroValuesQuirk(); 802 viewportMetaZeroValuesQuirk = document->settings() && document->settings()-> viewportMetaZeroValuesQuirk();
801 viewportMetaEnabled = document->settings() && document->settings()->viewport MetaEnabled(); 803 viewportMetaEnabled = document->settings() && document->settings()->viewport MetaEnabled();
802 referrerPolicy = ReferrerPolicyDefault; 804 referrerPolicy = document->getReferrerPolicy();
803 } 805 }
804 806
805 } // namespace blink 807 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698