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

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

Issue 1196193005: Allow preload scanners to be disabled by Settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@minimaster
Patch Set: add unit test Created 5 years, 6 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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 FloatSize initialViewport(documentParameters->mediaValues->viewportHeight(), documentParameters->mediaValues->viewportWidth()); 471 FloatSize initialViewport(documentParameters->mediaValues->viewportHeight(), documentParameters->mediaValues->viewportWidth());
472 PageScaleConstraints constraints = description.resolve(initialViewport, docu mentParameters->defaultViewportMinWidth); 472 PageScaleConstraints constraints = description.resolve(initialViewport, docu mentParameters->defaultViewportMinWidth);
473 MediaValuesCached* cachedMediaValues = static_cast<MediaValuesCached*>(docum entParameters->mediaValues.get()); 473 MediaValuesCached* cachedMediaValues = static_cast<MediaValuesCached*>(docum entParameters->mediaValues.get());
474 cachedMediaValues->setViewportHeight(constraints.layoutSize.height()); 474 cachedMediaValues->setViewportHeight(constraints.layoutSize.height());
475 cachedMediaValues->setViewportWidth(constraints.layoutSize.width()); 475 cachedMediaValues->setViewportWidth(constraints.layoutSize.width());
476 } 476 }
477 477
478 template<typename Token> 478 template<typename Token>
479 void TokenPreloadScanner::scanCommon(const Token& token, const SegmentedString& source, PreloadRequestStream& requests) 479 void TokenPreloadScanner::scanCommon(const Token& token, const SegmentedString& source, PreloadRequestStream& requests)
480 { 480 {
481 if (!m_documentParameters->doHtmlPreloadScanning)
482 return;
483
481 // Disable preload for documents with AppCache. 484 // Disable preload for documents with AppCache.
482 if (m_isAppCacheEnabled) 485 if (m_isAppCacheEnabled)
483 return; 486 return;
484 487
485 // http://crbug.com/434230 Disable preload for documents with CSP <meta> tag s 488 // http://crbug.com/434230 Disable preload for documents with CSP <meta> tag s
486 if (m_isCSPEnabled) 489 if (m_isCSPEnabled)
487 return; 490 return;
488 491
489 switch (token.type()) { 492 switch (token.type()) {
490 case HTMLToken::Character: { 493 case HTMLToken::Character: {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 m_token.clear(); 623 m_token.clear();
621 } 624 }
622 625
623 preloader->takeAndPreload(requests); 626 preloader->takeAndPreload(requests);
624 } 627 }
625 628
626 CachedDocumentParameters::CachedDocumentParameters(Document* document, PassRefPt r<MediaValues> givenMediaValues) 629 CachedDocumentParameters::CachedDocumentParameters(Document* document, PassRefPt r<MediaValues> givenMediaValues)
627 { 630 {
628 ASSERT(isMainThread()); 631 ASSERT(isMainThread());
629 ASSERT(document); 632 ASSERT(document);
633 doHtmlPreloadScanning = !document->settings() || document->settings()->doHtm lPreloadScanning();
630 if (givenMediaValues) 634 if (givenMediaValues)
631 mediaValues = givenMediaValues; 635 mediaValues = givenMediaValues;
632 else 636 else
633 mediaValues = MediaValuesCached::create(*document); 637 mediaValues = MediaValuesCached::create(*document);
634 ASSERT(mediaValues->isSafeToSendToAnotherThread()); 638 ASSERT(mediaValues->isSafeToSendToAnotherThread());
635 defaultViewportMinWidth = document->viewportDefaultMinWidth(); 639 defaultViewportMinWidth = document->viewportDefaultMinWidth();
636 viewportMetaZeroValuesQuirk = document->settings() && document->settings()-> viewportMetaZeroValuesQuirk(); 640 viewportMetaZeroValuesQuirk = document->settings() && document->settings()-> viewportMetaZeroValuesQuirk();
637 viewportMetaEnabled = document->settings() && document->settings()->viewport MetaEnabled(); 641 viewportMetaEnabled = document->settings() && document->settings()->viewport MetaEnabled();
638 } 642 }
639 643
640 } 644 }
OLDNEW
« no previous file with comments | « Source/core/html/parser/HTMLPreloadScanner.h ('k') | Source/core/html/parser/HTMLPreloadScannerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698