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

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

Issue 2674973006: Move parsing of referrer policy header values to SecurityPolicy (Closed)
Patch Set: Created 3 years, 10 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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 m_srcsetAttributeValue); 319 m_srcsetAttributeValue);
320 setUrlToLoad(bestFitSourceForImageAttributes( 320 setUrlToLoad(bestFitSourceForImageAttributes(
321 m_mediaValues->devicePixelRatio(), m_sourceSize, 321 m_mediaValues->devicePixelRatio(), m_sourceSize,
322 m_imgSrcUrl, m_srcsetImageCandidate), 322 m_imgSrcUrl, m_srcsetImageCandidate),
323 AllowURLReplacement); 323 AllowURLReplacement);
324 } 324 }
325 } else if (!m_referrerPolicySet && 325 } else if (!m_referrerPolicySet &&
326 match(attributeName, referrerpolicyAttr) && 326 match(attributeName, referrerpolicyAttr) &&
327 !attributeValue.isNull()) { 327 !attributeValue.isNull()) {
328 m_referrerPolicySet = true; 328 m_referrerPolicySet = true;
329 SecurityPolicy::referrerPolicyFromStringWithLegacyKeywords( 329 SecurityPolicy::referrerPolicyFromString(
330 attributeValue, &m_referrerPolicy); 330 attributeValue, SupportReferrerPolicyLegacyKeywords,
331 &m_referrerPolicy);
331 } 332 }
332 } 333 }
333 334
334 template <typename NameType> 335 template <typename NameType>
335 void processLinkAttribute(const NameType& attributeName, 336 void processLinkAttribute(const NameType& attributeName,
336 const String& attributeValue) { 337 const String& attributeValue) {
337 // FIXME - Don't set rel/media/crossorigin multiple times. 338 // FIXME - Don't set rel/media/crossorigin multiple times.
338 if (match(attributeName, hrefAttr)) { 339 if (match(attributeName, hrefAttr)) {
339 setUrlToLoad(attributeValue, DisallowURLReplacement); 340 setUrlToLoad(attributeValue, DisallowURLReplacement);
340 } else if (match(attributeName, relAttr)) { 341 } else if (match(attributeName, relAttr)) {
(...skipping 11 matching lines...) Expand all
352 } else if (match(attributeName, nonceAttr)) { 353 } else if (match(attributeName, nonceAttr)) {
353 setNonce(attributeValue); 354 setNonce(attributeValue);
354 } else if (match(attributeName, asAttr)) { 355 } else if (match(attributeName, asAttr)) {
355 m_asAttributeValue = attributeValue.lower(); 356 m_asAttributeValue = attributeValue.lower();
356 } else if (match(attributeName, typeAttr)) { 357 } else if (match(attributeName, typeAttr)) {
357 m_typeAttributeValue = attributeValue; 358 m_typeAttributeValue = attributeValue;
358 } else if (!m_referrerPolicySet && 359 } else if (!m_referrerPolicySet &&
359 match(attributeName, referrerpolicyAttr) && 360 match(attributeName, referrerpolicyAttr) &&
360 !attributeValue.isNull()) { 361 !attributeValue.isNull()) {
361 m_referrerPolicySet = true; 362 m_referrerPolicySet = true;
362 SecurityPolicy::referrerPolicyFromString(attributeValue, 363 SecurityPolicy::referrerPolicyFromString(
363 &m_referrerPolicy); 364 attributeValue, DoNotSupportReferrerPolicyLegacyKeywords,
365 &m_referrerPolicy);
364 } 366 }
365 } 367 }
366 368
367 template <typename NameType> 369 template <typename NameType>
368 void processInputAttribute(const NameType& attributeName, 370 void processInputAttribute(const NameType& attributeName,
369 const String& attributeValue) { 371 const String& attributeValue) {
370 // FIXME - Don't set type multiple times. 372 // FIXME - Don't set type multiple times.
371 if (match(attributeName, srcAttr)) 373 if (match(attributeName, srcAttr))
372 setUrlToLoad(attributeValue, DisallowURLReplacement); 374 setUrlToLoad(attributeValue, DisallowURLReplacement);
373 else if (match(attributeName, typeAttr)) 375 else if (match(attributeName, typeAttr))
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 initialViewport, documentParameters->defaultViewportMinWidth); 643 initialViewport, documentParameters->defaultViewportMinWidth);
642 mediaValues->overrideViewportDimensions(constraints.layoutSize.width(), 644 mediaValues->overrideViewportDimensions(constraints.layoutSize.width(),
643 constraints.layoutSize.height()); 645 constraints.layoutSize.height());
644 } 646 }
645 647
646 static void handleMetaReferrer(const String& attributeValue, 648 static void handleMetaReferrer(const String& attributeValue,
647 CachedDocumentParameters* documentParameters, 649 CachedDocumentParameters* documentParameters,
648 CSSPreloadScanner* cssScanner) { 650 CSSPreloadScanner* cssScanner) {
649 ReferrerPolicy metaReferrerPolicy = ReferrerPolicyDefault; 651 ReferrerPolicy metaReferrerPolicy = ReferrerPolicyDefault;
650 if (!attributeValue.isEmpty() && !attributeValue.isNull() && 652 if (!attributeValue.isEmpty() && !attributeValue.isNull() &&
651 SecurityPolicy::referrerPolicyFromStringWithLegacyKeywords( 653 SecurityPolicy::referrerPolicyFromString(
652 attributeValue, &metaReferrerPolicy)) { 654 attributeValue, SupportReferrerPolicyLegacyKeywords,
655 &metaReferrerPolicy)) {
653 documentParameters->referrerPolicy = metaReferrerPolicy; 656 documentParameters->referrerPolicy = metaReferrerPolicy;
654 } 657 }
655 cssScanner->setReferrerPolicy(documentParameters->referrerPolicy); 658 cssScanner->setReferrerPolicy(documentParameters->referrerPolicy);
656 } 659 }
657 660
658 template <typename Token> 661 template <typename Token>
659 static void handleMetaNameAttribute( 662 static void handleMetaNameAttribute(
660 const Token& token, 663 const Token& token,
661 CachedDocumentParameters* documentParameters, 664 CachedDocumentParameters* documentParameters,
662 MediaValuesCached* mediaValues, 665 MediaValuesCached* mediaValues,
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 defaultViewportMinWidth = document->viewportDefaultMinWidth(); 925 defaultViewportMinWidth = document->viewportDefaultMinWidth();
923 viewportMetaZeroValuesQuirk = 926 viewportMetaZeroValuesQuirk =
924 document->settings() && 927 document->settings() &&
925 document->settings()->getViewportMetaZeroValuesQuirk(); 928 document->settings()->getViewportMetaZeroValuesQuirk();
926 viewportMetaEnabled = 929 viewportMetaEnabled =
927 document->settings() && document->settings()->getViewportMetaEnabled(); 930 document->settings() && document->settings()->getViewportMetaEnabled();
928 referrerPolicy = document->getReferrerPolicy(); 931 referrerPolicy = document->getReferrerPolicy();
929 } 932 }
930 933
931 } // namespace blink 934 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLLinkElement.cpp ('k') | third_party/WebKit/Source/platform/weborigin/SecurityPolicy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698