| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 , m_originalRequest(req) | 102 , m_originalRequest(req) |
| 103 , m_substituteData(substituteData) | 103 , m_substituteData(substituteData) |
| 104 , m_request(req) | 104 , m_request(req) |
| 105 , m_isClientRedirect(false) | 105 , m_isClientRedirect(false) |
| 106 , m_replacesCurrentHistoryItem(false) | 106 , m_replacesCurrentHistoryItem(false) |
| 107 , m_dataReceived(false) | 107 , m_dataReceived(false) |
| 108 , m_navigationType(NavigationTypeOther) | 108 , m_navigationType(NavigationTypeOther) |
| 109 , m_documentLoadTiming(*this) | 109 , m_documentLoadTiming(*this) |
| 110 , m_timeOfLastDataReceived(0.0) | 110 , m_timeOfLastDataReceived(0.0) |
| 111 , m_applicationCacheHost(ApplicationCacheHost::create(this)) | 111 , m_applicationCacheHost(ApplicationCacheHost::create(this)) |
| 112 , m_wasBlockedAfterXFrameOptionsOrCSP(false) | 112 , m_wasBlockedAfterCSP(false) |
| 113 , m_state(NotStarted) | 113 , m_state(NotStarted) |
| 114 , m_inDataReceived(false) | 114 , m_inDataReceived(false) |
| 115 , m_dataBuffer(SharedBuffer::create()) | 115 , m_dataBuffer(SharedBuffer::create()) |
| 116 { | 116 { |
| 117 } | 117 } |
| 118 | 118 |
| 119 FrameLoader* DocumentLoader::frameLoader() const | 119 FrameLoader* DocumentLoader::frameLoader() const |
| 120 { | 120 { |
| 121 if (!m_frame) | 121 if (!m_frame) |
| 122 return nullptr; | 122 return nullptr; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 ASSERT(m_mainResource); | 270 ASSERT(m_mainResource); |
| 271 | 271 |
| 272 if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) { | 272 if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) { |
| 273 finishedLoading(m_mainResource->loadFinishTime()); | 273 finishedLoading(m_mainResource->loadFinishTime()); |
| 274 return; | 274 return; |
| 275 } | 275 } |
| 276 | 276 |
| 277 if (m_applicationCacheHost) | 277 if (m_applicationCacheHost) |
| 278 m_applicationCacheHost->failedLoadingMainResource(); | 278 m_applicationCacheHost->failedLoadingMainResource(); |
| 279 m_state = MainResourceDone; | 279 m_state = MainResourceDone; |
| 280 |
| 281 if (m_mainResource->resourceError().wasBlockedByResponse()) |
| 282 InspectorInstrumentation::canceledAfterReceivedResourceResponse(m_frame,
this, mainResourceIdentifier(), resource->response(), m_mainResource.get()); |
| 283 |
| 280 frameLoader()->loadFailed(this, m_mainResource->resourceError()); | 284 frameLoader()->loadFailed(this, m_mainResource->resourceError()); |
| 281 clearMainResourceHandle(); | 285 clearMainResourceHandle(); |
| 282 } | 286 } |
| 283 | 287 |
| 284 void DocumentLoader::finishedLoading(double finishTime) | 288 void DocumentLoader::finishedLoading(double finishTime) |
| 285 { | 289 { |
| 286 DCHECK(m_frame->loader().stateMachine()->creatingInitialEmptyDocument() | 290 DCHECK(m_frame->loader().stateMachine()->creatingInitialEmptyDocument() |
| 287 || !m_frame->page()->defersLoading() | 291 || !m_frame->page()->defersLoading() |
| 288 || InspectorInstrumentation::isDebuggerPaused(m_frame)); | 292 || InspectorInstrumentation::isDebuggerPaused(m_frame)); |
| 289 | 293 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 // Downloading is handled by the embedder, but we still get the initial | 369 // Downloading is handled by the embedder, but we still get the initial |
| 366 // response so that we can ignore it and clean up properly. | 370 // response so that we can ignore it and clean up properly. |
| 367 return false; | 371 return false; |
| 368 } | 372 } |
| 369 | 373 |
| 370 if (!canShowMIMEType(m_response.mimeType(), m_frame)) | 374 if (!canShowMIMEType(m_response.mimeType(), m_frame)) |
| 371 return false; | 375 return false; |
| 372 return true; | 376 return true; |
| 373 } | 377 } |
| 374 | 378 |
| 375 void DocumentLoader::cancelLoadAfterXFrameOptionsOrCSPDenied(const ResourceRespo
nse& response) | 379 void DocumentLoader::cancelLoadAfterCSPDenied(const ResourceResponse& response) |
| 376 { | 380 { |
| 377 InspectorInstrumentation::continueAfterXFrameOptionsDenied(m_frame, this, ma
inResourceIdentifier(), response, m_mainResource.get()); | 381 InspectorInstrumentation::canceledAfterReceivedResourceResponse(m_frame, thi
s, mainResourceIdentifier(), response, m_mainResource.get()); |
| 378 | 382 |
| 379 setWasBlockedAfterXFrameOptionsOrCSP(); | 383 setWasBlockedAfterCSP(); |
| 380 | 384 |
| 381 // Pretend that this was an empty HTTP 200 response. Don't reuse the | 385 // Pretend that this was an empty HTTP 200 response. Don't reuse the |
| 382 // original URL for the empty page (https://crbug.com/622385). | 386 // original URL for the empty page (https://crbug.com/622385). |
| 383 // | 387 // |
| 384 // TODO(mkwst): Remove this once XFO moves to the browser. | 388 // TODO(mkwst): Remove this once XFO moves to the browser. |
| 385 // https://crbug.com/555418. | 389 // https://crbug.com/555418. |
| 386 clearMainResourceHandle(); | 390 clearMainResourceHandle(); |
| 387 KURL blockedURL = SecurityOrigin::urlWithUniqueSecurityOrigin(); | 391 KURL blockedURL = SecurityOrigin::urlWithUniqueSecurityOrigin(); |
| 388 m_originalRequest.setURL(blockedURL); | 392 m_originalRequest.setURL(blockedURL); |
| 389 m_request.setURL(blockedURL); | 393 m_request.setURL(blockedURL); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 406 // The memory cache doesn't understand the application cache or its caching
rules. So if a main resource is served | 410 // The memory cache doesn't understand the application cache or its caching
rules. So if a main resource is served |
| 407 // from the application cache, ensure we don't save the result for future us
e. All responses loaded | 411 // from the application cache, ensure we don't save the result for future us
e. All responses loaded |
| 408 // from appcache will have a non-zero appCacheID(). | 412 // from appcache will have a non-zero appCacheID(). |
| 409 if (response.appCacheID()) | 413 if (response.appCacheID()) |
| 410 memoryCache()->remove(m_mainResource.get()); | 414 memoryCache()->remove(m_mainResource.get()); |
| 411 | 415 |
| 412 m_contentSecurityPolicy = ContentSecurityPolicy::create(); | 416 m_contentSecurityPolicy = ContentSecurityPolicy::create(); |
| 413 m_contentSecurityPolicy->setOverrideURLForSelf(response.url()); | 417 m_contentSecurityPolicy->setOverrideURLForSelf(response.url()); |
| 414 m_contentSecurityPolicy->didReceiveHeaders(ContentSecurityPolicyResponseHead
ers(response)); | 418 m_contentSecurityPolicy->didReceiveHeaders(ContentSecurityPolicyResponseHead
ers(response)); |
| 415 if (!m_contentSecurityPolicy->allowAncestors(m_frame, response.url())) { | 419 if (!m_contentSecurityPolicy->allowAncestors(m_frame, response.url())) { |
| 416 cancelLoadAfterXFrameOptionsOrCSPDenied(response); | 420 cancelLoadAfterCSPDenied(response); |
| 417 return; | 421 return; |
| 418 } | 422 } |
| 419 | 423 |
| 420 // 'frame-ancestors' obviates 'x-frame-options': https://w3c.github.io/webap
psec/specs/content-security-policy/#frame-ancestors-and-frame-options | |
| 421 if (!m_contentSecurityPolicy->isFrameAncestorsEnforced()) { | |
| 422 HTTPHeaderMap::const_iterator it = response.httpHeaderFields().find(HTTP
Names::X_Frame_Options); | |
| 423 if (it != response.httpHeaderFields().end()) { | |
| 424 String content = it->value; | |
| 425 if (frameLoader()->shouldInterruptLoadForXFrameOptions(content, resp
onse.url(), mainResourceIdentifier())) { | |
| 426 String message = "Refused to display '" + response.url().elidedS
tring() + "' in a frame because it set 'X-Frame-Options' to '" + content + "'."; | |
| 427 ConsoleMessage* consoleMessage = ConsoleMessage::createForReques
t(SecurityMessageSource, ErrorMessageLevel, message, response.url(), mainResourc
eIdentifier()); | |
| 428 frame()->document()->addConsoleMessage(consoleMessage); | |
| 429 | |
| 430 cancelLoadAfterXFrameOptionsOrCSPDenied(response); | |
| 431 return; | |
| 432 } | |
| 433 } | |
| 434 } | |
| 435 | |
| 436 ASSERT(!m_frame->page()->defersLoading()); | 424 ASSERT(!m_frame->page()->defersLoading()); |
| 437 | 425 |
| 438 m_response = response; | 426 m_response = response; |
| 439 | 427 |
| 440 if (isArchiveMIMEType(m_response.mimeType()) && m_mainResource->getDataBuffe
ringPolicy() != BufferData) | 428 if (isArchiveMIMEType(m_response.mimeType()) && m_mainResource->getDataBuffe
ringPolicy() != BufferData) |
| 441 m_mainResource->setDataBufferingPolicy(BufferData); | 429 m_mainResource->setDataBufferingPolicy(BufferData); |
| 442 | 430 |
| 443 if (!shouldContinueForResponse()) { | 431 if (!shouldContinueForResponse()) { |
| 444 InspectorInstrumentation::continueWithPolicyIgnore(m_frame, this, m_main
Resource->identifier(), m_response, m_mainResource.get()); | 432 InspectorInstrumentation::continueWithPolicyIgnore(m_frame, this, m_main
Resource->identifier(), m_response, m_mainResource.get()); |
| 445 m_fetcher->stopFetching(); | 433 m_fetcher->stopFetching(); |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 { | 708 { |
| 721 m_writer = createWriterFor(init, mimeType(), m_writer ? m_writer->encoding()
: emptyAtom, true, ForceSynchronousParsing); | 709 m_writer = createWriterFor(init, mimeType(), m_writer ? m_writer->encoding()
: emptyAtom, true, ForceSynchronousParsing); |
| 722 if (!source.isNull()) | 710 if (!source.isNull()) |
| 723 m_writer->appendReplacingData(source); | 711 m_writer->appendReplacingData(source); |
| 724 endWriting(m_writer.get()); | 712 endWriting(m_writer.get()); |
| 725 } | 713 } |
| 726 | 714 |
| 727 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); | 715 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); |
| 728 | 716 |
| 729 } // namespace blink | 717 } // namespace blink |
| OLD | NEW |