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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 if (((status >= 301 && status <= 303) || status == 307) | 338 if (((status >= 301 && status <= 303) || status == 307) |
339 && m_originalRequest.httpMethod() == "POST") | 339 && m_originalRequest.httpMethod() == "POST") |
340 return true; | 340 return true; |
341 | 341 |
342 return false; | 342 return false; |
343 } | 343 } |
344 | 344 |
345 void DocumentLoader::handleSubstituteDataLoadNow(DocumentLoaderTimer*) | 345 void DocumentLoader::handleSubstituteDataLoadNow(DocumentLoaderTimer*) |
346 { | 346 { |
347 RefPtr<DocumentLoader> protect(this); | 347 RefPtr<DocumentLoader> protect(this); |
348 ResourceResponse response(m_request.url(), m_substituteData.mimeType(), m_su
bstituteData.content()->size(), m_substituteData.textEncoding(), ""); | 348 ResourceResponse response(m_request.url(), m_substituteData.mimeType(), m_su
bstituteData.content()->size(), m_substituteData.textEncoding(), emptyString()); |
349 responseReceived(0, response); | 349 responseReceived(0, response); |
350 if (m_substituteData.content()->size()) | 350 if (m_substituteData.content()->size()) |
351 dataReceived(0, m_substituteData.content()->data(), m_substituteData.con
tent()->size()); | 351 dataReceived(0, m_substituteData.content()->data(), m_substituteData.con
tent()->size()); |
352 if (isLoadingMainResource()) | 352 if (isLoadingMainResource()) |
353 finishedLoading(0); | 353 finishedLoading(0); |
354 } | 354 } |
355 | 355 |
356 void DocumentLoader::startDataLoadTimer() | 356 void DocumentLoader::startDataLoadTimer() |
357 { | 357 { |
358 m_dataLoadTimer.startOneShot(0); | 358 m_dataLoadTimer.startOneShot(0); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 cancelMainResourceLoad(ResourceError::cancelledError(m_request.url()
)); | 556 cancelMainResourceLoad(ResourceError::cancelledError(m_request.url()
)); |
557 } | 557 } |
558 } | 558 } |
559 } | 559 } |
560 | 560 |
561 void DocumentLoader::ensureWriter() | 561 void DocumentLoader::ensureWriter() |
562 { | 562 { |
563 ensureWriter(m_response.mimeType()); | 563 ensureWriter(m_response.mimeType()); |
564 } | 564 } |
565 | 565 |
566 void DocumentLoader::ensureWriter(const String& mimeType, const KURL& overriding
URL) | 566 void DocumentLoader::ensureWriter(const AtomicString& mimeType, const KURL& over
ridingURL) |
567 { | 567 { |
568 if (m_writer) | 568 if (m_writer) |
569 return; | 569 return; |
570 | 570 |
571 const String& encoding = overrideEncoding().isNull() ? response().textEncodi
ngName().string() : overrideEncoding(); | 571 const AtomicString& encoding = overrideEncoding().isNull() ? response().text
EncodingName() : overrideEncoding(); |
572 m_writer = createWriterFor(m_frame, 0, requestURL(), mimeType, encoding, fal
se, false); | 572 m_writer = createWriterFor(m_frame, 0, requestURL(), mimeType, encoding, fal
se, false); |
573 m_writer->setDocumentWasLoadedAsPartOfNavigation(); | 573 m_writer->setDocumentWasLoadedAsPartOfNavigation(); |
574 // This should be set before receivedFirstData(). | 574 // This should be set before receivedFirstData(). |
575 if (!overridingURL.isEmpty()) | 575 if (!overridingURL.isEmpty()) |
576 m_frame->document()->setBaseURLOverride(overridingURL); | 576 m_frame->document()->setBaseURLOverride(overridingURL); |
577 | 577 |
578 // Call receivedFirstData() exactly once per load. | 578 // Call receivedFirstData() exactly once per load. |
579 frameLoader()->receivedFirstData(); | 579 frameLoader()->receivedFirstData(); |
580 m_frame->document()->maybeHandleHttpRefresh(m_response.httpHeaderField("Refr
esh"), Document::HttpRefreshFromHeader); | 580 m_frame->document()->maybeHandleHttpRefresh(m_response.httpHeaderField("Refr
esh"), Document::HttpRefreshFromHeader); |
581 } | 581 } |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 } | 796 } |
797 | 797 |
798 bool DocumentLoader::maybeLoadEmpty() | 798 bool DocumentLoader::maybeLoadEmpty() |
799 { | 799 { |
800 bool shouldLoadEmpty = !m_substituteData.isValid() && (m_request.url().isEmp
ty() || SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(m_request.url().proto
col())); | 800 bool shouldLoadEmpty = !m_substituteData.isValid() && (m_request.url().isEmp
ty() || SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(m_request.url().proto
col())); |
801 if (!shouldLoadEmpty) | 801 if (!shouldLoadEmpty) |
802 return false; | 802 return false; |
803 | 803 |
804 if (m_request.url().isEmpty() && !frameLoader()->stateMachine()->creatingIni
tialEmptyDocument()) | 804 if (m_request.url().isEmpty() && !frameLoader()->stateMachine()->creatingIni
tialEmptyDocument()) |
805 m_request.setURL(blankURL()); | 805 m_request.setURL(blankURL()); |
806 m_response = ResourceResponse(m_request.url(), "text/html", 0, String(), Str
ing()); | 806 m_response = ResourceResponse(m_request.url(), "text/html", 0, nullAtom, Str
ing()); |
807 finishedLoading(monotonicallyIncreasingTime()); | 807 finishedLoading(monotonicallyIncreasingTime()); |
808 return true; | 808 return true; |
809 } | 809 } |
810 | 810 |
811 void DocumentLoader::startLoadingMainResource() | 811 void DocumentLoader::startLoadingMainResource() |
812 { | 812 { |
813 RefPtr<DocumentLoader> protect(this); | 813 RefPtr<DocumentLoader> protect(this); |
814 m_mainDocumentError = ResourceError(); | 814 m_mainDocumentError = ResourceError(); |
815 timing()->markNavigationStart(); | 815 timing()->markNavigationStart(); |
816 ASSERT(!m_mainResource); | 816 ASSERT(!m_mainResource); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 RefPtr<DocumentLoader> protect(this); | 870 RefPtr<DocumentLoader> protect(this); |
871 ResourceError error = resourceError.isNull() ? ResourceError::cancelledError
(m_request.url()) : resourceError; | 871 ResourceError error = resourceError.isNull() ? ResourceError::cancelledError
(m_request.url()) : resourceError; |
872 | 872 |
873 m_dataLoadTimer.stop(); | 873 m_dataLoadTimer.stop(); |
874 if (mainResourceLoader()) | 874 if (mainResourceLoader()) |
875 mainResourceLoader()->cancel(error); | 875 mainResourceLoader()->cancel(error); |
876 | 876 |
877 mainReceivedError(error); | 877 mainReceivedError(error); |
878 } | 878 } |
879 | 879 |
880 DocumentWriter* DocumentLoader::beginWriting(const String& mimeType, const Strin
g& encoding, const KURL& url) | 880 DocumentWriter* DocumentLoader::beginWriting(const AtomicString& mimeType, const
AtomicString& encoding, const KURL& url) |
881 { | 881 { |
882 m_writer = createWriterFor(m_frame, 0, url, mimeType, encoding, false, true)
; | 882 m_writer = createWriterFor(m_frame, 0, url, mimeType, encoding, false, true)
; |
883 return m_writer.get(); | 883 return m_writer.get(); |
884 } | 884 } |
885 | 885 |
886 void DocumentLoader::endWriting(DocumentWriter* writer) | 886 void DocumentLoader::endWriting(DocumentWriter* writer) |
887 { | 887 { |
888 ASSERT_UNUSED(writer, m_writer == writer); | 888 ASSERT_UNUSED(writer, m_writer == writer); |
889 m_writer->end(); | 889 m_writer->end(); |
890 m_writer.clear(); | 890 m_writer.clear(); |
891 } | 891 } |
892 | 892 |
893 PassRefPtr<DocumentWriter> DocumentLoader::createWriterFor(Frame* frame, const D
ocument* ownerDocument, const KURL& url, const String& mimeType, const String& e
ncoding, bool userChosen, bool dispatch) | 893 PassRefPtr<DocumentWriter> DocumentLoader::createWriterFor(Frame* frame, const D
ocument* ownerDocument, const KURL& url, const AtomicString& mimeType, const Ato
micString& encoding, bool userChosen, bool dispatch) |
894 { | 894 { |
895 // Create a new document before clearing the frame, because it may need to | 895 // Create a new document before clearing the frame, because it may need to |
896 // inherit an aliased security context. | 896 // inherit an aliased security context. |
897 DocumentInit init(url, frame); | 897 DocumentInit init(url, frame); |
898 | 898 |
899 // In some rare cases, we'll re-used a DOMWindow for a new Document. For exa
mple, | 899 // In some rare cases, we'll re-used a DOMWindow for a new Document. For exa
mple, |
900 // when a script calls window.open("..."), the browser gives JavaScript a wi
ndow | 900 // when a script calls window.open("..."), the browser gives JavaScript a wi
ndow |
901 // synchronously but kicks off the load in the window asynchronously. Web si
tes | 901 // synchronously but kicks off the load in the window asynchronously. Web si
tes |
902 // expect that modifications that they make to the window object synchronous
ly | 902 // expect that modifications that they make to the window object synchronous
ly |
903 // won't be blown away when the network load commits. To make that happen, w
e | 903 // won't be blown away when the network load commits. To make that happen, w
e |
(...skipping 17 matching lines...) Expand all Loading... |
921 if (ownerDocument) { | 921 if (ownerDocument) { |
922 document->setCookieURL(ownerDocument->cookieURL()); | 922 document->setCookieURL(ownerDocument->cookieURL()); |
923 document->setSecurityOrigin(ownerDocument->securityOrigin()); | 923 document->setSecurityOrigin(ownerDocument->securityOrigin()); |
924 } | 924 } |
925 | 925 |
926 frame->loader().didBeginDocument(dispatch); | 926 frame->loader().didBeginDocument(dispatch); |
927 | 927 |
928 return DocumentWriter::create(document.get(), mimeType, encoding, userChosen
); | 928 return DocumentWriter::create(document.get(), mimeType, encoding, userChosen
); |
929 } | 929 } |
930 | 930 |
931 String DocumentLoader::mimeType() const | 931 const AtomicString& DocumentLoader::mimeType() const |
932 { | 932 { |
933 if (m_writer) | 933 if (m_writer) |
934 return m_writer->mimeType(); | 934 return m_writer->mimeType(); |
935 return m_response.mimeType(); | 935 return m_response.mimeType(); |
936 } | 936 } |
937 | 937 |
938 void DocumentLoader::setUserChosenEncoding(const String& charset) | 938 void DocumentLoader::setUserChosenEncoding(const String& charset) |
939 { | 939 { |
940 if (m_writer) | 940 if (m_writer) |
941 m_writer->setUserChosenEncoding(charset); | 941 m_writer->setUserChosenEncoding(charset); |
942 } | 942 } |
943 | 943 |
944 // This is only called by ScriptController::executeScriptIfJavaScriptURL | 944 // This is only called by ScriptController::executeScriptIfJavaScriptURL |
945 // and always contains the result of evaluating a javascript: url. | 945 // and always contains the result of evaluating a javascript: url. |
946 // This is the <iframe src="javascript:'html'"> case. | 946 // This is the <iframe src="javascript:'html'"> case. |
947 void DocumentLoader::replaceDocument(const String& source, Document* ownerDocume
nt) | 947 void DocumentLoader::replaceDocument(const String& source, Document* ownerDocume
nt) |
948 { | 948 { |
949 m_frame->loader().stopAllLoaders(); | 949 m_frame->loader().stopAllLoaders(); |
950 m_writer = createWriterFor(m_frame, ownerDocument, m_frame->document()->url(
), mimeType(), m_writer ? m_writer->encoding() : "", m_writer ? m_writer->encod
ingWasChosenByUser() : false, true); | 950 m_writer = createWriterFor(m_frame, ownerDocument, m_frame->document()->url(
), mimeType(), m_writer ? m_writer->encoding() : emptyAtom, m_writer ? m_writer
->encodingWasChosenByUser() : false, true); |
951 if (!source.isNull()) | 951 if (!source.isNull()) |
952 m_writer->appendReplacingData(source); | 952 m_writer->appendReplacingData(source); |
953 endWriting(m_writer.get()); | 953 endWriting(m_writer.get()); |
954 } | 954 } |
955 | 955 |
956 } // namespace WebCore | 956 } // namespace WebCore |
OLD | NEW |