| OLD | NEW |
| 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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 bool m_referrerPolicySet; | 490 bool m_referrerPolicySet; |
| 491 ReferrerPolicy m_referrerPolicy; | 491 ReferrerPolicy m_referrerPolicy; |
| 492 IntegrityMetadataSet m_integrityMetadata; | 492 IntegrityMetadataSet m_integrityMetadata; |
| 493 }; | 493 }; |
| 494 | 494 |
| 495 TokenPreloadScanner::TokenPreloadScanner(const KURL& documentURL, std::unique_pt
r<CachedDocumentParameters> documentParameters, const MediaValuesCached::MediaVa
luesCachedData& mediaValuesCachedData) | 495 TokenPreloadScanner::TokenPreloadScanner(const KURL& documentURL, std::unique_pt
r<CachedDocumentParameters> documentParameters, const MediaValuesCached::MediaVa
luesCachedData& mediaValuesCachedData) |
| 496 : m_documentURL(documentURL) | 496 : m_documentURL(documentURL) |
| 497 , m_inStyle(false) | 497 , m_inStyle(false) |
| 498 , m_inPicture(false) | 498 , m_inPicture(false) |
| 499 , m_inScript(false) | 499 , m_inScript(false) |
| 500 , m_isAppCacheEnabled(false) | |
| 501 , m_isCSPEnabled(false) | 500 , m_isCSPEnabled(false) |
| 502 , m_templateCount(0) | 501 , m_templateCount(0) |
| 503 , m_documentParameters(std::move(documentParameters)) | 502 , m_documentParameters(std::move(documentParameters)) |
| 504 , m_mediaValues(MediaValuesCached::create(mediaValuesCachedData)) | 503 , m_mediaValues(MediaValuesCached::create(mediaValuesCachedData)) |
| 505 , m_didRewind(false) | 504 , m_didRewind(false) |
| 506 { | 505 { |
| 507 ASSERT(m_documentParameters.get()); | 506 ASSERT(m_documentParameters.get()); |
| 508 ASSERT(m_mediaValues.get()); | 507 ASSERT(m_mediaValues.get()); |
| 509 m_cssScanner.setReferrerPolicy(m_documentParameters->referrerPolicy); | 508 m_cssScanner.setReferrerPolicy(m_documentParameters->referrerPolicy); |
| 510 } | 509 } |
| 511 | 510 |
| 512 TokenPreloadScanner::~TokenPreloadScanner() | 511 TokenPreloadScanner::~TokenPreloadScanner() |
| 513 { | 512 { |
| 514 } | 513 } |
| 515 | 514 |
| 516 TokenPreloadScannerCheckpoint TokenPreloadScanner::createCheckpoint() | 515 TokenPreloadScannerCheckpoint TokenPreloadScanner::createCheckpoint() |
| 517 { | 516 { |
| 518 TokenPreloadScannerCheckpoint checkpoint = m_checkpoints.size(); | 517 TokenPreloadScannerCheckpoint checkpoint = m_checkpoints.size(); |
| 519 m_checkpoints.append(Checkpoint(m_predictedBaseElementURL, m_inStyle, m_inSc
ript, m_isAppCacheEnabled, m_isCSPEnabled, m_templateCount)); | 518 m_checkpoints.append(Checkpoint(m_predictedBaseElementURL, m_inStyle, m_inSc
ript, m_isCSPEnabled, m_templateCount)); |
| 520 return checkpoint; | 519 return checkpoint; |
| 521 } | 520 } |
| 522 | 521 |
| 523 void TokenPreloadScanner::rewindTo(TokenPreloadScannerCheckpoint checkpointIndex
) | 522 void TokenPreloadScanner::rewindTo(TokenPreloadScannerCheckpoint checkpointIndex
) |
| 524 { | 523 { |
| 525 ASSERT(checkpointIndex < m_checkpoints.size()); // If this ASSERT fires, che
ckpointIndex is invalid. | 524 ASSERT(checkpointIndex < m_checkpoints.size()); // If this ASSERT fires, che
ckpointIndex is invalid. |
| 526 const Checkpoint& checkpoint = m_checkpoints[checkpointIndex]; | 525 const Checkpoint& checkpoint = m_checkpoints[checkpointIndex]; |
| 527 m_predictedBaseElementURL = checkpoint.predictedBaseElementURL; | 526 m_predictedBaseElementURL = checkpoint.predictedBaseElementURL; |
| 528 m_inStyle = checkpoint.inStyle; | 527 m_inStyle = checkpoint.inStyle; |
| 529 m_isAppCacheEnabled = checkpoint.isAppCacheEnabled; | |
| 530 m_isCSPEnabled = checkpoint.isCSPEnabled; | 528 m_isCSPEnabled = checkpoint.isCSPEnabled; |
| 531 m_templateCount = checkpoint.templateCount; | 529 m_templateCount = checkpoint.templateCount; |
| 532 | 530 |
| 533 m_didRewind = true; | 531 m_didRewind = true; |
| 534 m_inScript = checkpoint.inScript; | 532 m_inScript = checkpoint.inScript; |
| 535 | 533 |
| 536 m_cssScanner.reset(); | 534 m_cssScanner.reset(); |
| 537 m_checkpoints.clear(); | 535 m_checkpoints.clear(); |
| 538 } | 536 } |
| 539 | 537 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 } | 649 } |
| 652 return true; | 650 return true; |
| 653 } | 651 } |
| 654 | 652 |
| 655 template <typename Token> | 653 template <typename Token> |
| 656 void TokenPreloadScanner::scanCommon(const Token& token, const SegmentedString&
source, PreloadRequestStream& requests, ViewportDescriptionWrapper* viewport, bo
ol* likelyDocumentWriteScript) | 654 void TokenPreloadScanner::scanCommon(const Token& token, const SegmentedString&
source, PreloadRequestStream& requests, ViewportDescriptionWrapper* viewport, bo
ol* likelyDocumentWriteScript) |
| 657 { | 655 { |
| 658 if (!m_documentParameters->doHtmlPreloadScanning) | 656 if (!m_documentParameters->doHtmlPreloadScanning) |
| 659 return; | 657 return; |
| 660 | 658 |
| 661 // Disable preload for documents with AppCache. | |
| 662 if (m_isAppCacheEnabled) | |
| 663 return; | |
| 664 | |
| 665 // http://crbug.com/434230 Disable preload for documents with CSP <meta> tag
s | 659 // http://crbug.com/434230 Disable preload for documents with CSP <meta> tag
s |
| 666 if (m_isCSPEnabled) | 660 if (m_isCSPEnabled) |
| 667 return; | 661 return; |
| 668 | 662 |
| 669 switch (token.type()) { | 663 switch (token.type()) { |
| 670 case HTMLToken::Character: { | 664 case HTMLToken::Character: { |
| 671 if (m_inStyle) { | 665 if (m_inStyle) { |
| 672 m_cssScanner.scan(token.data(), source, requests, m_predictedBaseEle
mentURL); | 666 m_cssScanner.scan(token.data(), source, requests, m_predictedBaseEle
mentURL); |
| 673 } else if (m_inScript && likelyDocumentWriteScript && !m_didRewind) { | 667 } else if (m_inScript && likelyDocumentWriteScript && !m_didRewind) { |
| 674 // Don't mark scripts for evaluation if the preloader rewound to a | 668 // Don't mark scripts for evaluation if the preloader rewound to a |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 if (match(tagImpl, scriptTag)) { | 712 if (match(tagImpl, scriptTag)) { |
| 719 m_inScript = true; | 713 m_inScript = true; |
| 720 } | 714 } |
| 721 if (match(tagImpl, baseTag)) { | 715 if (match(tagImpl, baseTag)) { |
| 722 // The first <base> element is the one that wins. | 716 // The first <base> element is the one that wins. |
| 723 if (!m_predictedBaseElementURL.isEmpty()) | 717 if (!m_predictedBaseElementURL.isEmpty()) |
| 724 return; | 718 return; |
| 725 updatePredictedBaseURL(token); | 719 updatePredictedBaseURL(token); |
| 726 return; | 720 return; |
| 727 } | 721 } |
| 728 if (match(tagImpl, htmlTag) && token.getAttributeItem(manifestAttr)) { | |
| 729 m_isAppCacheEnabled = true; | |
| 730 return; | |
| 731 } | |
| 732 if (match(tagImpl, metaTag)) { | 722 if (match(tagImpl, metaTag)) { |
| 733 const typename Token::Attribute* equivAttribute = token.getAttribute
Item(http_equivAttr); | 723 const typename Token::Attribute* equivAttribute = token.getAttribute
Item(http_equivAttr); |
| 734 if (equivAttribute) { | 724 if (equivAttribute) { |
| 735 String equivAttributeValue(equivAttribute->value()); | 725 String equivAttributeValue(equivAttribute->value()); |
| 736 if (equalIgnoringCase(equivAttributeValue, "content-security-pol
icy")) { | 726 if (equalIgnoringCase(equivAttributeValue, "content-security-pol
icy")) { |
| 737 m_isCSPEnabled = true; | 727 m_isCSPEnabled = true; |
| 738 } else if (equalIgnoringCase(equivAttributeValue, "accept-ch"))
{ | 728 } else if (equalIgnoringCase(equivAttributeValue, "accept-ch"))
{ |
| 739 const typename Token::Attribute* contentAttribute = token.ge
tAttributeItem(contentAttr); | 729 const typename Token::Attribute* contentAttribute = token.ge
tAttributeItem(contentAttr); |
| 740 if (contentAttribute) | 730 if (contentAttribute) |
| 741 m_clientHintsPreferences.updateFromAcceptClientHintsHead
er(contentAttribute->value(), nullptr); | 731 m_clientHintsPreferences.updateFromAcceptClientHintsHead
er(contentAttribute->value(), nullptr); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 ASSERT(document); | 810 ASSERT(document); |
| 821 doHtmlPreloadScanning = !document->settings() || document->settings()->doHtm
lPreloadScanning(); | 811 doHtmlPreloadScanning = !document->settings() || document->settings()->doHtm
lPreloadScanning(); |
| 822 doDocumentWritePreloadScanning = doHtmlPreloadScanning && document->frame()
&& document->frame()->isMainFrame(); | 812 doDocumentWritePreloadScanning = doHtmlPreloadScanning && document->frame()
&& document->frame()->isMainFrame(); |
| 823 defaultViewportMinWidth = document->viewportDefaultMinWidth(); | 813 defaultViewportMinWidth = document->viewportDefaultMinWidth(); |
| 824 viewportMetaZeroValuesQuirk = document->settings() && document->settings()->
viewportMetaZeroValuesQuirk(); | 814 viewportMetaZeroValuesQuirk = document->settings() && document->settings()->
viewportMetaZeroValuesQuirk(); |
| 825 viewportMetaEnabled = document->settings() && document->settings()->viewport
MetaEnabled(); | 815 viewportMetaEnabled = document->settings() && document->settings()->viewport
MetaEnabled(); |
| 826 referrerPolicy = document->getReferrerPolicy(); | 816 referrerPolicy = document->getReferrerPolicy(); |
| 827 } | 817 } |
| 828 | 818 |
| 829 } // namespace blink | 819 } // namespace blink |
| OLD | NEW |