| 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 19 matching lines...) Expand all Loading... |
| 30 #include "config.h" | 30 #include "config.h" |
| 31 #include "core/loader/DocumentLoader.h" | 31 #include "core/loader/DocumentLoader.h" |
| 32 | 32 |
| 33 #include "core/FetchInitiatorTypeNames.h" | 33 #include "core/FetchInitiatorTypeNames.h" |
| 34 #include "core/dom/Document.h" | 34 #include "core/dom/Document.h" |
| 35 #include "core/dom/DocumentParser.h" | 35 #include "core/dom/DocumentParser.h" |
| 36 #include "core/events/Event.h" | 36 #include "core/events/Event.h" |
| 37 #include "core/fetch/MemoryCache.h" | 37 #include "core/fetch/MemoryCache.h" |
| 38 #include "core/fetch/ResourceFetcher.h" | 38 #include "core/fetch/ResourceFetcher.h" |
| 39 #include "core/fetch/ResourceLoader.h" | 39 #include "core/fetch/ResourceLoader.h" |
| 40 #include "core/frame/LocalDOMWindow.h" |
| 41 #include "core/frame/LocalFrame.h" |
| 42 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 40 #include "core/html/HTMLFrameOwnerElement.h" | 43 #include "core/html/HTMLFrameOwnerElement.h" |
| 41 #include "core/html/parser/TextResourceDecoder.h" | 44 #include "core/html/parser/TextResourceDecoder.h" |
| 42 #include "core/inspector/InspectorInstrumentation.h" | 45 #include "core/inspector/InspectorInstrumentation.h" |
| 43 #include "core/loader/FrameLoader.h" | 46 #include "core/loader/FrameLoader.h" |
| 44 #include "core/loader/FrameLoaderClient.h" | 47 #include "core/loader/FrameLoaderClient.h" |
| 45 #include "core/loader/UniqueIdentifier.h" | 48 #include "core/loader/UniqueIdentifier.h" |
| 46 #include "core/loader/appcache/ApplicationCacheHost.h" | 49 #include "core/loader/appcache/ApplicationCacheHost.h" |
| 47 #include "core/frame/LocalDOMWindow.h" | |
| 48 #include "core/frame/LocalFrame.h" | |
| 49 #include "core/frame/csp/ContentSecurityPolicy.h" | |
| 50 #include "core/page/FrameTree.h" | 50 #include "core/page/FrameTree.h" |
| 51 #include "core/page/Page.h" | 51 #include "core/page/Page.h" |
| 52 #include "core/frame/Settings.h" | 52 #include "core/frame/Settings.h" |
| 53 #include "core/inspector/ConsoleMessage.h" | 53 #include "core/inspector/ConsoleMessage.h" |
| 54 #include "platform/Logging.h" | 54 #include "platform/Logging.h" |
| 55 #include "platform/UserGestureIndicator.h" | 55 #include "platform/UserGestureIndicator.h" |
| 56 #include "platform/mhtml/ArchiveResource.h" | 56 #include "platform/mhtml/ArchiveResource.h" |
| 57 #include "platform/mhtml/ArchiveResourceCollection.h" | 57 #include "platform/mhtml/ArchiveResourceCollection.h" |
| 58 #include "platform/mhtml/MHTMLArchive.h" | 58 #include "platform/mhtml/MHTMLArchive.h" |
| 59 #include "platform/plugins/PluginData.h" | 59 #include "platform/plugins/PluginData.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 frameLoader()->receivedMainResourceError(error); | 170 frameLoader()->receivedMainResourceError(error); |
| 171 clearMainResourceHandle(); | 171 clearMainResourceHandle(); |
| 172 } | 172 } |
| 173 | 173 |
| 174 // Cancels the data source's pending loads. Conceptually, a data source only lo
ads | 174 // Cancels the data source's pending loads. Conceptually, a data source only lo
ads |
| 175 // one document at a time, but one document may have many related resources. | 175 // one document at a time, but one document may have many related resources. |
| 176 // stopLoading will stop all loads initiated by the data source, | 176 // stopLoading will stop all loads initiated by the data source, |
| 177 // but not loads initiated by child frames' data sources -- that's the WebFrame'
s job. | 177 // but not loads initiated by child frames' data sources -- that's the WebFrame'
s job. |
| 178 void DocumentLoader::stopLoading() | 178 void DocumentLoader::stopLoading() |
| 179 { | 179 { |
| 180 RefPtr<LocalFrame> protectFrame(m_frame); | 180 RefPtrWillBeRawPtr<LocalFrame> protectFrame(m_frame); |
| 181 RefPtr<DocumentLoader> protectLoader(this); | 181 RefPtr<DocumentLoader> protectLoader(this); |
| 182 | 182 |
| 183 // In some rare cases, calling FrameLoader::stopLoading could cause isLoadin
g() to return false. | 183 // In some rare cases, calling FrameLoader::stopLoading could cause isLoadin
g() to return false. |
| 184 // (This can happen when there's a single XMLHttpRequest currently loading a
nd stopLoading causes it | 184 // (This can happen when there's a single XMLHttpRequest currently loading a
nd stopLoading causes it |
| 185 // to stop loading. Because of this, we need to save it so we don't return e
arly. | 185 // to stop loading. Because of this, we need to save it so we don't return e
arly. |
| 186 bool loading = isLoading(); | 186 bool loading = isLoading(); |
| 187 | 187 |
| 188 if (m_committed) { | 188 if (m_committed) { |
| 189 // Attempt to stop the frame if the document loader is loading, or if it
is done loading but | 189 // Attempt to stop the frame if the document loader is loading, or if it
is done loading but |
| 190 // still parsing. Failure to do so can cause a world leak. | 190 // still parsing. Failure to do so can cause a world leak. |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 { | 493 { |
| 494 if (m_writer) | 494 if (m_writer) |
| 495 return; | 495 return; |
| 496 | 496 |
| 497 const AtomicString& encoding = overrideEncoding().isNull() ? response().text
EncodingName() : overrideEncoding(); | 497 const AtomicString& encoding = overrideEncoding().isNull() ? response().text
EncodingName() : overrideEncoding(); |
| 498 | 498 |
| 499 // Prepare a DocumentInit before clearing the frame, because it may need to | 499 // Prepare a DocumentInit before clearing the frame, because it may need to |
| 500 // inherit an aliased security context. | 500 // inherit an aliased security context. |
| 501 DocumentInit init(url(), m_frame); | 501 DocumentInit init(url(), m_frame); |
| 502 init.withNewRegistrationContext(); | 502 init.withNewRegistrationContext(); |
| 503 m_frame->loader().clear(); | 503 m_frame->loader().dispose(true); |
| 504 ASSERT(m_frame->page()); | 504 ASSERT(m_frame->page()); |
| 505 | 505 |
| 506 m_writer = createWriterFor(0, init, mimeType, encoding, false); | 506 m_writer = createWriterFor(0, init, mimeType, encoding, false); |
| 507 m_writer->setDocumentWasLoadedAsPartOfNavigation(); | 507 m_writer->setDocumentWasLoadedAsPartOfNavigation(); |
| 508 // This should be set before receivedFirstData(). | 508 // This should be set before receivedFirstData(). |
| 509 if (!overridingURL.isEmpty()) | 509 if (!overridingURL.isEmpty()) |
| 510 m_frame->document()->setBaseURLOverride(overridingURL); | 510 m_frame->document()->setBaseURLOverride(overridingURL); |
| 511 | 511 |
| 512 // Call receivedFirstData() exactly once per load. | 512 // Call receivedFirstData() exactly once per load. |
| 513 frameLoader()->receivedFirstData(); | 513 frameLoader()->receivedFirstData(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 524 void DocumentLoader::dataReceived(Resource* resource, const char* data, int leng
th) | 524 void DocumentLoader::dataReceived(Resource* resource, const char* data, int leng
th) |
| 525 { | 525 { |
| 526 ASSERT(data); | 526 ASSERT(data); |
| 527 ASSERT(length); | 527 ASSERT(length); |
| 528 ASSERT_UNUSED(resource, resource == m_mainResource); | 528 ASSERT_UNUSED(resource, resource == m_mainResource); |
| 529 ASSERT(!m_response.isNull()); | 529 ASSERT(!m_response.isNull()); |
| 530 ASSERT(!mainResourceLoader() || !mainResourceLoader()->defersLoading()); | 530 ASSERT(!mainResourceLoader() || !mainResourceLoader()->defersLoading()); |
| 531 | 531 |
| 532 // Both unloading the old page and parsing the new page may execute JavaScri
pt which destroys the datasource | 532 // Both unloading the old page and parsing the new page may execute JavaScri
pt which destroys the datasource |
| 533 // by starting a new load, so retain temporarily. | 533 // by starting a new load, so retain temporarily. |
| 534 RefPtr<LocalFrame> protectFrame(m_frame); | 534 RefPtrWillBeRawPtr<LocalFrame> protectFrame(m_frame); |
| 535 RefPtr<DocumentLoader> protectLoader(this); | 535 RefPtr<DocumentLoader> protectLoader(this); |
| 536 | 536 |
| 537 m_applicationCacheHost->mainResourceDataReceived(data, length); | 537 m_applicationCacheHost->mainResourceDataReceived(data, length); |
| 538 m_timeOfLastDataReceived = monotonicallyIncreasingTime(); | 538 m_timeOfLastDataReceived = monotonicallyIncreasingTime(); |
| 539 | 539 |
| 540 commitIfReady(); | 540 commitIfReady(); |
| 541 if (!frameLoader()) | 541 if (!frameLoader()) |
| 542 return; | 542 return; |
| 543 if (isArchiveMIMEType(response().mimeType())) | 543 if (isArchiveMIMEType(response().mimeType())) |
| 544 return; | 544 return; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 556 } | 556 } |
| 557 | 557 |
| 558 void DocumentLoader::appendRedirect(const KURL& url) | 558 void DocumentLoader::appendRedirect(const KURL& url) |
| 559 { | 559 { |
| 560 m_redirectChain.append(url); | 560 m_redirectChain.append(url); |
| 561 } | 561 } |
| 562 | 562 |
| 563 void DocumentLoader::detachFromFrame() | 563 void DocumentLoader::detachFromFrame() |
| 564 { | 564 { |
| 565 ASSERT(m_frame); | 565 ASSERT(m_frame); |
| 566 RefPtr<LocalFrame> protectFrame(m_frame); | 566 RefPtrWillBeRawPtr<LocalFrame> protectFrame(m_frame); |
| 567 RefPtr<DocumentLoader> protectLoader(this); | 567 RefPtr<DocumentLoader> protectLoader(this); |
| 568 | 568 |
| 569 // It never makes sense to have a document loader that is detached from its | 569 // It never makes sense to have a document loader that is detached from its |
| 570 // frame have any loads active, so go ahead and kill all the loads. | 570 // frame have any loads active, so go ahead and kill all the loads. |
| 571 stopLoading(); | 571 stopLoading(); |
| 572 | 572 |
| 573 m_applicationCacheHost->setApplicationCache(0); | 573 m_applicationCacheHost->setApplicationCache(0); |
| 574 InspectorInstrumentation::loaderDetachedFromFrame(m_frame, this); | 574 InspectorInstrumentation::loaderDetachedFromFrame(m_frame, this); |
| 575 m_frame = 0; | 575 m_frame = 0; |
| 576 } | 576 } |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 // This is only called by FrameLoader::replaceDocumentWhileExecutingJavaScriptUR
L() | 815 // This is only called by FrameLoader::replaceDocumentWhileExecutingJavaScriptUR
L() |
| 816 void DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL(const DocumentIn
it& init, const String& source, Document* ownerDocument) | 816 void DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL(const DocumentIn
it& init, const String& source, Document* ownerDocument) |
| 817 { | 817 { |
| 818 m_writer = createWriterFor(ownerDocument, init, mimeType(), m_writer ? m_wri
ter->encoding() : emptyAtom, true); | 818 m_writer = createWriterFor(ownerDocument, init, mimeType(), m_writer ? m_wri
ter->encoding() : emptyAtom, true); |
| 819 if (!source.isNull()) | 819 if (!source.isNull()) |
| 820 m_writer->appendReplacingData(source); | 820 m_writer->appendReplacingData(source); |
| 821 endWriting(m_writer.get()); | 821 endWriting(m_writer.get()); |
| 822 } | 822 } |
| 823 | 823 |
| 824 } // namespace blink | 824 } // namespace blink |
| OLD | NEW |