Index: third_party/WebKit/Source/core/loader/PingLoader.cpp |
diff --git a/third_party/WebKit/Source/core/loader/PingLoader.cpp b/third_party/WebKit/Source/core/loader/PingLoader.cpp |
index 956cc975a14c432b310e98ef0777481f61f21a14..90b2a070e1f176639c3677ffa73c17da156f4394 100644 |
--- a/third_party/WebKit/Source/core/loader/PingLoader.cpp |
+++ b/third_party/WebKit/Source/core/loader/PingLoader.cpp |
@@ -220,6 +220,7 @@ class PingLoaderImpl : public GarbageCollectedFinalized<PingLoaderImpl>, |
String m_url; |
unsigned long m_identifier; |
SelfKeepAlive<PingLoaderImpl> m_keepAlive; |
+ AtomicString m_initiator; |
bool m_isBeacon; |
@@ -237,6 +238,7 @@ PingLoaderImpl::PingLoaderImpl(LocalFrame* frame, |
m_url(request.url()), |
m_identifier(createUniqueIdentifier()), |
m_keepAlive(this), |
+ m_initiator(initiator), |
m_isBeacon(isBeacon), |
m_origin(frame->document()->getSecurityOrigin()), |
m_corsMode(IsCORSEnabled) { |
@@ -290,42 +292,47 @@ void PingLoaderImpl::dispose() { |
bool PingLoaderImpl::willFollowRedirect( |
WebURLRequest& passedNewRequest, |
const WebURLResponse& passedRedirectResponse) { |
- if (!m_isBeacon) |
- return true; |
- |
- if (m_corsMode == NotCORSEnabled) |
- return true; |
- |
- DCHECK(passedNewRequest.allowStoredCredentials()); |
- |
- ResourceRequest& newRequest(passedNewRequest.toMutableResourceRequest()); |
- const ResourceResponse& redirectResponse( |
- passedRedirectResponse.toResourceResponse()); |
- |
- DCHECK(!newRequest.isNull()); |
- DCHECK(!redirectResponse.isNull()); |
- |
- String errorDescription; |
- ResourceLoaderOptions options; |
- // TODO(tyoshino): Save updated data in options.securityOrigin and pass it |
- // on the next time. |
- if (!CrossOriginAccessControl::handleRedirect( |
- m_origin, newRequest, redirectResponse, AllowStoredCredentials, |
- options, errorDescription)) { |
- if (m_frame) { |
- if (m_frame->document()) { |
- m_frame->document()->addConsoleMessage(ConsoleMessage::create( |
- JSMessageSource, ErrorMessageLevel, errorDescription)); |
+ if (m_isBeacon && m_corsMode == IsCORSEnabled) { |
+ DCHECK(passedNewRequest.allowStoredCredentials()); |
+ |
+ ResourceRequest& newRequest(passedNewRequest.toMutableResourceRequest()); |
+ const ResourceResponse& redirectResponse( |
+ passedRedirectResponse.toResourceResponse()); |
+ |
+ DCHECK(!newRequest.isNull()); |
+ DCHECK(!redirectResponse.isNull()); |
+ |
+ String errorDescription; |
+ ResourceLoaderOptions options; |
+ // TODO(tyoshino): Save updated data in options.securityOrigin and pass it |
+ // on the next time. |
+ if (!CrossOriginAccessControl::handleRedirect( |
+ m_origin, newRequest, redirectResponse, AllowStoredCredentials, |
+ options, errorDescription)) { |
+ if (m_frame) { |
+ if (m_frame->document()) { |
+ m_frame->document()->addConsoleMessage(ConsoleMessage::create( |
+ JSMessageSource, ErrorMessageLevel, errorDescription)); |
+ } |
} |
- } |
- // Cancel the load and self destruct. |
- dispose(); |
+ // Cancel the load and self destruct. |
+ dispose(); |
- return false; |
+ return false; |
+ } |
} |
// FIXME: http://crbug.com/427429 is needed to correctly propagate updates of |
// Origin: following this successful redirect. |
+ if (m_frame && m_frame->document()) { |
allada
2016/12/20 02:35:54
nit: I am not sure about code style for this area,
ahmetemirercin
2016/12/20 07:09:07
It seems line 312 is result of this refactoring bu
|
+ FetchInitiatorInfo initiatorInfo; |
+ initiatorInfo.name = m_initiator; |
+ FetchContext& fetchContext = m_frame->document()->fetcher()->context(); |
+ fetchContext.dispatchWillSendRequest( |
+ m_identifier, passedNewRequest.toMutableResourceRequest(), |
+ passedRedirectResponse.toResourceResponse(), initiatorInfo); |
+ } |
+ |
return true; |
} |