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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 { | 501 { |
502 if (m_writer) | 502 if (m_writer) |
503 return; | 503 return; |
504 | 504 |
505 const AtomicString& encoding = overrideEncoding().isNull() ? response().text
EncodingName() : overrideEncoding(); | 505 const AtomicString& encoding = overrideEncoding().isNull() ? response().text
EncodingName() : overrideEncoding(); |
506 | 506 |
507 // Prepare a DocumentInit before clearing the frame, because it may need to | 507 // Prepare a DocumentInit before clearing the frame, because it may need to |
508 // inherit an aliased security context. | 508 // inherit an aliased security context. |
509 DocumentInit init(url(), m_frame); | 509 DocumentInit init(url(), m_frame); |
510 init.withNewRegistrationContext(); | 510 init.withNewRegistrationContext(); |
511 m_frame->loader().clear(); | 511 m_frame->loader().dispose(FrameLoader::DoDisposeFrameContents); |
512 ASSERT(m_frame->page()); | 512 ASSERT(m_frame->page()); |
513 | 513 |
514 m_writer = createWriterFor(0, init, mimeType, encoding, false); | 514 m_writer = createWriterFor(0, init, mimeType, encoding, false); |
515 m_writer->setDocumentWasLoadedAsPartOfNavigation(); | 515 m_writer->setDocumentWasLoadedAsPartOfNavigation(); |
516 // This should be set before receivedFirstData(). | 516 // This should be set before receivedFirstData(). |
517 if (!overridingURL.isEmpty()) | 517 if (!overridingURL.isEmpty()) |
518 m_frame->document()->setBaseURLOverride(overridingURL); | 518 m_frame->document()->setBaseURLOverride(overridingURL); |
519 | 519 |
520 // Call receivedFirstData() exactly once per load. | 520 // Call receivedFirstData() exactly once per load. |
521 frameLoader()->receivedFirstData(); | 521 frameLoader()->receivedFirstData(); |
(...skipping 10 matching lines...) Expand all Loading... |
532 void DocumentLoader::dataReceived(Resource* resource, const char* data, int leng
th) | 532 void DocumentLoader::dataReceived(Resource* resource, const char* data, int leng
th) |
533 { | 533 { |
534 ASSERT(data); | 534 ASSERT(data); |
535 ASSERT(length); | 535 ASSERT(length); |
536 ASSERT_UNUSED(resource, resource == m_mainResource); | 536 ASSERT_UNUSED(resource, resource == m_mainResource); |
537 ASSERT(!m_response.isNull()); | 537 ASSERT(!m_response.isNull()); |
538 ASSERT(!mainResourceLoader() || !mainResourceLoader()->defersLoading()); | 538 ASSERT(!mainResourceLoader() || !mainResourceLoader()->defersLoading()); |
539 | 539 |
540 // Both unloading the old page and parsing the new page may execute JavaScri
pt which destroys the datasource | 540 // Both unloading the old page and parsing the new page may execute JavaScri
pt which destroys the datasource |
541 // by starting a new load, so retain temporarily. | 541 // by starting a new load, so retain temporarily. |
542 RefPtr<LocalFrame> protectFrame(m_frame); | 542 RefPtrWillBeRawPtr<LocalFrame> protectFrame(m_frame); |
543 RefPtr<DocumentLoader> protectLoader(this); | 543 RefPtr<DocumentLoader> protectLoader(this); |
544 | 544 |
545 m_applicationCacheHost->mainResourceDataReceived(data, length); | 545 m_applicationCacheHost->mainResourceDataReceived(data, length); |
546 m_timeOfLastDataReceived = monotonicallyIncreasingTime(); | 546 m_timeOfLastDataReceived = monotonicallyIncreasingTime(); |
547 | 547 |
548 commitIfReady(); | 548 commitIfReady(); |
549 if (!frameLoader()) | 549 if (!frameLoader()) |
550 return; | 550 return; |
551 if (isArchiveMIMEType(response().mimeType())) | 551 if (isArchiveMIMEType(response().mimeType())) |
552 return; | 552 return; |
(...skipping 11 matching lines...) Expand all Loading... |
564 } | 564 } |
565 | 565 |
566 void DocumentLoader::appendRedirect(const KURL& url) | 566 void DocumentLoader::appendRedirect(const KURL& url) |
567 { | 567 { |
568 m_redirectChain.append(url); | 568 m_redirectChain.append(url); |
569 } | 569 } |
570 | 570 |
571 void DocumentLoader::detachFromFrame() | 571 void DocumentLoader::detachFromFrame() |
572 { | 572 { |
573 ASSERT(m_frame); | 573 ASSERT(m_frame); |
574 RefPtr<LocalFrame> protectFrame(m_frame); | 574 RefPtrWillBeRawPtr<LocalFrame> protectFrame(m_frame); |
575 RefPtr<DocumentLoader> protectLoader(this); | 575 RefPtr<DocumentLoader> protectLoader(this); |
576 | 576 |
577 // It never makes sense to have a document loader that is detached from its | 577 // It never makes sense to have a document loader that is detached from its |
578 // frame have any loads active, so go ahead and kill all the loads. | 578 // frame have any loads active, so go ahead and kill all the loads. |
579 stopLoading(); | 579 stopLoading(); |
580 | 580 |
581 m_applicationCacheHost->setApplicationCache(0); | 581 m_applicationCacheHost->setApplicationCache(0); |
582 InspectorInstrumentation::loaderDetachedFromFrame(m_frame, this); | 582 InspectorInstrumentation::loaderDetachedFromFrame(m_frame, this); |
583 m_frame = 0; | 583 m_frame = 0; |
584 } | 584 } |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 // This is only called by FrameLoader::replaceDocumentWhileExecutingJavaScriptUR
L() | 823 // This is only called by FrameLoader::replaceDocumentWhileExecutingJavaScriptUR
L() |
824 void DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL(const DocumentIn
it& init, const String& source, Document* ownerDocument) | 824 void DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL(const DocumentIn
it& init, const String& source, Document* ownerDocument) |
825 { | 825 { |
826 m_writer = createWriterFor(ownerDocument, init, mimeType(), m_writer ? m_wri
ter->encoding() : emptyAtom, true); | 826 m_writer = createWriterFor(ownerDocument, init, mimeType(), m_writer ? m_wri
ter->encoding() : emptyAtom, true); |
827 if (!source.isNull()) | 827 if (!source.isNull()) |
828 m_writer->appendReplacingData(source); | 828 m_writer->appendReplacingData(source); |
829 endWriting(m_writer.get()); | 829 endWriting(m_writer.get()); |
830 } | 830 } |
831 | 831 |
832 } // namespace blink | 832 } // namespace blink |
OLD | NEW |