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

Side by Side Diff: Source/core/loader/PingLoader.cpp

Issue 360233005: Replace 'ResourceRequest::TargetType' with 'ResourceRequest::RequestContext'. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 namespace WebCore { 56 namespace WebCore {
57 57
58 void PingLoader::loadImage(LocalFrame* frame, const KURL& url) 58 void PingLoader::loadImage(LocalFrame* frame, const KURL& url)
59 { 59 {
60 if (!frame->document()->securityOrigin()->canDisplay(url)) { 60 if (!frame->document()->securityOrigin()->canDisplay(url)) {
61 FrameLoader::reportLocalLoadFailed(frame, url.string()); 61 FrameLoader::reportLocalLoadFailed(frame, url.string());
62 return; 62 return;
63 } 63 }
64 64
65 ResourceRequest request(url); 65 ResourceRequest request(url);
66 request.setTargetType(ResourceRequest::TargetIsPing); 66 request.setRequestContext(ResourceRequest::PingContext);
67 request.setHTTPHeaderField("Cache-Control", "max-age=0"); 67 request.setHTTPHeaderField("Cache-Control", "max-age=0");
68 frame->loader().fetchContext().addAdditionalRequestHeaders(frame->document() , request, FetchSubresource); 68 frame->loader().fetchContext().addAdditionalRequestHeaders(frame->document() , request, FetchSubresource);
69 frame->loader().fetchContext().setFirstPartyForCookies(request); 69 frame->loader().fetchContext().setFirstPartyForCookies(request);
70 70
71 FetchInitiatorInfo initiatorInfo; 71 FetchInitiatorInfo initiatorInfo;
72 initiatorInfo.name = FetchInitiatorTypeNames::ping; 72 initiatorInfo.name = FetchInitiatorTypeNames::ping;
73 PingLoader::start(frame, request, initiatorInfo); 73 PingLoader::start(frame, request, initiatorInfo);
74 } 74 }
75 75
76 // http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#hyperl ink-auditing 76 // http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#hyperl ink-auditing
77 void PingLoader::sendLinkAuditPing(LocalFrame* frame, const KURL& pingURL, const KURL& destinationURL) 77 void PingLoader::sendLinkAuditPing(LocalFrame* frame, const KURL& pingURL, const KURL& destinationURL)
78 { 78 {
79 ResourceRequest request(pingURL); 79 ResourceRequest request(pingURL);
80 request.setTargetType(ResourceRequest::TargetIsPing); 80 request.setRequestContext(ResourceRequest::PingContext);
81 request.setHTTPMethod("POST"); 81 request.setHTTPMethod("POST");
82 request.setHTTPContentType("text/ping"); 82 request.setHTTPContentType("text/ping");
83 request.setHTTPBody(FormData::create("PING")); 83 request.setHTTPBody(FormData::create("PING"));
84 request.setHTTPHeaderField("Cache-Control", "max-age=0"); 84 request.setHTTPHeaderField("Cache-Control", "max-age=0");
85 frame->loader().fetchContext().addAdditionalRequestHeaders(frame->document() , request, FetchSubresource); 85 frame->loader().fetchContext().addAdditionalRequestHeaders(frame->document() , request, FetchSubresource);
86 frame->loader().fetchContext().setFirstPartyForCookies(request); 86 frame->loader().fetchContext().setFirstPartyForCookies(request);
87 87
88 RefPtr<SecurityOrigin> pingOrigin = SecurityOrigin::create(pingURL); 88 RefPtr<SecurityOrigin> pingOrigin = SecurityOrigin::create(pingURL);
89 // addAdditionalRequestHeaders() will have added a referrer for same origin requests, 89 // addAdditionalRequestHeaders() will have added a referrer for same origin requests,
90 // but the spec omits the referrer for same origin. 90 // but the spec omits the referrer for same origin.
91 if (frame->document()->securityOrigin()->isSameSchemeHostPort(pingOrigin.get ())) 91 if (frame->document()->securityOrigin()->isSameSchemeHostPort(pingOrigin.get ()))
92 request.clearHTTPReferrer(); 92 request.clearHTTPReferrer();
93 93
94 request.setHTTPHeaderField("Ping-To", AtomicString(destinationURL.string())) ; 94 request.setHTTPHeaderField("Ping-To", AtomicString(destinationURL.string())) ;
95 95
96 // Ping-From follows the same rules as the default referrer beahavior for su bresource requests. 96 // Ping-From follows the same rules as the default referrer beahavior for su bresource requests.
97 // FIXME: Should Ping-From obey ReferrerPolicy? 97 // FIXME: Should Ping-From obey ReferrerPolicy?
98 if (!SecurityPolicy::shouldHideReferrer(pingURL, frame->document()->url().st ring())) 98 if (!SecurityPolicy::shouldHideReferrer(pingURL, frame->document()->url().st ring()))
99 request.setHTTPHeaderField("Ping-From", AtomicString(frame->document()-> url().string())); 99 request.setHTTPHeaderField("Ping-From", AtomicString(frame->document()-> url().string()));
100 100
101 FetchInitiatorInfo initiatorInfo; 101 FetchInitiatorInfo initiatorInfo;
102 initiatorInfo.name = FetchInitiatorTypeNames::ping; 102 initiatorInfo.name = FetchInitiatorTypeNames::ping;
103 PingLoader::start(frame, request, initiatorInfo); 103 PingLoader::start(frame, request, initiatorInfo);
104 } 104 }
105 105
106 void PingLoader::sendViolationReport(LocalFrame* frame, const KURL& reportURL, P assRefPtr<FormData> report, ViolationReportType type) 106 void PingLoader::sendViolationReport(LocalFrame* frame, const KURL& reportURL, P assRefPtr<FormData> report, ViolationReportType type)
107 { 107 {
108 ResourceRequest request(reportURL); 108 ResourceRequest request(reportURL);
109 request.setTargetType(ResourceRequest::TargetIsSubresource); 109 request.setRequestContext(ResourceRequest::PingContext);
110 request.setHTTPMethod("POST"); 110 request.setHTTPMethod("POST");
111 request.setHTTPContentType(type == ContentSecurityPolicyViolationReport ? "a pplication/csp-report" : "application/json"); 111 request.setHTTPContentType(type == ContentSecurityPolicyViolationReport ? "a pplication/csp-report" : "application/json");
112 request.setHTTPBody(report); 112 request.setHTTPBody(report);
113 frame->loader().fetchContext().addAdditionalRequestHeaders(frame->document() , request, FetchSubresource); 113 frame->loader().fetchContext().addAdditionalRequestHeaders(frame->document() , request, FetchSubresource);
114 frame->loader().fetchContext().setFirstPartyForCookies(request); 114 frame->loader().fetchContext().setFirstPartyForCookies(request);
115 115
116 FetchInitiatorInfo initiatorInfo; 116 FetchInitiatorInfo initiatorInfo;
117 initiatorInfo.name = FetchInitiatorTypeNames::violationreport; 117 initiatorInfo.name = FetchInitiatorTypeNames::violationreport;
118 PingLoader::start(frame, request, initiatorInfo, SecurityOrigin::create(repo rtURL)->isSameSchemeHostPort(frame->document()->securityOrigin()) ? AllowStoredC redentials : DoNotAllowStoredCredentials); 118 PingLoader::start(frame, request, initiatorInfo, SecurityOrigin::create(repo rtURL)->isSameSchemeHostPort(frame->document()->securityOrigin()) ? AllowStoredC redentials : DoNotAllowStoredCredentials);
119 } 119 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 { 206 {
207 if (Page* page = this->page()) { 207 if (Page* page = this->page()) {
208 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Re sourceFinish", "data", InspectorResourceFinishEvent::data(m_identifier, 0, true) ); 208 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Re sourceFinish", "data", InspectorResourceFinishEvent::data(m_identifier, 0, true) );
209 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti meline migrates to tracing. 209 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti meline migrates to tracing.
210 InspectorInstrumentation::didFailLoading(page->deprecatedLocalMainFrame( ), m_identifier, ResourceError::cancelledError(m_url)); 210 InspectorInstrumentation::didFailLoading(page->deprecatedLocalMainFrame( ), m_identifier, ResourceError::cancelledError(m_url));
211 } 211 }
212 delete this; 212 delete this;
213 } 213 }
214 214
215 } 215 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698