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/network/ContentSecurityPolicyResponseHeaders.h" | 59 #include "platform/network/ContentSecurityPolicyResponseHeaders.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 frameLoader()->receivedMainResourceError(error); | 172 frameLoader()->receivedMainResourceError(error); |
173 clearMainResourceHandle(); | 173 clearMainResourceHandle(); |
174 } | 174 } |
175 | 175 |
176 // Cancels the data source's pending loads. Conceptually, a data source only lo
ads | 176 // Cancels the data source's pending loads. Conceptually, a data source only lo
ads |
177 // one document at a time, but one document may have many related resources. | 177 // one document at a time, but one document may have many related resources. |
178 // stopLoading will stop all loads initiated by the data source, | 178 // stopLoading will stop all loads initiated by the data source, |
179 // but not loads initiated by child frames' data sources -- that's the WebFrame'
s job. | 179 // but not loads initiated by child frames' data sources -- that's the WebFrame'
s job. |
180 void DocumentLoader::stopLoading() | 180 void DocumentLoader::stopLoading() |
181 { | 181 { |
182 RefPtr<LocalFrame> protectFrame(m_frame); | 182 RefPtrWillBeRawPtr<LocalFrame> protectFrame(m_frame); |
183 RefPtr<DocumentLoader> protectLoader(this); | 183 RefPtr<DocumentLoader> protectLoader(this); |
184 | 184 |
185 // In some rare cases, calling FrameLoader::stopLoading could cause isLoadin
g() to return false. | 185 // In some rare cases, calling FrameLoader::stopLoading could cause isLoadin
g() to return false. |
186 // (This can happen when there's a single XMLHttpRequest currently loading a
nd stopLoading causes it | 186 // (This can happen when there's a single XMLHttpRequest currently loading a
nd stopLoading causes it |
187 // to stop loading. Because of this, we need to save it so we don't return e
arly. | 187 // to stop loading. Because of this, we need to save it so we don't return e
arly. |
188 bool loading = isLoading(); | 188 bool loading = isLoading(); |
189 | 189 |
190 if (m_committed) { | 190 if (m_committed) { |
191 // Attempt to stop the frame if the document loader is loading, or if it
is done loading but | 191 // Attempt to stop the frame if the document loader is loading, or if it
is done loading but |
192 // still parsing. Failure to do so can cause a world leak. | 192 // still parsing. Failure to do so can cause a world leak. |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 { | 508 { |
509 if (m_writer) | 509 if (m_writer) |
510 return; | 510 return; |
511 | 511 |
512 const AtomicString& encoding = overrideEncoding().isNull() ? response().text
EncodingName() : overrideEncoding(); | 512 const AtomicString& encoding = overrideEncoding().isNull() ? response().text
EncodingName() : overrideEncoding(); |
513 | 513 |
514 // Prepare a DocumentInit before clearing the frame, because it may need to | 514 // Prepare a DocumentInit before clearing the frame, because it may need to |
515 // inherit an aliased security context. | 515 // inherit an aliased security context. |
516 DocumentInit init(url(), m_frame); | 516 DocumentInit init(url(), m_frame); |
517 init.withNewRegistrationContext(); | 517 init.withNewRegistrationContext(); |
518 m_frame->loader().clear(); | 518 m_frame->loader().dispose(FrameLoader::DoDisposeFrameContents); |
519 ASSERT(m_frame->page()); | 519 ASSERT(m_frame->page()); |
520 | 520 |
521 m_writer = createWriterFor(0, init, mimeType, encoding, false); | 521 m_writer = createWriterFor(0, init, mimeType, encoding, false); |
522 m_writer->setDocumentWasLoadedAsPartOfNavigation(); | 522 m_writer->setDocumentWasLoadedAsPartOfNavigation(); |
523 // This should be set before receivedFirstData(). | 523 // This should be set before receivedFirstData(). |
524 if (!overridingURL.isEmpty()) | 524 if (!overridingURL.isEmpty()) |
525 m_frame->document()->setBaseURLOverride(overridingURL); | 525 m_frame->document()->setBaseURLOverride(overridingURL); |
526 | 526 |
527 // Call receivedFirstData() exactly once per load. | 527 // Call receivedFirstData() exactly once per load. |
528 frameLoader()->receivedFirstData(); | 528 frameLoader()->receivedFirstData(); |
(...skipping 10 matching lines...) Expand all Loading... |
539 void DocumentLoader::dataReceived(Resource* resource, const char* data, int leng
th) | 539 void DocumentLoader::dataReceived(Resource* resource, const char* data, int leng
th) |
540 { | 540 { |
541 ASSERT(data); | 541 ASSERT(data); |
542 ASSERT(length); | 542 ASSERT(length); |
543 ASSERT_UNUSED(resource, resource == m_mainResource); | 543 ASSERT_UNUSED(resource, resource == m_mainResource); |
544 ASSERT(!m_response.isNull()); | 544 ASSERT(!m_response.isNull()); |
545 ASSERT(!mainResourceLoader() || !mainResourceLoader()->defersLoading()); | 545 ASSERT(!mainResourceLoader() || !mainResourceLoader()->defersLoading()); |
546 | 546 |
547 // Both unloading the old page and parsing the new page may execute JavaScri
pt which destroys the datasource | 547 // Both unloading the old page and parsing the new page may execute JavaScri
pt which destroys the datasource |
548 // by starting a new load, so retain temporarily. | 548 // by starting a new load, so retain temporarily. |
549 RefPtr<LocalFrame> protectFrame(m_frame); | 549 RefPtrWillBeRawPtr<LocalFrame> protectFrame(m_frame); |
550 RefPtr<DocumentLoader> protectLoader(this); | 550 RefPtr<DocumentLoader> protectLoader(this); |
551 | 551 |
552 m_applicationCacheHost->mainResourceDataReceived(data, length); | 552 m_applicationCacheHost->mainResourceDataReceived(data, length); |
553 m_timeOfLastDataReceived = monotonicallyIncreasingTime(); | 553 m_timeOfLastDataReceived = monotonicallyIncreasingTime(); |
554 | 554 |
555 commitIfReady(); | 555 commitIfReady(); |
556 if (!frameLoader()) | 556 if (!frameLoader()) |
557 return; | 557 return; |
558 if (isArchiveMIMEType(response().mimeType())) | 558 if (isArchiveMIMEType(response().mimeType())) |
559 return; | 559 return; |
(...skipping 11 matching lines...) Expand all Loading... |
571 } | 571 } |
572 | 572 |
573 void DocumentLoader::appendRedirect(const KURL& url) | 573 void DocumentLoader::appendRedirect(const KURL& url) |
574 { | 574 { |
575 m_redirectChain.append(url); | 575 m_redirectChain.append(url); |
576 } | 576 } |
577 | 577 |
578 void DocumentLoader::detachFromFrame() | 578 void DocumentLoader::detachFromFrame() |
579 { | 579 { |
580 ASSERT(m_frame); | 580 ASSERT(m_frame); |
581 RefPtr<LocalFrame> protectFrame(m_frame); | 581 RefPtrWillBeRawPtr<LocalFrame> protectFrame(m_frame); |
582 RefPtr<DocumentLoader> protectLoader(this); | 582 RefPtr<DocumentLoader> protectLoader(this); |
583 | 583 |
584 // It never makes sense to have a document loader that is detached from its | 584 // It never makes sense to have a document loader that is detached from its |
585 // frame have any loads active, so go ahead and kill all the loads. | 585 // frame have any loads active, so go ahead and kill all the loads. |
586 stopLoading(); | 586 stopLoading(); |
587 | 587 |
588 m_applicationCacheHost->setApplicationCache(0); | 588 m_applicationCacheHost->setApplicationCache(0); |
589 InspectorInstrumentation::loaderDetachedFromFrame(m_frame, this); | 589 InspectorInstrumentation::loaderDetachedFromFrame(m_frame, this); |
590 m_frame = 0; | 590 m_frame = 0; |
591 } | 591 } |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 // This is only called by FrameLoader::replaceDocumentWhileExecutingJavaScriptUR
L() | 830 // This is only called by FrameLoader::replaceDocumentWhileExecutingJavaScriptUR
L() |
831 void DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL(const DocumentIn
it& init, const String& source, Document* ownerDocument) | 831 void DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL(const DocumentIn
it& init, const String& source, Document* ownerDocument) |
832 { | 832 { |
833 m_writer = createWriterFor(ownerDocument, init, mimeType(), m_writer ? m_wri
ter->encoding() : emptyAtom, true); | 833 m_writer = createWriterFor(ownerDocument, init, mimeType(), m_writer ? m_wri
ter->encoding() : emptyAtom, true); |
834 if (!source.isNull()) | 834 if (!source.isNull()) |
835 m_writer->appendReplacingData(source); | 835 m_writer->appendReplacingData(source); |
836 endWriting(m_writer.get()); | 836 endWriting(m_writer.get()); |
837 } | 837 } |
838 | 838 |
839 } // namespace blink | 839 } // namespace blink |
OLD | NEW |