Index: Source/core/loader/LinkLoader.cpp |
diff --git a/Source/core/loader/LinkLoader.cpp b/Source/core/loader/LinkLoader.cpp |
index 3a928f86edaef55ee6664c857ebe889ae7ba490d..feb23bd3d900f82ec534be2fc9cd198251cf1b41 100644 |
--- a/Source/core/loader/LinkLoader.cpp |
+++ b/Source/core/loader/LinkLoader.cpp |
@@ -113,7 +113,7 @@ void LinkLoader::didSendDOMContentLoadedForPrerender() |
m_client->didSendDOMContentLoadedForLinkPrerender(); |
} |
-bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const AtomicString& crossOriginMode, const String& type, const KURL& href, Document& document) |
+static void dnsPrefetchIfNeeded(const LinkRelAttribute& relAttribute, const KURL& href, Document& document) |
{ |
if (relAttribute.isDNSPrefetch()) { |
Settings* settings = document.settings(); |
@@ -125,6 +125,28 @@ bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const AtomicStri |
prefetchDNS(href.host()); |
} |
} |
+} |
+ |
+bool LinkLoader::loadLinkFromHeader(const String& headerValue, Document* document) |
+{ |
+ if (!document) |
+ return false; |
+ LinkHeaderSet headerSet(headerValue); |
+ for (auto& header : headerSet) { |
+ if (!header.valid() || header.url().isEmpty() || header.rel().isEmpty()) |
+ return false; |
+ LinkRelAttribute relAttribute(header.rel()); |
+ KURL url = document->completeURL(header.url()); |
+ dnsPrefetchIfNeeded(relAttribute, url, *document); |
+ |
+ // FIXME: Add more supported headers as needed. |
+ } |
+ return true; |
+} |
+ |
+bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const AtomicString& crossOriginMode, const String& type, const KURL& href, Document& document) |
+{ |
+ dnsPrefetchIfNeeded(relAttribute, href, document); |
if (relAttribute.isPreconnect() && href.isValid()) { |
preconnect(href); |