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 17 matching lines...) Expand all Loading... |
28 #include "config.h" | 28 #include "config.h" |
29 #include "core/html/parser/HTMLPreloadScanner.h" | 29 #include "core/html/parser/HTMLPreloadScanner.h" |
30 | 30 |
31 #include "core/HTMLNames.h" | 31 #include "core/HTMLNames.h" |
32 #include "core/InputTypeNames.h" | 32 #include "core/InputTypeNames.h" |
33 #include "core/css/MediaList.h" | 33 #include "core/css/MediaList.h" |
34 #include "core/css/MediaQueryEvaluator.h" | 34 #include "core/css/MediaQueryEvaluator.h" |
35 #include "core/css/MediaValuesCached.h" | 35 #include "core/css/MediaValuesCached.h" |
36 #include "core/css/parser/SizesAttributeParser.h" | 36 #include "core/css/parser/SizesAttributeParser.h" |
37 #include "core/dom/Document.h" | 37 #include "core/dom/Document.h" |
| 38 #include "core/fetch/IntegrityMetadata.h" |
38 #include "core/frame/Settings.h" | 39 #include "core/frame/Settings.h" |
| 40 #include "core/frame/SubresourceIntegrity.h" |
| 41 #include "core/html/CrossOriginAttribute.h" |
39 #include "core/html/HTMLImageElement.h" | 42 #include "core/html/HTMLImageElement.h" |
40 #include "core/html/HTMLMetaElement.h" | 43 #include "core/html/HTMLMetaElement.h" |
41 #include "core/html/LinkRelAttribute.h" | 44 #include "core/html/LinkRelAttribute.h" |
42 #include "core/html/parser/HTMLParserIdioms.h" | 45 #include "core/html/parser/HTMLParserIdioms.h" |
43 #include "core/html/parser/HTMLSrcsetParser.h" | 46 #include "core/html/parser/HTMLSrcsetParser.h" |
44 #include "core/html/parser/HTMLTokenizer.h" | 47 #include "core/html/parser/HTMLTokenizer.h" |
45 #include "platform/RuntimeEnabledFeatures.h" | 48 #include "platform/RuntimeEnabledFeatures.h" |
46 #include "platform/TraceEvent.h" | 49 #include "platform/TraceEvent.h" |
47 #include "wtf/MainThread.h" | 50 #include "wtf/MainThread.h" |
48 | 51 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 resourceWidth.isSet = true; | 200 resourceWidth.isSet = true; |
198 } | 201 } |
199 | 202 |
200 // The element's 'referrerpolicy' attribute (if present) takes precedenc
e over the document's referrer policy. | 203 // The element's 'referrerpolicy' attribute (if present) takes precedenc
e over the document's referrer policy. |
201 ReferrerPolicy referrerPolicy = (m_referrerPolicy != ReferrerPolicyDefau
lt && RuntimeEnabledFeatures::referrerPolicyAttributeEnabled()) ? m_referrerPoli
cy : documentReferrerPolicy; | 204 ReferrerPolicy referrerPolicy = (m_referrerPolicy != ReferrerPolicyDefau
lt && RuntimeEnabledFeatures::referrerPolicyAttributeEnabled()) ? m_referrerPoli
cy : documentReferrerPolicy; |
202 OwnPtr<PreloadRequest> request = PreloadRequest::create(initiatorFor(m_t
agImpl), position, m_urlToLoad, predictedBaseURL, resourceType(), referrerPolicy
, resourceWidth, clientHintsPreferences, requestType); | 205 OwnPtr<PreloadRequest> request = PreloadRequest::create(initiatorFor(m_t
agImpl), position, m_urlToLoad, predictedBaseURL, resourceType(), referrerPolicy
, resourceWidth, clientHintsPreferences, requestType); |
203 if (isCORSEnabled()) | 206 if (isCORSEnabled()) |
204 request->setCrossOriginEnabled(allowStoredCredentials()); | 207 request->setCrossOriginEnabled(allowStoredCredentials()); |
205 request->setCharset(charset()); | 208 request->setCharset(charset()); |
206 request->setDefer(m_defer); | 209 request->setDefer(m_defer); |
| 210 request->setIntegrityMetadata(m_integrityMetadata); |
207 return request.release(); | 211 return request.release(); |
208 } | 212 } |
209 | 213 |
210 private: | 214 private: |
211 template<typename NameType> | 215 template<typename NameType> |
212 void processScriptAttribute(const NameType& attributeName, const String& att
ributeValue) | 216 void processScriptAttribute(const NameType& attributeName, const String& att
ributeValue) |
213 { | 217 { |
214 // FIXME - Don't set crossorigin multiple times. | 218 // FIXME - Don't set crossorigin multiple times. |
215 if (match(attributeName, srcAttr)) | 219 if (match(attributeName, srcAttr)) |
216 setUrlToLoad(attributeValue, DisallowURLReplacement); | 220 setUrlToLoad(attributeValue, DisallowURLReplacement); |
217 else if (match(attributeName, crossoriginAttr)) | 221 else if (match(attributeName, crossoriginAttr)) |
218 setCrossOriginAllowed(attributeValue); | 222 setCrossOriginAllowed(attributeValue); |
219 else if (match(attributeName, asyncAttr)) | 223 else if (match(attributeName, asyncAttr)) |
220 setDefer(FetchRequest::LazyLoad); | 224 setDefer(FetchRequest::LazyLoad); |
221 else if (match(attributeName, deferAttr)) | 225 else if (match(attributeName, deferAttr)) |
222 setDefer(FetchRequest::LazyLoad); | 226 setDefer(FetchRequest::LazyLoad); |
| 227 else if (match(attributeName, integrityAttr)) |
| 228 SubresourceIntegrity::parseIntegrityAttribute(attributeValue, m_inte
grityMetadata); |
223 } | 229 } |
224 | 230 |
225 template<typename NameType> | 231 template<typename NameType> |
226 void processImgAttribute(const NameType& attributeName, const String& attrib
uteValue) | 232 void processImgAttribute(const NameType& attributeName, const String& attrib
uteValue) |
227 { | 233 { |
228 if (match(attributeName, srcAttr) && m_imgSrcUrl.isNull()) { | 234 if (match(attributeName, srcAttr) && m_imgSrcUrl.isNull()) { |
229 m_imgSrcUrl = attributeValue; | 235 m_imgSrcUrl = attributeValue; |
230 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePi
xelRatio(), m_sourceSize, attributeValue, m_srcsetImageCandidate), AllowURLRepla
cement); | 236 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePi
xelRatio(), m_sourceSize, attributeValue, m_srcsetImageCandidate), AllowURLRepla
cement); |
231 } else if (match(attributeName, crossoriginAttr)) { | 237 } else if (match(attributeName, crossoriginAttr)) { |
232 setCrossOriginAllowed(attributeValue); | 238 setCrossOriginAllowed(attributeValue); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 m_isCORSEnabled = true; | 393 m_isCORSEnabled = true; |
388 if (!corsSetting.isNull() && equalIgnoringCase(stripLeadingAndTrailingHT
MLSpaces(corsSetting), "use-credentials")) | 394 if (!corsSetting.isNull() && equalIgnoringCase(stripLeadingAndTrailingHT
MLSpaces(corsSetting), "use-credentials")) |
389 m_allowCredentials = AllowStoredCredentials; | 395 m_allowCredentials = AllowStoredCredentials; |
390 else | 396 else |
391 m_allowCredentials = DoNotAllowStoredCredentials; | 397 m_allowCredentials = DoNotAllowStoredCredentials; |
392 } | 398 } |
393 | 399 |
394 void setDefer(FetchRequest::DeferOption defer) | 400 void setDefer(FetchRequest::DeferOption defer) |
395 { | 401 { |
396 m_defer = defer; | 402 m_defer = defer; |
| 403 |
397 } | 404 } |
398 | 405 |
399 bool defer() const | 406 bool defer() const |
400 { | 407 { |
401 return m_defer; | 408 return m_defer; |
402 } | 409 } |
403 | 410 |
404 const StringImpl* m_tagImpl; | 411 const StringImpl* m_tagImpl; |
405 String m_urlToLoad; | 412 String m_urlToLoad; |
406 ImageCandidate m_srcsetImageCandidate; | 413 ImageCandidate m_srcsetImageCandidate; |
407 String m_charset; | 414 String m_charset; |
408 bool m_linkIsStyleSheet; | 415 bool m_linkIsStyleSheet; |
409 bool m_linkIsPreconnect; | 416 bool m_linkIsPreconnect; |
410 bool m_linkIsImport; | 417 bool m_linkIsImport; |
411 bool m_matchedMediaAttribute; | 418 bool m_matchedMediaAttribute; |
412 bool m_inputIsImage; | 419 bool m_inputIsImage; |
413 String m_imgSrcUrl; | 420 String m_imgSrcUrl; |
414 String m_srcsetAttributeValue; | 421 String m_srcsetAttributeValue; |
415 float m_sourceSize; | 422 float m_sourceSize; |
416 bool m_sourceSizeSet; | 423 bool m_sourceSizeSet; |
417 bool m_isCORSEnabled; | 424 bool m_isCORSEnabled; |
418 FetchRequest::DeferOption m_defer; | 425 FetchRequest::DeferOption m_defer; |
419 StoredCredentials m_allowCredentials; | 426 StoredCredentials m_allowCredentials; |
420 RefPtrWillBeMember<MediaValues> m_mediaValues; | 427 RefPtrWillBeMember<MediaValues> m_mediaValues; |
421 bool m_referrerPolicySet; | 428 bool m_referrerPolicySet; |
422 ReferrerPolicy m_referrerPolicy; | 429 ReferrerPolicy m_referrerPolicy; |
| 430 IntegrityMetadataSet m_integrityMetadata; |
423 }; | 431 }; |
424 | 432 |
425 TokenPreloadScanner::TokenPreloadScanner(const KURL& documentURL, PassOwnPtr<Cac
hedDocumentParameters> documentParameters) | 433 TokenPreloadScanner::TokenPreloadScanner(const KURL& documentURL, PassOwnPtr<Cac
hedDocumentParameters> documentParameters) |
426 : m_documentURL(documentURL) | 434 : m_documentURL(documentURL) |
427 , m_inStyle(false) | 435 , m_inStyle(false) |
428 , m_inPicture(false) | 436 , m_inPicture(false) |
429 , m_isAppCacheEnabled(false) | 437 , m_isAppCacheEnabled(false) |
430 , m_isCSPEnabled(false) | 438 , m_isCSPEnabled(false) |
431 , m_templateCount(0) | 439 , m_templateCount(0) |
432 , m_documentParameters(documentParameters) | 440 , m_documentParameters(documentParameters) |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 else | 678 else |
671 mediaValues = MediaValuesCached::create(*document); | 679 mediaValues = MediaValuesCached::create(*document); |
672 ASSERT(mediaValues->isSafeToSendToAnotherThread()); | 680 ASSERT(mediaValues->isSafeToSendToAnotherThread()); |
673 defaultViewportMinWidth = document->viewportDefaultMinWidth(); | 681 defaultViewportMinWidth = document->viewportDefaultMinWidth(); |
674 viewportMetaZeroValuesQuirk = document->settings() && document->settings()->
viewportMetaZeroValuesQuirk(); | 682 viewportMetaZeroValuesQuirk = document->settings() && document->settings()->
viewportMetaZeroValuesQuirk(); |
675 viewportMetaEnabled = document->settings() && document->settings()->viewport
MetaEnabled(); | 683 viewportMetaEnabled = document->settings() && document->settings()->viewport
MetaEnabled(); |
676 referrerPolicy = ReferrerPolicyDefault; | 684 referrerPolicy = ReferrerPolicyDefault; |
677 } | 685 } |
678 | 686 |
679 } | 687 } |
OLD | NEW |