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