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 LinkHeader header(headerValue); | |
135 if (!header.valid() || header.url().isEmpty() || header.rel().isEmpty()) | |
136 return false; | |
137 LinkRelAttribute relAttribute(header.rel()); | |
Mike West
2015/02/06 12:22:06
Can you add a test (or FIXME) for multiple link he
| |
138 KURL url = document->completeURL(header.url()); | |
139 dnsPrefetchIfNeeded(relAttribute, url, *document); | |
140 | |
141 // FIXME: Add more supported headers as needed. | |
142 return true; | |
143 } | |
144 | |
145 bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const AtomicStri ng& crossOriginMode, const String& type, const KURL& href, Document& document) | |
146 { | |
147 dnsPrefetchIfNeeded(relAttribute, href, document); | |
128 | 148 |
129 if (relAttribute.isPreconnect() && href.isValid()) { | 149 if (relAttribute.isPreconnect() && href.isValid()) { |
130 preconnect(href); | 150 preconnect(href); |
131 } | 151 } |
132 | 152 |
133 // FIXME(crbug.com/323096): Should take care of import. | 153 // FIXME(crbug.com/323096): Should take care of import. |
134 if ((relAttribute.isLinkPrefetch() || relAttribute.isLinkSubresource() || re lAttribute.isTransitionExitingStylesheet()) && href.isValid() && document.frame( )) { | 154 if ((relAttribute.isLinkPrefetch() || relAttribute.isLinkSubresource() || re lAttribute.isTransitionExitingStylesheet()) && href.isValid() && document.frame( )) { |
135 if (!m_client->shouldLoadLink()) | 155 if (!m_client->shouldLoadLink()) |
136 return false; | 156 return false; |
137 Resource::Type type = relAttribute.isLinkSubresource() ? Resource::Link Subresource : Resource::LinkPrefetch; | 157 Resource::Type type = relAttribute.isLinkSubresource() ? Resource::Link Subresource : Resource::LinkPrefetch; |
(...skipping 27 matching lines...) Expand all Loading... | |
165 m_prerender.clear(); | 185 m_prerender.clear(); |
166 } | 186 } |
167 } | 187 } |
168 | 188 |
169 void LinkLoader::trace(Visitor* visitor) | 189 void LinkLoader::trace(Visitor* visitor) |
170 { | 190 { |
171 visitor->trace(m_prerender); | 191 visitor->trace(m_prerender); |
172 } | 192 } |
173 | 193 |
174 } | 194 } |
OLD | NEW |