| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 namespace blink { | 79 namespace blink { |
| 80 | 80 |
| 81 static bool isArchiveMIMEType(const String& mimeType) { | 81 static bool isArchiveMIMEType(const String& mimeType) { |
| 82 return equalIgnoringCase("multipart/related", mimeType); | 82 return equalIgnoringCase("multipart/related", mimeType); |
| 83 } | 83 } |
| 84 | 84 |
| 85 static bool shouldInheritSecurityOriginFromOwner(const KURL& url) { | 85 static bool shouldInheritSecurityOriginFromOwner(const KURL& url) { |
| 86 // https://html.spec.whatwg.org/multipage/browsers.html#origin | 86 // https://html.spec.whatwg.org/multipage/browsers.html#origin |
| 87 // | 87 // |
| 88 // If a Document is the initial "about:blank" document | 88 // If a Document is the initial "about:blank" document The origin and |
| 89 // The origin and effective script origin of the Document are those it | 89 // effective script origin of the Document are those it was assigned when its |
| 90 // was assigned when its browsing context was created. | 90 // browsing context was created. |
| 91 // | 91 // |
| 92 // Note: We generalize this to all "blank" URLs and invalid URLs because we | 92 // Note: We generalize this to all "blank" URLs and invalid URLs because we |
| 93 // treat all of these URLs as about:blank. | 93 // treat all of these URLs as about:blank. |
| 94 return url.isEmpty() || url.protocolIsAbout(); | 94 return url.isEmpty() || url.protocolIsAbout(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 DocumentLoader::DocumentLoader(LocalFrame* frame, | 97 DocumentLoader::DocumentLoader(LocalFrame* frame, |
| 98 const ResourceRequest& req, | 98 const ResourceRequest& req, |
| 99 const SubstituteData& substituteData) | 99 const SubstituteData& substituteData) |
| 100 : m_frame(frame), | 100 : m_frame(frame), |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 192 |
| 193 if (resource) | 193 if (resource) |
| 194 fetcher()->preloadStarted(resource); | 194 fetcher()->preloadStarted(resource); |
| 195 return resource; | 195 return resource; |
| 196 } | 196 } |
| 197 | 197 |
| 198 void DocumentLoader::didRedirect(const KURL& oldURL, const KURL& newURL) { | 198 void DocumentLoader::didRedirect(const KURL& oldURL, const KURL& newURL) { |
| 199 timing().addRedirect(oldURL, newURL); | 199 timing().addRedirect(oldURL, newURL); |
| 200 | 200 |
| 201 // If a redirection happens during a back/forward navigation, don't restore | 201 // If a redirection happens during a back/forward navigation, don't restore |
| 202 // any state from the old HistoryItem. | 202 // any state from the old HistoryItem. There is a provisional history item for |
| 203 // There is a provisional history item for back/forward navigation only. | 203 // back/forward navigation only. In the other case, clearing it is a no-op. |
| 204 // In the other case, clearing it is a no-op. | |
| 205 DCHECK(frameLoader()); | 204 DCHECK(frameLoader()); |
| 206 frameLoader()->clearProvisionalHistoryItem(); | 205 frameLoader()->clearProvisionalHistoryItem(); |
| 207 } | 206 } |
| 208 | 207 |
| 209 void DocumentLoader::dispatchLinkHeaderPreloads( | 208 void DocumentLoader::dispatchLinkHeaderPreloads( |
| 210 ViewportDescriptionWrapper* viewport, | 209 ViewportDescriptionWrapper* viewport, |
| 211 LinkLoader::MediaPreloadPolicy mediaPolicy) { | 210 LinkLoader::MediaPreloadPolicy mediaPolicy) { |
| 212 LinkLoader::loadLinksFromHeader( | 211 LinkLoader::loadLinksFromHeader( |
| 213 response().httpHeaderField(HTTPNames::Link), response().url(), | 212 response().httpHeaderField(HTTPNames::Link), response().url(), |
| 214 m_frame->document(), NetworkHintsInterfaceImpl(), | 213 m_frame->document(), NetworkHintsInterfaceImpl(), |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 responseEndTime = m_timeOfLastDataReceived; | 281 responseEndTime = m_timeOfLastDataReceived; |
| 283 if (!responseEndTime) | 282 if (!responseEndTime) |
| 284 responseEndTime = monotonicallyIncreasingTime(); | 283 responseEndTime = monotonicallyIncreasingTime(); |
| 285 timing().setResponseEnd(responseEndTime); | 284 timing().setResponseEnd(responseEndTime); |
| 286 | 285 |
| 287 commitIfReady(); | 286 commitIfReady(); |
| 288 if (!frameLoader()) | 287 if (!frameLoader()) |
| 289 return; | 288 return; |
| 290 | 289 |
| 291 if (!maybeCreateArchive()) { | 290 if (!maybeCreateArchive()) { |
| 292 // If this is an empty document, it will not have actually been created yet.
Commit dummy data so that | 291 // If this is an empty document, it will not have actually been created yet. |
| 293 // DocumentWriter::begin() gets called and creates the Document. | 292 // Commit dummy data so that DocumentWriter::begin() gets called and creates |
| 293 // the Document. |
| 294 if (!m_writer) | 294 if (!m_writer) |
| 295 commitData(0, 0); | 295 commitData(0, 0); |
| 296 } | 296 } |
| 297 | 297 |
| 298 if (!m_frame) | 298 if (!m_frame) |
| 299 return; | 299 return; |
| 300 | 300 |
| 301 m_applicationCacheHost->finishedLoadingMainResource(); | 301 m_applicationCacheHost->finishedLoadingMainResource(); |
| 302 endWriting(m_writer.get()); | 302 endWriting(m_writer.get()); |
| 303 if (m_state < MainResourceDone) | 303 if (m_state < MainResourceDone) |
| 304 m_state = MainResourceDone; | 304 m_state = MainResourceDone; |
| 305 clearMainResourceHandle(); | 305 clearMainResourceHandle(); |
| 306 } | 306 } |
| 307 | 307 |
| 308 void DocumentLoader::redirectReceived( | 308 void DocumentLoader::redirectReceived( |
| 309 Resource* resource, | 309 Resource* resource, |
| 310 ResourceRequest& request, | 310 ResourceRequest& request, |
| 311 const ResourceResponse& redirectResponse) { | 311 const ResourceResponse& redirectResponse) { |
| 312 DCHECK_EQ(resource, m_mainResource); | 312 DCHECK_EQ(resource, m_mainResource); |
| 313 DCHECK(!redirectResponse.isNull()); | 313 DCHECK(!redirectResponse.isNull()); |
| 314 m_request = request; | 314 m_request = request; |
| 315 | 315 |
| 316 // If the redirecting url is not allowed to display content from the target or
igin, | 316 // If the redirecting url is not allowed to display content from the target |
| 317 // then block the redirect. | 317 // origin, then block the redirect. |
| 318 const KURL& requestURL = m_request.url(); | 318 const KURL& requestURL = m_request.url(); |
| 319 RefPtr<SecurityOrigin> redirectingOrigin = | 319 RefPtr<SecurityOrigin> redirectingOrigin = |
| 320 SecurityOrigin::create(redirectResponse.url()); | 320 SecurityOrigin::create(redirectResponse.url()); |
| 321 if (!redirectingOrigin->canDisplay(requestURL)) { | 321 if (!redirectingOrigin->canDisplay(requestURL)) { |
| 322 FrameLoader::reportLocalLoadFailed(m_frame, requestURL.getString()); | 322 FrameLoader::reportLocalLoadFailed(m_frame, requestURL.getString()); |
| 323 m_fetcher->stopFetching(); | 323 m_fetcher->stopFetching(); |
| 324 return; | 324 return; |
| 325 } | 325 } |
| 326 if (!frameLoader()->shouldContinueForNavigationPolicy( | 326 if (!frameLoader()->shouldContinueForNavigationPolicy( |
| 327 m_request, SubstituteData(), this, CheckContentSecurityPolicy, | 327 m_request, SubstituteData(), this, CheckContentSecurityPolicy, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 return true; | 369 return true; |
| 370 } | 370 } |
| 371 | 371 |
| 372 void DocumentLoader::cancelLoadAfterXFrameOptionsOrCSPDenied( | 372 void DocumentLoader::cancelLoadAfterXFrameOptionsOrCSPDenied( |
| 373 const ResourceResponse& response) { | 373 const ResourceResponse& response) { |
| 374 InspectorInstrumentation::continueAfterXFrameOptionsDenied( | 374 InspectorInstrumentation::continueAfterXFrameOptionsDenied( |
| 375 m_frame, this, mainResourceIdentifier(), response, m_mainResource.get()); | 375 m_frame, this, mainResourceIdentifier(), response, m_mainResource.get()); |
| 376 | 376 |
| 377 setWasBlockedAfterXFrameOptionsOrCSP(); | 377 setWasBlockedAfterXFrameOptionsOrCSP(); |
| 378 | 378 |
| 379 // Pretend that this was an empty HTTP 200 response. Don't reuse the | 379 // Pretend that this was an empty HTTP 200 response. Don't reuse the original |
| 380 // original URL for the empty page (https://crbug.com/622385). | 380 // URL for the empty page (https://crbug.com/622385). |
| 381 // | 381 // |
| 382 // TODO(mkwst): Remove this once XFO moves to the browser. | 382 // TODO(mkwst): Remove this once XFO moves to the browser. |
| 383 // https://crbug.com/555418. | 383 // https://crbug.com/555418. |
| 384 clearMainResourceHandle(); | 384 clearMainResourceHandle(); |
| 385 KURL blockedURL = SecurityOrigin::urlWithUniqueSecurityOrigin(); | 385 KURL blockedURL = SecurityOrigin::urlWithUniqueSecurityOrigin(); |
| 386 m_originalRequest.setURL(blockedURL); | 386 m_originalRequest.setURL(blockedURL); |
| 387 m_request.setURL(blockedURL); | 387 m_request.setURL(blockedURL); |
| 388 m_redirectChain.removeLast(); | 388 m_redirectChain.removeLast(); |
| 389 appendRedirect(blockedURL); | 389 appendRedirect(blockedURL); |
| 390 m_response = ResourceResponse(blockedURL, "text/html", 0, nullAtom, String()); | 390 m_response = ResourceResponse(blockedURL, "text/html", 0, nullAtom, String()); |
| 391 finishedLoading(monotonicallyIncreasingTime()); | 391 finishedLoading(monotonicallyIncreasingTime()); |
| 392 | 392 |
| 393 return; | 393 return; |
| 394 } | 394 } |
| 395 | 395 |
| 396 void DocumentLoader::responseReceived( | 396 void DocumentLoader::responseReceived( |
| 397 Resource* resource, | 397 Resource* resource, |
| 398 const ResourceResponse& response, | 398 const ResourceResponse& response, |
| 399 std::unique_ptr<WebDataConsumerHandle> handle) { | 399 std::unique_ptr<WebDataConsumerHandle> handle) { |
| 400 DCHECK_EQ(m_mainResource, resource); | 400 DCHECK_EQ(m_mainResource, resource); |
| 401 DCHECK(!handle); | 401 DCHECK(!handle); |
| 402 DCHECK(frame()); | 402 DCHECK(frame()); |
| 403 | 403 |
| 404 m_applicationCacheHost->didReceiveResponseForMainResource(response); | 404 m_applicationCacheHost->didReceiveResponseForMainResource(response); |
| 405 | 405 |
| 406 // The memory cache doesn't understand the application cache or its caching ru
les. So if a main resource is served | 406 // The memory cache doesn't understand the application cache or its caching |
| 407 // from the application cache, ensure we don't save the result for future use.
All responses loaded | 407 // rules. So if a main resource is served from the application cache, ensure |
| 408 // from appcache will have a non-zero appCacheID(). | 408 // we don't save the result for future use. All responses loaded from appcache |
| 409 // will have a non-zero appCacheID(). |
| 409 if (response.appCacheID()) | 410 if (response.appCacheID()) |
| 410 memoryCache()->remove(m_mainResource.get()); | 411 memoryCache()->remove(m_mainResource.get()); |
| 411 | 412 |
| 412 m_contentSecurityPolicy = ContentSecurityPolicy::create(); | 413 m_contentSecurityPolicy = ContentSecurityPolicy::create(); |
| 413 m_contentSecurityPolicy->setOverrideURLForSelf(response.url()); | 414 m_contentSecurityPolicy->setOverrideURLForSelf(response.url()); |
| 414 m_contentSecurityPolicy->didReceiveHeaders( | 415 m_contentSecurityPolicy->didReceiveHeaders( |
| 415 ContentSecurityPolicyResponseHeaders(response)); | 416 ContentSecurityPolicyResponseHeaders(response)); |
| 416 if (!m_contentSecurityPolicy->allowAncestors(m_frame, response.url())) { | 417 if (!m_contentSecurityPolicy->allowAncestors(m_frame, response.url())) { |
| 417 cancelLoadAfterXFrameOptionsOrCSPDenied(response); | 418 cancelLoadAfterXFrameOptionsOrCSPDenied(response); |
| 418 return; | 419 return; |
| 419 } | 420 } |
| 420 | 421 |
| 421 // 'frame-ancestors' obviates 'x-frame-options': https://w3c.github.io/webapps
ec/specs/content-security-policy/#frame-ancestors-and-frame-options | 422 // 'frame-ancestors' obviates 'x-frame-options': |
| 423 // https://w3c.github.io/webappsec/specs/content-security-policy/#frame-ancest
ors-and-frame-options |
| 422 if (!m_contentSecurityPolicy->isFrameAncestorsEnforced()) { | 424 if (!m_contentSecurityPolicy->isFrameAncestorsEnforced()) { |
| 423 HTTPHeaderMap::const_iterator it = | 425 HTTPHeaderMap::const_iterator it = |
| 424 response.httpHeaderFields().find(HTTPNames::X_Frame_Options); | 426 response.httpHeaderFields().find(HTTPNames::X_Frame_Options); |
| 425 if (it != response.httpHeaderFields().end()) { | 427 if (it != response.httpHeaderFields().end()) { |
| 426 String content = it->value; | 428 String content = it->value; |
| 427 if (frameLoader()->shouldInterruptLoadForXFrameOptions( | 429 if (frameLoader()->shouldInterruptLoadForXFrameOptions( |
| 428 content, response.url(), mainResourceIdentifier())) { | 430 content, response.url(), mainResourceIdentifier())) { |
| 429 String message = "Refused to display '" + | 431 String message = "Refused to display '" + |
| 430 response.url().elidedString() + | 432 response.url().elidedString() + |
| 431 "' in a frame because it set 'X-Frame-Options' to '" + | 433 "' in a frame because it set 'X-Frame-Options' to '" + |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 void DocumentLoader::dataReceived(Resource* resource, | 521 void DocumentLoader::dataReceived(Resource* resource, |
| 520 const char* data, | 522 const char* data, |
| 521 size_t length) { | 523 size_t length) { |
| 522 DCHECK(data); | 524 DCHECK(data); |
| 523 DCHECK(length); | 525 DCHECK(length); |
| 524 DCHECK_EQ(resource, m_mainResource); | 526 DCHECK_EQ(resource, m_mainResource); |
| 525 DCHECK(!m_response.isNull()); | 527 DCHECK(!m_response.isNull()); |
| 526 DCHECK(!m_frame->page()->defersLoading()); | 528 DCHECK(!m_frame->page()->defersLoading()); |
| 527 | 529 |
| 528 if (m_inDataReceived) { | 530 if (m_inDataReceived) { |
| 529 // If this function is reentered, defer processing of the additional | 531 // If this function is reentered, defer processing of the additional data to |
| 530 // data to the top-level invocation. Reentrant calls can occur because | 532 // the top-level invocation. Reentrant calls can occur because of web |
| 531 // of web platform (mis-)features that require running a nested message | 533 // platform (mis-)features that require running a nested message loop: |
| 532 // loop: | |
| 533 // - alert(), confirm(), prompt() | 534 // - alert(), confirm(), prompt() |
| 534 // - Detach of plugin elements. | 535 // - Detach of plugin elements. |
| 535 // - Synchronous XMLHTTPRequest | 536 // - Synchronous XMLHTTPRequest |
| 536 m_dataBuffer->append(data, length); | 537 m_dataBuffer->append(data, length); |
| 537 return; | 538 return; |
| 538 } | 539 } |
| 539 | 540 |
| 540 AutoReset<bool> reentrancyProtector(&m_inDataReceived, true); | 541 AutoReset<bool> reentrancyProtector(&m_inDataReceived, true); |
| 541 processData(data, length); | 542 processData(data, length); |
| 542 | 543 |
| 543 // Process data received in reentrant invocations. Note that the | 544 // Process data received in reentrant invocations. Note that the invocations |
| 544 // invocations of processData() may queue more data in reentrant | 545 // of processData() may queue more data in reentrant invocations, so iterate |
| 545 // invocations, so iterate until it's empty. | 546 // until it's empty. |
| 546 const char* segment; | 547 const char* segment; |
| 547 size_t pos = 0; | 548 size_t pos = 0; |
| 548 while (size_t length = m_dataBuffer->getSomeData(segment, pos)) { | 549 while (size_t length = m_dataBuffer->getSomeData(segment, pos)) { |
| 549 processData(segment, length); | 550 processData(segment, length); |
| 550 pos += length; | 551 pos += length; |
| 551 } | 552 } |
| 552 // All data has been consumed, so flush the buffer. | 553 // All data has been consumed, so flush the buffer. |
| 553 m_dataBuffer->clear(); | 554 m_dataBuffer->clear(); |
| 554 } | 555 } |
| 555 | 556 |
| 556 void DocumentLoader::processData(const char* data, size_t length) { | 557 void DocumentLoader::processData(const char* data, size_t length) { |
| 557 m_applicationCacheHost->mainResourceDataReceived(data, length); | 558 m_applicationCacheHost->mainResourceDataReceived(data, length); |
| 558 m_timeOfLastDataReceived = monotonicallyIncreasingTime(); | 559 m_timeOfLastDataReceived = monotonicallyIncreasingTime(); |
| 559 | 560 |
| 560 if (isArchiveMIMEType(response().mimeType())) | 561 if (isArchiveMIMEType(response().mimeType())) |
| 561 return; | 562 return; |
| 562 commitIfReady(); | 563 commitIfReady(); |
| 563 if (!frameLoader()) | 564 if (!frameLoader()) |
| 564 return; | 565 return; |
| 565 commitData(data, length); | 566 commitData(data, length); |
| 566 | 567 |
| 567 // If we are sending data to MediaDocument, we should stop here | 568 // If we are sending data to MediaDocument, we should stop here and cancel the |
| 568 // and cancel the request. | 569 // request. |
| 569 if (m_frame && m_frame->document()->isMediaDocument()) | 570 if (m_frame && m_frame->document()->isMediaDocument()) |
| 570 m_fetcher->stopFetching(); | 571 m_fetcher->stopFetching(); |
| 571 } | 572 } |
| 572 | 573 |
| 573 void DocumentLoader::clearRedirectChain() { | 574 void DocumentLoader::clearRedirectChain() { |
| 574 m_redirectChain.clear(); | 575 m_redirectChain.clear(); |
| 575 } | 576 } |
| 576 | 577 |
| 577 void DocumentLoader::appendRedirect(const KURL& url) { | 578 void DocumentLoader::appendRedirect(const KURL& url) { |
| 578 m_redirectChain.append(url); | 579 m_redirectChain.append(url); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 599 } | 600 } |
| 600 | 601 |
| 601 void DocumentLoader::clearMainResourceHandle() { | 602 void DocumentLoader::clearMainResourceHandle() { |
| 602 if (!m_mainResource) | 603 if (!m_mainResource) |
| 603 return; | 604 return; |
| 604 m_mainResource->removeClient(this); | 605 m_mainResource->removeClient(this); |
| 605 m_mainResource = nullptr; | 606 m_mainResource = nullptr; |
| 606 } | 607 } |
| 607 | 608 |
| 608 bool DocumentLoader::maybeCreateArchive() { | 609 bool DocumentLoader::maybeCreateArchive() { |
| 609 // Give the archive machinery a crack at this document. If the MIME type is no
t an archive type, it will return 0. | 610 // Give the archive machinery a crack at this document. If the MIME type is |
| 611 // not an archive type, it will return 0. |
| 610 if (!isArchiveMIMEType(m_response.mimeType())) | 612 if (!isArchiveMIMEType(m_response.mimeType())) |
| 611 return false; | 613 return false; |
| 612 | 614 |
| 613 DCHECK(m_mainResource); | 615 DCHECK(m_mainResource); |
| 614 ArchiveResource* mainResource = | 616 ArchiveResource* mainResource = |
| 615 m_fetcher->createArchive(m_mainResource.get()); | 617 m_fetcher->createArchive(m_mainResource.get()); |
| 616 if (!mainResource) | 618 if (!mainResource) |
| 617 return false; | 619 return false; |
| 618 // The origin is the MHTML file, we need to set the base URL to the document e
ncoded in the MHTML so | 620 // The origin is the MHTML file, we need to set the base URL to the document |
| 619 // relative URLs are resolved properly. | 621 // encoded in the MHTML so relative URLs are resolved properly. |
| 620 ensureWriter(mainResource->mimeType(), mainResource->url()); | 622 ensureWriter(mainResource->mimeType(), mainResource->url()); |
| 621 | 623 |
| 622 // The Document has now been created. | 624 // The Document has now been created. |
| 623 m_frame->document()->enforceSandboxFlags(SandboxAll); | 625 m_frame->document()->enforceSandboxFlags(SandboxAll); |
| 624 | 626 |
| 625 commitData(mainResource->data()->data(), mainResource->data()->size()); | 627 commitData(mainResource->data()->data(), mainResource->data()->size()); |
| 626 return true; | 628 return true; |
| 627 } | 629 } |
| 628 | 630 |
| 629 const AtomicString& DocumentLoader::responseMIMEType() const { | 631 const AtomicString& DocumentLoader::responseMIMEType() const { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 CheckContentSecurityPolicy, DocumentContext)); | 677 CheckContentSecurityPolicy, DocumentContext)); |
| 676 FetchRequest fetchRequest(m_request, FetchInitiatorTypeNames::document, | 678 FetchRequest fetchRequest(m_request, FetchInitiatorTypeNames::document, |
| 677 mainResourceLoadOptions); | 679 mainResourceLoadOptions); |
| 678 m_mainResource = | 680 m_mainResource = |
| 679 RawResource::fetchMainResource(fetchRequest, fetcher(), m_substituteData); | 681 RawResource::fetchMainResource(fetchRequest, fetcher(), m_substituteData); |
| 680 if (!m_mainResource) { | 682 if (!m_mainResource) { |
| 681 m_request = ResourceRequest(blankURL()); | 683 m_request = ResourceRequest(blankURL()); |
| 682 maybeLoadEmpty(); | 684 maybeLoadEmpty(); |
| 683 return; | 685 return; |
| 684 } | 686 } |
| 685 // A bunch of headers are set when the underlying resource load begins, and m_
request needs to include those. | 687 // A bunch of headers are set when the underlying resource load begins, and |
| 686 // Even when using a cached resource, we may make some modification to the req
uest, e.g. adding the referer header. | 688 // m_request needs to include those. Even when using a cached resource, we may |
| 689 // make some modification to the request, e.g. adding the referer header. |
| 687 m_request = m_mainResource->isLoading() ? m_mainResource->resourceRequest() | 690 m_request = m_mainResource->isLoading() ? m_mainResource->resourceRequest() |
| 688 : fetchRequest.resourceRequest(); | 691 : fetchRequest.resourceRequest(); |
| 689 m_mainResource->addClient(this); | 692 m_mainResource->addClient(this); |
| 690 } | 693 } |
| 691 | 694 |
| 692 void DocumentLoader::endWriting(DocumentWriter* writer) { | 695 void DocumentLoader::endWriting(DocumentWriter* writer) { |
| 693 DCHECK_EQ(m_writer, writer); | 696 DCHECK_EQ(m_writer, writer); |
| 694 m_writer->end(); | 697 m_writer->end(); |
| 695 m_writer.clear(); | 698 m_writer.clear(); |
| 696 } | 699 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 | 731 |
| 729 return DocumentWriter::create(document, parsingPolicy, mimeType, encoding); | 732 return DocumentWriter::create(document, parsingPolicy, mimeType, encoding); |
| 730 } | 733 } |
| 731 | 734 |
| 732 const AtomicString& DocumentLoader::mimeType() const { | 735 const AtomicString& DocumentLoader::mimeType() const { |
| 733 if (m_writer) | 736 if (m_writer) |
| 734 return m_writer->mimeType(); | 737 return m_writer->mimeType(); |
| 735 return m_response.mimeType(); | 738 return m_response.mimeType(); |
| 736 } | 739 } |
| 737 | 740 |
| 738 // This is only called by FrameLoader::replaceDocumentWhileExecutingJavaScriptUR
L() | 741 // This is only called by |
| 742 // FrameLoader::replaceDocumentWhileExecutingJavaScriptURL() |
| 739 void DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL( | 743 void DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL( |
| 740 const DocumentInit& init, | 744 const DocumentInit& init, |
| 741 const String& source) { | 745 const String& source) { |
| 742 m_writer = createWriterFor(init, mimeType(), | 746 m_writer = createWriterFor(init, mimeType(), |
| 743 m_writer ? m_writer->encoding() : emptyAtom, true, | 747 m_writer ? m_writer->encoding() : emptyAtom, true, |
| 744 ForceSynchronousParsing); | 748 ForceSynchronousParsing); |
| 745 if (!source.isNull()) | 749 if (!source.isNull()) |
| 746 m_writer->appendReplacingData(source); | 750 m_writer->appendReplacingData(source); |
| 747 endWriting(m_writer.get()); | 751 endWriting(m_writer.get()); |
| 748 } | 752 } |
| 749 | 753 |
| 750 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); | 754 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); |
| 751 | 755 |
| 752 } // namespace blink | 756 } // namespace blink |
| OLD | NEW |