Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / core / html / parser / PreloadRequest.cpp
blob5e7b3b83e7287f8c34757f4cb44a01e9a1c44e0c
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "config.h"
6 #include "core/html/parser/PreloadRequest.h"
8 #include "core/dom/Document.h"
9 #include "core/fetch/FetchInitiatorInfo.h"
11 namespace blink {
13 bool PreloadRequest::isSafeToSendToAnotherThread() const
15 return m_initiatorName.isSafeToSendToAnotherThread()
16 && m_charset.isSafeToSendToAnotherThread()
17 && m_resourceURL.isSafeToSendToAnotherThread()
18 && m_baseURL.isSafeToSendToAnotherThread();
21 KURL PreloadRequest::completeURL(Document* document)
23 return document->completeURLWithOverride(m_resourceURL, m_baseURL.isEmpty() ? document->url() : m_baseURL);
26 FetchRequest PreloadRequest::resourceRequest(Document* document)
28 ASSERT(isMainThread());
29 FetchInitiatorInfo initiatorInfo;
30 initiatorInfo.name = AtomicString(m_initiatorName);
31 initiatorInfo.position = m_initiatorPosition;
32 ResourceRequest resourceRequest(completeURL(document));
33 resourceRequest.setHTTPReferrer(SecurityPolicy::generateReferrer(m_referrerPolicy, resourceRequest.url(), document->outgoingReferrer()));
34 FetchRequest request(resourceRequest, initiatorInfo);
36 if (m_resourceType == Resource::ImportResource) {
37 SecurityOrigin* securityOrigin = document->contextDocument()->securityOrigin();
38 bool sameOrigin = securityOrigin->canRequest(request.url());
39 request.setCrossOriginAccessControl(securityOrigin,
40 sameOrigin ? AllowStoredCredentials : DoNotAllowStoredCredentials,
41 ClientDidNotRequestCredentials);
44 if (m_isCORSEnabled)
45 request.setCrossOriginAccessControl(document->securityOrigin(), m_allowCredentials);
47 request.setDefer(m_defer);
48 request.setResourceWidth(m_resourceWidth);
49 request.clientHintsPreferences().updateFrom(m_clientHintsPreferences);
51 return request;