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

Side by Side Diff: Source/core/fetch/ResourceLoader.cpp

Issue 196043002: HTML Imports: Send credentials for same origin requests (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Landing again with another fix Created 6 years, 9 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
« no previous file with comments | « Source/core/fetch/ResourceLoader.h ('k') | Source/core/html/HTMLLinkElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved.
3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com) 3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 m_deferredRequest = ResourceRequest(); 114 m_deferredRequest = ResourceRequest();
115 } 115 }
116 116
117 void ResourceLoader::init(const ResourceRequest& passedRequest) 117 void ResourceLoader::init(const ResourceRequest& passedRequest)
118 { 118 {
119 ResourceRequest request(passedRequest); 119 ResourceRequest request(passedRequest);
120 m_host->willSendRequest(m_resource->identifier(), request, ResourceResponse( ), m_options.initiatorInfo); 120 m_host->willSendRequest(m_resource->identifier(), request, ResourceResponse( ), m_options.initiatorInfo);
121 request.setReportLoadTiming(true); 121 request.setReportLoadTiming(true);
122 ASSERT(m_state != Terminated); 122 ASSERT(m_state != Terminated);
123 ASSERT(!request.isNull()); 123 ASSERT(!request.isNull());
124 m_originalRequest = m_request = request; 124 m_originalRequest = m_request = applyOptions(request);
125 m_resource->updateRequest(request); 125 m_resource->updateRequest(request);
126 m_host->didInitializeResourceLoader(this); 126 m_host->didInitializeResourceLoader(this);
127 } 127 }
128 128
129 void ResourceLoader::start() 129 void ResourceLoader::start()
130 { 130 {
131 ASSERT(!m_loader); 131 ASSERT(!m_loader);
132 ASSERT(!m_request.isNull()); 132 ASSERT(!m_request.isNull());
133 ASSERT(m_deferredRequest.isNull()); 133 ASSERT(m_deferredRequest.isNull());
134 134
(...skipping 11 matching lines...) Expand all
146 146
147 if (m_state == Terminated) 147 if (m_state == Terminated)
148 return; 148 return;
149 149
150 RELEASE_ASSERT(m_connectionState == ConnectionStateNew); 150 RELEASE_ASSERT(m_connectionState == ConnectionStateNew);
151 m_connectionState = ConnectionStateStarted; 151 m_connectionState = ConnectionStateStarted;
152 152
153 m_loader = adoptPtr(blink::Platform::current()->createURLLoader()); 153 m_loader = adoptPtr(blink::Platform::current()->createURLLoader());
154 ASSERT(m_loader); 154 ASSERT(m_loader);
155 blink::WrappedResourceRequest wrappedRequest(m_request); 155 blink::WrappedResourceRequest wrappedRequest(m_request);
156 wrappedRequest.setAllowStoredCredentials(m_options.allowCredentials == Allow StoredCredentials);
157 m_loader->loadAsynchronously(wrappedRequest, this); 156 m_loader->loadAsynchronously(wrappedRequest, this);
158 } 157 }
159 158
160 void ResourceLoader::changeToSynchronous() 159 void ResourceLoader::changeToSynchronous()
161 { 160 {
162 ASSERT(m_options.synchronousPolicy == RequestAsynchronously); 161 ASSERT(m_options.synchronousPolicy == RequestAsynchronously);
163 ASSERT(m_loader); 162 ASSERT(m_loader);
164 m_loader->cancel(); 163 m_loader->cancel();
165 m_loader.clear(); 164 m_loader.clear();
166 m_request.setPriority(ResourceLoadPriorityHighest); 165 m_request.setPriority(ResourceLoadPriorityHighest);
167 m_connectionState = ConnectionStateNew; 166 m_connectionState = ConnectionStateNew;
168 requestSynchronously(); 167 requestSynchronously();
169 } 168 }
170 169
171 void ResourceLoader::setDefersLoading(bool defers) 170 void ResourceLoader::setDefersLoading(bool defers)
172 { 171 {
173 m_defersLoading = defers; 172 m_defersLoading = defers;
174 if (m_loader) 173 if (m_loader)
175 m_loader->setDefersLoading(defers); 174 m_loader->setDefersLoading(defers);
176 if (!defers && !m_deferredRequest.isNull()) { 175 if (!defers && !m_deferredRequest.isNull()) {
177 m_request = m_deferredRequest; 176 m_request = applyOptions(m_deferredRequest);
178 m_deferredRequest = ResourceRequest(); 177 m_deferredRequest = ResourceRequest();
179 start(); 178 start();
180 } 179 }
181 } 180 }
182 181
183 void ResourceLoader::didDownloadData(blink::WebURLLoader*, int length, int encod edDataLength) 182 void ResourceLoader::didDownloadData(blink::WebURLLoader*, int length, int encod edDataLength)
184 { 183 {
185 RefPtr<ResourceLoader> protect(this); 184 RefPtr<ResourceLoader> protect(this);
186 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse); 185 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse);
187 m_host->didDownloadData(m_resource, length, encodedDataLength); 186 m_host->didDownloadData(m_resource, length, encodedDataLength);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 if (m_state == Finishing) 255 if (m_state == Finishing)
257 m_resource->error(Resource::LoadError); 256 m_resource->error(Resource::LoadError);
258 if (m_state != Terminated) 257 if (m_state != Terminated)
259 releaseResources(); 258 releaseResources();
260 } 259 }
261 260
262 void ResourceLoader::willSendRequest(blink::WebURLLoader*, blink::WebURLRequest& passedRequest, const blink::WebURLResponse& passedRedirectResponse) 261 void ResourceLoader::willSendRequest(blink::WebURLLoader*, blink::WebURLRequest& passedRequest, const blink::WebURLResponse& passedRedirectResponse)
263 { 262 {
264 RefPtr<ResourceLoader> protect(this); 263 RefPtr<ResourceLoader> protect(this);
265 264
266 ResourceRequest& request(passedRequest.toMutableResourceRequest()); 265 ResourceRequest& request(applyOptions(passedRequest.toMutableResourceRequest ()));
267 ASSERT(!request.isNull()); 266 ASSERT(!request.isNull());
268 const ResourceResponse& redirectResponse(passedRedirectResponse.toResourceRe sponse()); 267 const ResourceResponse& redirectResponse(passedRedirectResponse.toResourceRe sponse());
269 ASSERT(!redirectResponse.isNull()); 268 ASSERT(!redirectResponse.isNull());
270 if (!m_host->canAccessRedirect(m_resource, request, redirectResponse, m_opti ons)) { 269 if (!m_host->canAccessRedirect(m_resource, request, redirectResponse, m_opti ons)) {
271 cancel(); 270 cancel();
272 return; 271 return;
273 } 272 }
274 273
274 applyOptions(request); // canAccessRedirect() can modify m_options so we sho uld re-apply it.
275 m_host->redirectReceived(m_resource, redirectResponse); 275 m_host->redirectReceived(m_resource, redirectResponse);
276 m_resource->willSendRequest(request, redirectResponse); 276 m_resource->willSendRequest(request, redirectResponse);
277 if (request.isNull() || m_state == Terminated) 277 if (request.isNull() || m_state == Terminated)
278 return; 278 return;
279 279
280 m_host->willSendRequest(m_resource->identifier(), request, redirectResponse, m_options.initiatorInfo); 280 m_host->willSendRequest(m_resource->identifier(), request, redirectResponse, m_options.initiatorInfo);
281 request.setReportLoadTiming(true); 281 request.setReportLoadTiming(true);
282 ASSERT(!request.isNull()); 282 ASSERT(!request.isNull());
283 m_resource->updateRequest(request); 283 m_resource->updateRequest(request);
284 m_request = request; 284 m_request = request;
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 ASSERT(loader); 449 ASSERT(loader);
450 450
451 RefPtr<ResourceLoader> protect(this); 451 RefPtr<ResourceLoader> protect(this);
452 RefPtr<ResourceLoaderHost> protectHost(m_host); 452 RefPtr<ResourceLoaderHost> protectHost(m_host);
453 ResourcePtr<Resource> protectResource(m_resource); 453 ResourcePtr<Resource> protectResource(m_resource);
454 454
455 RELEASE_ASSERT(m_connectionState == ConnectionStateNew); 455 RELEASE_ASSERT(m_connectionState == ConnectionStateNew);
456 m_connectionState = ConnectionStateStarted; 456 m_connectionState = ConnectionStateStarted;
457 457
458 blink::WrappedResourceRequest requestIn(m_request); 458 blink::WrappedResourceRequest requestIn(m_request);
459 requestIn.setAllowStoredCredentials(m_options.allowCredentials == AllowStore dCredentials);
460 blink::WebURLResponse responseOut; 459 blink::WebURLResponse responseOut;
461 responseOut.initialize(); 460 responseOut.initialize();
462 blink::WebURLError errorOut; 461 blink::WebURLError errorOut;
463 blink::WebData dataOut; 462 blink::WebData dataOut;
464 loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut); 463 loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut);
465 if (errorOut.reason) { 464 if (errorOut.reason) {
466 didFail(0, errorOut); 465 didFail(0, errorOut);
467 return; 466 return;
468 } 467 }
469 didReceiveResponse(0, responseOut); 468 didReceiveResponse(0, responseOut);
470 if (m_state == Terminated) 469 if (m_state == Terminated)
471 return; 470 return;
472 RefPtr<ResourceLoadInfo> resourceLoadInfo = responseOut.toResourceResponse() .resourceLoadInfo(); 471 RefPtr<ResourceLoadInfo> resourceLoadInfo = responseOut.toResourceResponse() .resourceLoadInfo();
473 int64 encodedDataLength = resourceLoadInfo ? resourceLoadInfo->encodedDataLe ngth : blink::WebURLLoaderClient::kUnknownEncodedDataLength; 472 int64 encodedDataLength = resourceLoadInfo ? resourceLoadInfo->encodedDataLe ngth : blink::WebURLLoaderClient::kUnknownEncodedDataLength;
474 m_host->didReceiveData(m_resource, dataOut.data(), dataOut.size(), encodedDa taLength); 473 m_host->didReceiveData(m_resource, dataOut.data(), dataOut.size(), encodedDa taLength);
475 m_resource->setResourceBuffer(dataOut); 474 m_resource->setResourceBuffer(dataOut);
476 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength); 475 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength);
477 } 476 }
478 477
478 ResourceRequest& ResourceLoader::applyOptions(ResourceRequest& request) const
479 {
480 request.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredC redentials);
481 return request;
479 } 482 }
483
484 }
OLDNEW
« no previous file with comments | « Source/core/fetch/ResourceLoader.h ('k') | Source/core/html/HTMLLinkElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698