Chromium Code Reviews| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 if (match(m_tagImpl, sourceTag) && m_matchedMediaAttribute && pictureDat a.sourceURL.isEmpty()) { | 166 if (match(m_tagImpl, sourceTag) && m_matchedMediaAttribute && pictureDat a.sourceURL.isEmpty()) { |
| 167 pictureData.sourceURL = m_srcsetImageCandidate.toString(); | 167 pictureData.sourceURL = m_srcsetImageCandidate.toString(); |
| 168 pictureData.sourceSizeSet = m_sourceSizeSet; | 168 pictureData.sourceSizeSet = m_sourceSizeSet; |
| 169 pictureData.sourceSize = m_sourceSize; | 169 pictureData.sourceSize = m_sourceSize; |
| 170 pictureData.picked = true; | 170 pictureData.picked = true; |
| 171 } else if (match(m_tagImpl, imgTag) && !pictureData.sourceURL.isEmpty()) { | 171 } else if (match(m_tagImpl, imgTag) && !pictureData.sourceURL.isEmpty()) { |
| 172 setUrlToLoad(pictureData.sourceURL, AllowURLReplacement); | 172 setUrlToLoad(pictureData.sourceURL, AllowURLReplacement); |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 | 175 |
| 176 PassOwnPtr<PreloadRequest> createPreloadRequest(const KURL& predictedBaseURL , const SegmentedString& source, const ClientHintsPreferences& clientHintsPrefer ences, const PictureData& pictureData) | 176 PassOwnPtr<PreloadRequest> createPreloadRequest(const KURL& predictedBaseURL , const SegmentedString& source, const ClientHintsPreferences& clientHintsPrefer ences, const PictureData& pictureData, const ReferrerPolicy& referrerPolicy) |
| 177 { | 177 { |
| 178 PreloadRequest::RequestType requestType = PreloadRequest::RequestTypePre load; | 178 PreloadRequest::RequestType requestType = PreloadRequest::RequestTypePre load; |
| 179 if (shouldPreconnect()) | 179 if (shouldPreconnect()) |
| 180 requestType = PreloadRequest::RequestTypePreconnect; | 180 requestType = PreloadRequest::RequestTypePreconnect; |
| 181 else if (!shouldPreload() || !m_matchedMediaAttribute) | 181 else if (!shouldPreload() || !m_matchedMediaAttribute) |
| 182 return nullptr; | 182 return nullptr; |
| 183 | 183 |
| 184 TextPosition position = TextPosition(source.currentLine(), source.curren tColumn()); | 184 TextPosition position = TextPosition(source.currentLine(), source.curren tColumn()); |
| 185 FetchRequest::ResourceWidth resourceWidth; | 185 FetchRequest::ResourceWidth resourceWidth; |
| 186 float sourceSize = m_sourceSize; | 186 float sourceSize = m_sourceSize; |
| 187 bool sourceSizeSet = m_sourceSizeSet; | 187 bool sourceSizeSet = m_sourceSizeSet; |
| 188 if (pictureData.picked) { | 188 if (pictureData.picked) { |
| 189 sourceSizeSet = pictureData.sourceSizeSet; | 189 sourceSizeSet = pictureData.sourceSizeSet; |
| 190 sourceSize = pictureData.sourceSize; | 190 sourceSize = pictureData.sourceSize; |
| 191 } | 191 } |
| 192 if (sourceSizeSet) { | 192 if (sourceSizeSet) { |
| 193 resourceWidth.width = sourceSize; | 193 resourceWidth.width = sourceSize; |
| 194 resourceWidth.isSet = true; | 194 resourceWidth.isSet = true; |
| 195 } | 195 } |
| 196 | 196 |
| 197 OwnPtr<PreloadRequest> request = PreloadRequest::create(initiatorFor(m_t agImpl), position, m_urlToLoad, predictedBaseURL, resourceType(), resourceWidth, clientHintsPreferences, requestType); | 197 OwnPtr<PreloadRequest> request = PreloadRequest::create(initiatorFor(m_t agImpl), position, m_urlToLoad, predictedBaseURL, resourceType(), referrerPolicy , resourceWidth, clientHintsPreferences, requestType); |
| 198 if (isCORSEnabled()) | 198 if (isCORSEnabled()) |
| 199 request->setCrossOriginEnabled(allowStoredCredentials()); | 199 request->setCrossOriginEnabled(allowStoredCredentials()); |
| 200 request->setCharset(charset()); | 200 request->setCharset(charset()); |
| 201 request->setDefer(m_defer); | 201 request->setDefer(m_defer); |
| 202 return request.release(); | 202 return request.release(); |
| 203 } | 203 } |
| 204 | 204 |
| 205 private: | 205 private: |
| 206 template<typename NameType> | 206 template<typename NameType> |
| 207 void processScriptAttribute(const NameType& attributeName, const String& att ributeValue) | 207 void processScriptAttribute(const NameType& attributeName, const String& att ributeValue) |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 466 return; | 466 return; |
| 467 ViewportDescription description(ViewportDescription::ViewportMeta); | 467 ViewportDescription description(ViewportDescription::ViewportMeta); |
| 468 HTMLMetaElement::getViewportDescriptionFromContentAttribute(attributeValue, description, nullptr, documentParameters->viewportMetaZeroValuesQuirk); | 468 HTMLMetaElement::getViewportDescriptionFromContentAttribute(attributeValue, description, nullptr, documentParameters->viewportMetaZeroValuesQuirk); |
| 469 FloatSize initialViewport(documentParameters->mediaValues->viewportHeight(), documentParameters->mediaValues->viewportWidth()); | 469 FloatSize initialViewport(documentParameters->mediaValues->viewportHeight(), documentParameters->mediaValues->viewportWidth()); |
| 470 PageScaleConstraints constraints = description.resolve(initialViewport, docu mentParameters->defaultViewportMinWidth); | 470 PageScaleConstraints constraints = description.resolve(initialViewport, docu mentParameters->defaultViewportMinWidth); |
| 471 MediaValuesCached* cachedMediaValues = static_cast<MediaValuesCached*>(docum entParameters->mediaValues.get()); | 471 MediaValuesCached* cachedMediaValues = static_cast<MediaValuesCached*>(docum entParameters->mediaValues.get()); |
| 472 cachedMediaValues->setViewportHeight(constraints.layoutSize.height()); | 472 cachedMediaValues->setViewportHeight(constraints.layoutSize.height()); |
| 473 cachedMediaValues->setViewportWidth(constraints.layoutSize.width()); | 473 cachedMediaValues->setViewportWidth(constraints.layoutSize.width()); |
| 474 } | 474 } |
| 475 | 475 |
| 476 template<typename Token> | 476 template <typename Token> |
| 477 void TokenPreloadScanner::scanCommon(const Token& token, const SegmentedString& source, PreloadRequestStream& requests) | 477 void TokenPreloadScanner::scanCommon(const Token& token, const SegmentedString& source, PreloadRequestStream& requests) |
| 478 { | 478 { |
| 479 if (!m_documentParameters->doHtmlPreloadScanning) | 479 if (!m_documentParameters->doHtmlPreloadScanning) |
| 480 return; | 480 return; |
| 481 | 481 |
| 482 // Disable preload for documents with AppCache. | 482 // Disable preload for documents with AppCache. |
| 483 if (m_isAppCacheEnabled) | 483 if (m_isAppCacheEnabled) |
| 484 return; | 484 return; |
| 485 | 485 |
| 486 // http://crbug.com/434230 Disable preload for documents with CSP <meta> tag s | 486 // http://crbug.com/434230 Disable preload for documents with CSP <meta> tag s |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 547 } | 547 } |
| 548 return; | 548 return; |
| 549 } | 549 } |
| 550 const typename Token::Attribute* nameAttribute = token.getAttributeI tem(nameAttr); | 550 const typename Token::Attribute* nameAttribute = token.getAttributeI tem(nameAttr); |
| 551 if (nameAttribute && equalIgnoringCase(String(nameAttribute->value), "viewport")) { | 551 if (nameAttribute && equalIgnoringCase(String(nameAttribute->value), "viewport")) { |
| 552 const typename Token::Attribute* contentAttribute = token.getAtt ributeItem(contentAttr); | 552 const typename Token::Attribute* contentAttribute = token.getAtt ributeItem(contentAttr); |
| 553 if (contentAttribute) | 553 if (contentAttribute) |
| 554 handleMetaViewport(String(contentAttribute->value), m_docume ntParameters.get()); | 554 handleMetaViewport(String(contentAttribute->value), m_docume ntParameters.get()); |
| 555 return; | 555 return; |
| 556 } | 556 } |
| 557 if (nameAttribute && equalIgnoringCase(String(nameAttribute->value), "referrer")) { | |
| 558 const typename Token::Attribute* contentAttribute = token.getAtt ributeItem(contentAttr); | |
| 559 if (contentAttribute) { | |
| 560 const String contentAttributeValue(contentAttribute->value); | |
| 561 if (contentAttributeValue.isEmpty() || contentAttributeValue .isNull() || !SecurityPolicy::referrerPolicyFromString(contentAttributeValue, &m _documentParameters->referrerPolicy)) { | |
| 562 m_documentParameters->referrerPolicy = ReferrerPolicyDef ault; | |
| 563 } | |
| 564 m_cssScanner.setReferrerPolicy(m_documentParameters->referre rPolicy); | |
|
Yoav Weiss
2015/07/15 08:14:47
Could you split that part into a helper function?
estark
2015/07/15 21:58:56
Done.
| |
| 565 } | |
| 566 } | |
| 557 } | 567 } |
| 558 | 568 |
| 559 if (match(tagImpl, pictureTag)) { | 569 if (match(tagImpl, pictureTag)) { |
| 560 m_inPicture = true; | 570 m_inPicture = true; |
| 561 m_pictureData = PictureData(); | 571 m_pictureData = PictureData(); |
| 562 return; | 572 return; |
| 563 } | 573 } |
| 564 | 574 |
| 565 StartTagScanner scanner(tagImpl, m_documentParameters->mediaValues); | 575 StartTagScanner scanner(tagImpl, m_documentParameters->mediaValues); |
| 566 scanner.processAttributes(token.attributes()); | 576 scanner.processAttributes(token.attributes()); |
| 567 if (m_inPicture) | 577 if (m_inPicture) |
| 568 scanner.handlePictureSourceURL(m_pictureData); | 578 scanner.handlePictureSourceURL(m_pictureData); |
| 569 OwnPtr<PreloadRequest> request = scanner.createPreloadRequest(m_predicte dBaseElementURL, source, m_clientHintsPreferences, m_pictureData); | 579 OwnPtr<PreloadRequest> request = scanner.createPreloadRequest(m_predicte dBaseElementURL, source, m_clientHintsPreferences, m_pictureData, m_documentPara meters->referrerPolicy); |
| 570 if (request) | 580 if (request) |
| 571 requests.append(request.release()); | 581 requests.append(request.release()); |
| 572 return; | 582 return; |
| 573 } | 583 } |
| 574 default: { | 584 default: { |
| 575 return; | 585 return; |
| 576 } | 586 } |
| 577 } | 587 } |
| 578 } | 588 } |
| 579 | 589 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 630 ASSERT(document); | 640 ASSERT(document); |
| 631 doHtmlPreloadScanning = !document->settings() || document->settings()->doHtm lPreloadScanning(); | 641 doHtmlPreloadScanning = !document->settings() || document->settings()->doHtm lPreloadScanning(); |
| 632 if (givenMediaValues) | 642 if (givenMediaValues) |
| 633 mediaValues = givenMediaValues; | 643 mediaValues = givenMediaValues; |
| 634 else | 644 else |
| 635 mediaValues = MediaValuesCached::create(*document); | 645 mediaValues = MediaValuesCached::create(*document); |
| 636 ASSERT(mediaValues->isSafeToSendToAnotherThread()); | 646 ASSERT(mediaValues->isSafeToSendToAnotherThread()); |
| 637 defaultViewportMinWidth = document->viewportDefaultMinWidth(); | 647 defaultViewportMinWidth = document->viewportDefaultMinWidth(); |
| 638 viewportMetaZeroValuesQuirk = document->settings() && document->settings()-> viewportMetaZeroValuesQuirk(); | 648 viewportMetaZeroValuesQuirk = document->settings() && document->settings()-> viewportMetaZeroValuesQuirk(); |
| 639 viewportMetaEnabled = document->settings() && document->settings()->viewport MetaEnabled(); | 649 viewportMetaEnabled = document->settings() && document->settings()->viewport MetaEnabled(); |
| 650 referrerPolicy = ReferrerPolicyDefault; | |
| 640 } | 651 } |
| 641 | 652 |
| 642 } | 653 } |
| OLD | NEW |