| 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 } | 236 } |
| 237 | 237 |
| 238 Resource::Type type; | 238 Resource::Type type; |
| 239 if (!resourceType(type)) | 239 if (!resourceType(type)) |
| 240 return nullptr; | 240 return nullptr; |
| 241 | 241 |
| 242 // The element's 'referrerpolicy' attribute (if present) takes precedenc
e over the document's referrer policy. | 242 // The element's 'referrerpolicy' attribute (if present) takes precedenc
e over the document's referrer policy. |
| 243 ReferrerPolicy referrerPolicy = (m_referrerPolicy != ReferrerPolicyDefau
lt) ? m_referrerPolicy : documentReferrerPolicy; | 243 ReferrerPolicy referrerPolicy = (m_referrerPolicy != ReferrerPolicyDefau
lt) ? m_referrerPolicy : documentReferrerPolicy; |
| 244 std::unique_ptr<PreloadRequest> request = PreloadRequest::create(initiat
orFor(m_tagImpl), position, m_urlToLoad, predictedBaseURL, type, referrerPolicy,
resourceWidth, clientHintsPreferences, requestType); | 244 std::unique_ptr<PreloadRequest> request = PreloadRequest::create(initiat
orFor(m_tagImpl), position, m_urlToLoad, predictedBaseURL, type, referrerPolicy,
resourceWidth, clientHintsPreferences, requestType); |
| 245 request->setCrossOrigin(m_crossOrigin); | 245 request->setCrossOrigin(m_crossOrigin); |
| 246 request->setNonce(m_nonce); |
| 246 request->setCharset(charset()); | 247 request->setCharset(charset()); |
| 247 request->setDefer(m_defer); | 248 request->setDefer(m_defer); |
| 248 request->setIntegrityMetadata(m_integrityMetadata); | 249 request->setIntegrityMetadata(m_integrityMetadata); |
| 249 return request; | 250 return request; |
| 250 } | 251 } |
| 251 | 252 |
| 252 private: | 253 private: |
| 253 template<typename NameType> | 254 template<typename NameType> |
| 254 void processScriptAttribute(const NameType& attributeName, const String& att
ributeValue) | 255 void processScriptAttribute(const NameType& attributeName, const String& att
ributeValue) |
| 255 { | 256 { |
| 256 // FIXME - Don't set crossorigin multiple times. | 257 // FIXME - Don't set crossorigin multiple times. |
| 257 if (match(attributeName, srcAttr)) | 258 if (match(attributeName, srcAttr)) |
| 258 setUrlToLoad(attributeValue, DisallowURLReplacement); | 259 setUrlToLoad(attributeValue, DisallowURLReplacement); |
| 259 else if (match(attributeName, crossoriginAttr)) | 260 else if (match(attributeName, crossoriginAttr)) |
| 260 setCrossOrigin(attributeValue); | 261 setCrossOrigin(attributeValue); |
| 262 else if (match(attributeName, nonceAttr)) |
| 263 setNonce(attributeValue); |
| 261 else if (match(attributeName, asyncAttr)) | 264 else if (match(attributeName, asyncAttr)) |
| 262 setDefer(FetchRequest::LazyLoad); | 265 setDefer(FetchRequest::LazyLoad); |
| 263 else if (match(attributeName, deferAttr)) | 266 else if (match(attributeName, deferAttr)) |
| 264 setDefer(FetchRequest::LazyLoad); | 267 setDefer(FetchRequest::LazyLoad); |
| 265 // Note that only scripts need to have the integrity metadata set on | 268 // Note that only scripts need to have the integrity metadata set on |
| 266 // preloads. This is because script resources fetches, and only script | 269 // preloads. This is because script resources fetches, and only script |
| 267 // resource fetches, need to re-request resources if a cached version | 270 // resource fetches, need to re-request resources if a cached version |
| 268 // has different metadata (including empty) from the metadata on the | 271 // has different metadata (including empty) from the metadata on the |
| 269 // request. See the comment before the call to | 272 // request. See the comment before the call to |
| 270 // mustRefetchDueToIntegrityMismatch() in | 273 // mustRefetchDueToIntegrityMismatch() in |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 } else if (match(attributeName, relAttr)) { | 311 } else if (match(attributeName, relAttr)) { |
| 309 LinkRelAttribute rel(attributeValue); | 312 LinkRelAttribute rel(attributeValue); |
| 310 m_linkIsStyleSheet = rel.isStyleSheet() && !rel.isAlternate() && rel
.getIconType() == InvalidIcon && !rel.isDNSPrefetch(); | 313 m_linkIsStyleSheet = rel.isStyleSheet() && !rel.isAlternate() && rel
.getIconType() == InvalidIcon && !rel.isDNSPrefetch(); |
| 311 m_linkIsPreconnect = rel.isPreconnect(); | 314 m_linkIsPreconnect = rel.isPreconnect(); |
| 312 m_linkIsPreload = rel.isLinkPreload(); | 315 m_linkIsPreload = rel.isLinkPreload(); |
| 313 m_linkIsImport = rel.isImport(); | 316 m_linkIsImport = rel.isImport(); |
| 314 } else if (match(attributeName, mediaAttr)) { | 317 } else if (match(attributeName, mediaAttr)) { |
| 315 m_matched &= mediaAttributeMatches(*m_mediaValues, attributeValue); | 318 m_matched &= mediaAttributeMatches(*m_mediaValues, attributeValue); |
| 316 } else if (match(attributeName, crossoriginAttr)) { | 319 } else if (match(attributeName, crossoriginAttr)) { |
| 317 setCrossOrigin(attributeValue); | 320 setCrossOrigin(attributeValue); |
| 321 } else if (match(attributeName, nonceAttr)) { |
| 322 setNonce(attributeValue); |
| 318 } else if (match(attributeName, asAttr)) { | 323 } else if (match(attributeName, asAttr)) { |
| 319 m_asAttributeValue = attributeValue; | 324 m_asAttributeValue = attributeValue; |
| 320 } else if (match(attributeName, typeAttr)) { | 325 } else if (match(attributeName, typeAttr)) { |
| 321 m_matched &= MIMETypeRegistry::isSupportedStyleSheetMIMEType(Content
Type(attributeValue).type()); | 326 m_matched &= MIMETypeRegistry::isSupportedStyleSheetMIMEType(Content
Type(attributeValue).type()); |
| 322 } | 327 } |
| 323 } | 328 } |
| 324 | 329 |
| 325 template<typename NameType> | 330 template<typename NameType> |
| 326 void processInputAttribute(const NameType& attributeName, const String& attr
ibuteValue) | 331 void processInputAttribute(const NameType& attributeName, const String& attr
ibuteValue) |
| 327 { | 332 { |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 if (match(m_tagImpl, inputTag) && !m_inputIsImage) | 446 if (match(m_tagImpl, inputTag) && !m_inputIsImage) |
| 442 return false; | 447 return false; |
| 443 return true; | 448 return true; |
| 444 } | 449 } |
| 445 | 450 |
| 446 void setCrossOrigin(const String& corsSetting) | 451 void setCrossOrigin(const String& corsSetting) |
| 447 { | 452 { |
| 448 m_crossOrigin = crossOriginAttributeValue(corsSetting); | 453 m_crossOrigin = crossOriginAttributeValue(corsSetting); |
| 449 } | 454 } |
| 450 | 455 |
| 456 void setNonce(const String& nonce) |
| 457 { |
| 458 m_nonce = nonce; |
| 459 } |
| 460 |
| 451 void setDefer(FetchRequest::DeferOption defer) | 461 void setDefer(FetchRequest::DeferOption defer) |
| 452 { | 462 { |
| 453 m_defer = defer; | 463 m_defer = defer; |
| 454 } | 464 } |
| 455 | 465 |
| 456 bool defer() const | 466 bool defer() const |
| 457 { | 467 { |
| 458 return m_defer; | 468 return m_defer; |
| 459 } | 469 } |
| 460 | 470 |
| 461 const StringImpl* m_tagImpl; | 471 const StringImpl* m_tagImpl; |
| 462 String m_urlToLoad; | 472 String m_urlToLoad; |
| 463 ImageCandidate m_srcsetImageCandidate; | 473 ImageCandidate m_srcsetImageCandidate; |
| 464 String m_charset; | 474 String m_charset; |
| 465 bool m_linkIsStyleSheet; | 475 bool m_linkIsStyleSheet; |
| 466 bool m_linkIsPreconnect; | 476 bool m_linkIsPreconnect; |
| 467 bool m_linkIsPreload; | 477 bool m_linkIsPreload; |
| 468 bool m_linkIsImport; | 478 bool m_linkIsImport; |
| 469 bool m_matched; | 479 bool m_matched; |
| 470 bool m_inputIsImage; | 480 bool m_inputIsImage; |
| 471 String m_imgSrcUrl; | 481 String m_imgSrcUrl; |
| 472 String m_srcsetAttributeValue; | 482 String m_srcsetAttributeValue; |
| 473 String m_asAttributeValue; | 483 String m_asAttributeValue; |
| 474 float m_sourceSize; | 484 float m_sourceSize; |
| 475 bool m_sourceSizeSet; | 485 bool m_sourceSizeSet; |
| 476 FetchRequest::DeferOption m_defer; | 486 FetchRequest::DeferOption m_defer; |
| 477 CrossOriginAttributeValue m_crossOrigin; | 487 CrossOriginAttributeValue m_crossOrigin; |
| 488 String m_nonce; |
| 478 Member<MediaValuesCached> m_mediaValues; | 489 Member<MediaValuesCached> m_mediaValues; |
| 479 bool m_referrerPolicySet; | 490 bool m_referrerPolicySet; |
| 480 ReferrerPolicy m_referrerPolicy; | 491 ReferrerPolicy m_referrerPolicy; |
| 481 IntegrityMetadataSet m_integrityMetadata; | 492 IntegrityMetadataSet m_integrityMetadata; |
| 482 }; | 493 }; |
| 483 | 494 |
| 484 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) |
| 485 : m_documentURL(documentURL) | 496 : m_documentURL(documentURL) |
| 486 , m_inStyle(false) | 497 , m_inStyle(false) |
| 487 , m_inPicture(false) | 498 , m_inPicture(false) |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 ASSERT(document); | 820 ASSERT(document); |
| 810 doHtmlPreloadScanning = !document->settings() || document->settings()->doHtm
lPreloadScanning(); | 821 doHtmlPreloadScanning = !document->settings() || document->settings()->doHtm
lPreloadScanning(); |
| 811 doDocumentWritePreloadScanning = doHtmlPreloadScanning && document->frame()
&& document->frame()->isMainFrame(); | 822 doDocumentWritePreloadScanning = doHtmlPreloadScanning && document->frame()
&& document->frame()->isMainFrame(); |
| 812 defaultViewportMinWidth = document->viewportDefaultMinWidth(); | 823 defaultViewportMinWidth = document->viewportDefaultMinWidth(); |
| 813 viewportMetaZeroValuesQuirk = document->settings() && document->settings()->
viewportMetaZeroValuesQuirk(); | 824 viewportMetaZeroValuesQuirk = document->settings() && document->settings()->
viewportMetaZeroValuesQuirk(); |
| 814 viewportMetaEnabled = document->settings() && document->settings()->viewport
MetaEnabled(); | 825 viewportMetaEnabled = document->settings() && document->settings()->viewport
MetaEnabled(); |
| 815 referrerPolicy = document->getReferrerPolicy(); | 826 referrerPolicy = document->getReferrerPolicy(); |
| 816 } | 827 } |
| 817 | 828 |
| 818 } // namespace blink | 829 } // namespace blink |
| OLD | NEW |