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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 void LinkLoader::didSendLoadForPrerender() | 91 void LinkLoader::didSendLoadForPrerender() |
92 { | 92 { |
93 m_client->didSendLoadForLinkPrerender(); | 93 m_client->didSendLoadForLinkPrerender(); |
94 } | 94 } |
95 | 95 |
96 void LinkLoader::didSendDOMContentLoadedForPrerender() | 96 void LinkLoader::didSendDOMContentLoadedForPrerender() |
97 { | 97 { |
98 m_client->didSendDOMContentLoadedForLinkPrerender(); | 98 m_client->didSendDOMContentLoadedForLinkPrerender(); |
99 } | 99 } |
100 | 100 |
101 bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const String& ty
pe, const KURL& href, Document& document) | 101 bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const AtomicStri
ng& crossOriginMode, const String& type, const KURL& href, Document& document) |
102 { | 102 { |
103 if (relAttribute.isDNSPrefetch()) { | 103 if (relAttribute.isDNSPrefetch()) { |
104 Settings* settings = document.settings(); | 104 Settings* settings = document.settings(); |
105 // FIXME: The href attribute of the link element can be in "//hostname"
form, and we shouldn't attempt | 105 // FIXME: The href attribute of the link element can be in "//hostname"
form, and we shouldn't attempt |
106 // to complete that as URL <https://bugs.webkit.org/show_bug.cgi?id=4885
7>. | 106 // to complete that as URL <https://bugs.webkit.org/show_bug.cgi?id=4885
7>. |
107 if (settings && settings->dnsPrefetchingEnabled() && href.isValid() && !
href.isEmpty()) | 107 if (settings && settings->dnsPrefetchingEnabled() && href.isValid() && !
href.isEmpty()) |
108 prefetchDNS(href.host()); | 108 prefetchDNS(href.host()); |
109 } | 109 } |
110 | 110 |
111 // FIXME(crbug.com/323096): Should take care of import. | 111 // FIXME(crbug.com/323096): Should take care of import. |
112 if ((relAttribute.isLinkPrefetch() || relAttribute.isLinkSubresource()) && h
ref.isValid() && document.frame()) { | 112 if ((relAttribute.isLinkPrefetch() || relAttribute.isLinkSubresource()) && h
ref.isValid() && document.frame()) { |
113 if (!m_client->shouldLoadLink()) | 113 if (!m_client->shouldLoadLink()) |
114 return false; | 114 return false; |
115 Resource::Type type = relAttribute.isLinkSubresource() ? Resource::Link
Subresource : Resource::LinkPrefetch; | 115 Resource::Type type = relAttribute.isLinkSubresource() ? Resource::Link
Subresource : Resource::LinkPrefetch; |
116 FetchRequest linkRequest(ResourceRequest(document.completeURL(href)), Fe
tchInitiatorTypeNames::link); | 116 FetchRequest linkRequest(ResourceRequest(document.completeURL(href)), Fe
tchInitiatorTypeNames::link); |
| 117 if (!crossOriginMode.isNull()) |
| 118 linkRequest.setCrossOriginAccessControl(document.securityOrigin(), c
rossOriginMode); |
117 setResource(document.fetcher()->fetchLinkResource(type, linkRequest)); | 119 setResource(document.fetcher()->fetchLinkResource(type, linkRequest)); |
118 } | 120 } |
119 | 121 |
120 if (relAttribute.isLinkPrerender()) { | 122 if (relAttribute.isLinkPrerender()) { |
121 if (!m_prerender) { | 123 if (!m_prerender) { |
122 m_prerender = PrerenderHandle::create(document, this, href); | 124 m_prerender = PrerenderHandle::create(document, this, href); |
123 } else if (m_prerender->url() != href) { | 125 } else if (m_prerender->url() != href) { |
124 m_prerender->cancel(); | 126 m_prerender->cancel(); |
125 m_prerender = PrerenderHandle::create(document, this, href); | 127 m_prerender = PrerenderHandle::create(document, this, href); |
126 } | 128 } |
127 } else if (m_prerender) { | 129 } else if (m_prerender) { |
128 m_prerender->cancel(); | 130 m_prerender->cancel(); |
129 m_prerender.clear(); | 131 m_prerender.clear(); |
130 } | 132 } |
131 return true; | 133 return true; |
132 } | 134 } |
133 | 135 |
134 void LinkLoader::released() | 136 void LinkLoader::released() |
135 { | 137 { |
136 // Only prerenders need treatment here; other links either use the Resource
interface, or are notionally | 138 // Only prerenders need treatment here; other links either use the Resource
interface, or are notionally |
137 // atomic (dns prefetch). | 139 // atomic (dns prefetch). |
138 if (m_prerender) { | 140 if (m_prerender) { |
139 m_prerender->cancel(); | 141 m_prerender->cancel(); |
140 m_prerender.clear(); | 142 m_prerender.clear(); |
141 } | 143 } |
142 } | 144 } |
143 | 145 |
144 } | 146 } |
OLD | NEW |