| OLD | NEW |
| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 static void finishPingRequestInitialization(ResourceRequest& request, LocalFrame
* frame) | 61 static void finishPingRequestInitialization(ResourceRequest& request, LocalFrame
* frame) |
| 62 { | 62 { |
| 63 request.setRequestContext(WebURLRequest::RequestContextPing); | 63 request.setRequestContext(WebURLRequest::RequestContextPing); |
| 64 frame->document()->fetcher()->context().addAdditionalRequestHeaders(request,
FetchSubresource); | 64 frame->document()->fetcher()->context().addAdditionalRequestHeaders(request,
FetchSubresource); |
| 65 frame->document()->fetcher()->context().setFirstPartyForCookies(request); | 65 frame->document()->fetcher()->context().setFirstPartyForCookies(request); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void PingLoader::loadImage(LocalFrame* frame, const KURL& url) | 68 void PingLoader::loadImage(LocalFrame* frame, const KURL& url) |
| 69 { | 69 { |
| 70 if (!frame->document()->securityOrigin()->canDisplay(url)) { | 70 if (!frame->document()->getSecurityOrigin()->canDisplay(url)) { |
| 71 FrameLoader::reportLocalLoadFailed(frame, url.getString()); | 71 FrameLoader::reportLocalLoadFailed(frame, url.getString()); |
| 72 return; | 72 return; |
| 73 } | 73 } |
| 74 | 74 |
| 75 ResourceRequest request(url); | 75 ResourceRequest request(url); |
| 76 request.setHTTPHeaderField(HTTPNames::Cache_Control, "max-age=0"); | 76 request.setHTTPHeaderField(HTTPNames::Cache_Control, "max-age=0"); |
| 77 finishPingRequestInitialization(request, frame); | 77 finishPingRequestInitialization(request, frame); |
| 78 | 78 |
| 79 FetchInitiatorInfo initiatorInfo; | 79 FetchInitiatorInfo initiatorInfo; |
| 80 initiatorInfo.name = FetchInitiatorTypeNames::ping; | 80 initiatorInfo.name = FetchInitiatorTypeNames::ping; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 110 void PingLoader::sendViolationReport(LocalFrame* frame, const KURL& reportURL, P
assRefPtr<EncodedFormData> report, ViolationReportType type) | 110 void PingLoader::sendViolationReport(LocalFrame* frame, const KURL& reportURL, P
assRefPtr<EncodedFormData> report, ViolationReportType type) |
| 111 { | 111 { |
| 112 ResourceRequest request(reportURL); | 112 ResourceRequest request(reportURL); |
| 113 request.setHTTPMethod(HTTPNames::POST); | 113 request.setHTTPMethod(HTTPNames::POST); |
| 114 request.setHTTPContentType(type == ContentSecurityPolicyViolationReport ? "a
pplication/csp-report" : "application/json"); | 114 request.setHTTPContentType(type == ContentSecurityPolicyViolationReport ? "a
pplication/csp-report" : "application/json"); |
| 115 request.setHTTPBody(report); | 115 request.setHTTPBody(report); |
| 116 finishPingRequestInitialization(request, frame); | 116 finishPingRequestInitialization(request, frame); |
| 117 | 117 |
| 118 FetchInitiatorInfo initiatorInfo; | 118 FetchInitiatorInfo initiatorInfo; |
| 119 initiatorInfo.name = FetchInitiatorTypeNames::violationreport; | 119 initiatorInfo.name = FetchInitiatorTypeNames::violationreport; |
| 120 PingLoader::start(frame, request, initiatorInfo, SecurityOrigin::create(repo
rtURL)->isSameSchemeHostPort(frame->document()->securityOrigin()) ? AllowStoredC
redentials : DoNotAllowStoredCredentials); | 120 PingLoader::start(frame, request, initiatorInfo, SecurityOrigin::create(repo
rtURL)->isSameSchemeHostPort(frame->document()->getSecurityOrigin()) ? AllowStor
edCredentials : DoNotAllowStoredCredentials); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void PingLoader::start(LocalFrame* frame, ResourceRequest& request, const FetchI
nitiatorInfo& initiatorInfo, StoredCredentials credentialsAllowed) | 123 void PingLoader::start(LocalFrame* frame, ResourceRequest& request, const FetchI
nitiatorInfo& initiatorInfo, StoredCredentials credentialsAllowed) |
| 124 { | 124 { |
| 125 if (MixedContentChecker::shouldBlockFetch(frame, request, request.url())) | 125 if (MixedContentChecker::shouldBlockFetch(frame, request, request.url())) |
| 126 return; | 126 return; |
| 127 | 127 |
| 128 // Leak the ping loader, since it will kill itself as soon as it receives a
response. | 128 // Leak the ping loader, since it will kill itself as soon as it receives a
response. |
| 129 RefPtrWillBeRawPtr<PingLoader> loader = adoptRefWillBeNoop(new PingLoader(fr
ame, request, initiatorInfo, credentialsAllowed)); | 129 RefPtrWillBeRawPtr<PingLoader> loader = adoptRefWillBeNoop(new PingLoader(fr
ame, request, initiatorInfo, credentialsAllowed)); |
| 130 loader->ref(); | 130 loader->ref(); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 InspectorInstrumentation::didFailLoading(frame, m_identifier, ResourceError:
:cancelledError(m_url)); | 219 InspectorInstrumentation::didFailLoading(frame, m_identifier, ResourceError:
:cancelledError(m_url)); |
| 220 frame->console().didFailLoading(m_identifier, ResourceError::cancelledError(
m_url)); | 220 frame->console().didFailLoading(m_identifier, ResourceError::cancelledError(
m_url)); |
| 221 } | 221 } |
| 222 | 222 |
| 223 DEFINE_TRACE(PingLoader) | 223 DEFINE_TRACE(PingLoader) |
| 224 { | 224 { |
| 225 LocalFrameLifecycleObserver::trace(visitor); | 225 LocalFrameLifecycleObserver::trace(visitor); |
| 226 } | 226 } |
| 227 | 227 |
| 228 } // namespace blink | 228 } // namespace blink |
| OLD | NEW |