Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(556)

Unified Diff: third_party/WebKit/Source/core/loader/PingLoader.cpp

Issue 2586063002: DevTools: Show redirects from navigator.sendBeacon() (Closed)
Patch Set: corrected m_frame->frame() Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/inspector-protocol/resources/ping-redirect.php ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ceaec4b00cf41083e5856bf88ef25bbc19c7738c..2a42b0e5e83fcbaa43b745caee13ab1b57619d1b 100644
--- a/third_party/WebKit/Source/core/loader/PingLoader.cpp
+++ b/third_party/WebKit/Source/core/loader/PingLoader.cpp
@@ -222,6 +222,7 @@ class PingLoaderImpl : public GarbageCollectedFinalized<PingLoaderImpl>,
String m_url;
unsigned long m_identifier;
SelfKeepAlive<PingLoaderImpl> m_keepAlive;
+ AtomicString m_initiator;
bool m_isBeacon;
@@ -239,6 +240,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) {
@@ -293,42 +295,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 (frame()) {
- if (frame()->document()) {
- 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 (frame()) {
+ if (frame()->document()) {
+ 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 (frame() && frame()->document()) {
+ FetchInitiatorInfo initiatorInfo;
+ initiatorInfo.name = m_initiator;
+ FetchContext& fetchContext = frame()->document()->fetcher()->context();
+ fetchContext.dispatchWillSendRequest(
+ m_identifier, passedNewRequest.toMutableResourceRequest(),
+ passedRedirectResponse.toResourceResponse(), initiatorInfo);
+ }
+
return true;
}
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/inspector-protocol/resources/ping-redirect.php ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698