| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 void LinkLoader::didSendLoadForPrerender() | 106 void LinkLoader::didSendLoadForPrerender() |
| 107 { | 107 { |
| 108 m_client->didSendLoadForLinkPrerender(); | 108 m_client->didSendLoadForLinkPrerender(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void LinkLoader::didSendDOMContentLoadedForPrerender() | 111 void LinkLoader::didSendDOMContentLoadedForPrerender() |
| 112 { | 112 { |
| 113 m_client->didSendDOMContentLoadedForLinkPrerender(); | 113 m_client->didSendDOMContentLoadedForLinkPrerender(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const AtomicStri
ng& crossOriginMode, const String& type, const KURL& href, Document& document) | 116 static void dnsPrefetchIfNeeded(const LinkRelAttribute& relAttribute, const KURL
& href, Document& document) |
| 117 { | 117 { |
| 118 if (relAttribute.isDNSPrefetch()) { | 118 if (relAttribute.isDNSPrefetch()) { |
| 119 Settings* settings = document.settings(); | 119 Settings* settings = document.settings(); |
| 120 // FIXME: The href attribute of the link element can be in "//hostname"
form, and we shouldn't attempt | 120 // FIXME: The href attribute of the link element can be in "//hostname"
form, and we shouldn't attempt |
| 121 // to complete that as URL <https://bugs.webkit.org/show_bug.cgi?id=4885
7>. | 121 // to complete that as URL <https://bugs.webkit.org/show_bug.cgi?id=4885
7>. |
| 122 if (settings && settings->dnsPrefetchingEnabled() && href.isValid() && !
href.isEmpty()) { | 122 if (settings && settings->dnsPrefetchingEnabled() && href.isValid() && !
href.isEmpty()) { |
| 123 if (settings->logDnsPrefetchAndPreconnect()) | 123 if (settings->logDnsPrefetchAndPreconnect()) |
| 124 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSo
urce, DebugMessageLevel, String("DNS prefetch triggered for " + href.host()))); | 124 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSo
urce, DebugMessageLevel, String("DNS prefetch triggered for " + href.host()))); |
| 125 prefetchDNS(href.host()); | 125 prefetchDNS(href.host()); |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 } |
| 129 |
| 130 bool LinkLoader::loadLinkFromHeader(const String& headerValue, Document* documen
t) |
| 131 { |
| 132 if (!document) |
| 133 return false; |
| 134 LinkHeaderSet headerSet(headerValue); |
| 135 for (auto& header : headerSet) { |
| 136 if (!header.valid() || header.url().isEmpty() || header.rel().isEmpty()) |
| 137 return false; |
| 138 LinkRelAttribute relAttribute(header.rel()); |
| 139 KURL url = document->completeURL(header.url()); |
| 140 dnsPrefetchIfNeeded(relAttribute, url, *document); |
| 141 |
| 142 // FIXME: Add more supported headers as needed. |
| 143 } |
| 144 return true; |
| 145 } |
| 146 |
| 147 bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const AtomicStri
ng& crossOriginMode, const String& type, const KURL& href, Document& document) |
| 148 { |
| 149 dnsPrefetchIfNeeded(relAttribute, href, document); |
| 128 | 150 |
| 129 if (relAttribute.isPreconnect() && href.isValid()) { | 151 if (relAttribute.isPreconnect() && href.isValid()) { |
| 130 preconnect(href); | 152 preconnect(href); |
| 131 } | 153 } |
| 132 | 154 |
| 133 // FIXME(crbug.com/323096): Should take care of import. | 155 // FIXME(crbug.com/323096): Should take care of import. |
| 134 if ((relAttribute.isLinkPrefetch() || relAttribute.isLinkSubresource() || re
lAttribute.isTransitionExitingStylesheet()) && href.isValid() && document.frame(
)) { | 156 if ((relAttribute.isLinkPrefetch() || relAttribute.isLinkSubresource() || re
lAttribute.isTransitionExitingStylesheet()) && href.isValid() && document.frame(
)) { |
| 135 if (!m_client->shouldLoadLink()) | 157 if (!m_client->shouldLoadLink()) |
| 136 return false; | 158 return false; |
| 137 Resource::Type type = relAttribute.isLinkSubresource() ? Resource::Link
Subresource : Resource::LinkPrefetch; | 159 Resource::Type type = relAttribute.isLinkSubresource() ? Resource::Link
Subresource : Resource::LinkPrefetch; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 165 m_prerender.clear(); | 187 m_prerender.clear(); |
| 166 } | 188 } |
| 167 } | 189 } |
| 168 | 190 |
| 169 void LinkLoader::trace(Visitor* visitor) | 191 void LinkLoader::trace(Visitor* visitor) |
| 170 { | 192 { |
| 171 visitor->trace(m_prerender); | 193 visitor->trace(m_prerender); |
| 172 } | 194 } |
| 173 | 195 |
| 174 } | 196 } |
| OLD | NEW |