OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
4 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 4 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 2335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2346 } | 2346 } |
2347 | 2347 |
2348 void FrameLoader::load(const ResourceRequest& request, const SubstituteData& sub
stituteData, bool lockHistory) | 2348 void FrameLoader::load(const ResourceRequest& request, const SubstituteData& sub
stituteData, bool lockHistory) |
2349 { | 2349 { |
2350 if (m_inStopAllLoaders) | 2350 if (m_inStopAllLoaders) |
2351 return; | 2351 return; |
2352 | 2352 |
2353 // FIXME: is this the right place to reset loadType? Perhaps this should be
done after loading is finished or aborted. | 2353 // FIXME: is this the right place to reset loadType? Perhaps this should be
done after loading is finished or aborted. |
2354 m_loadType = FrameLoadTypeStandard; | 2354 m_loadType = FrameLoadTypeStandard; |
2355 RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(request, subs
tituteData); | 2355 RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(request, subs
tituteData); |
2356 loader->setURLForHistoryReflectsClientRedirect(lockHistory); | 2356 if (lockHistory && m_documentLoader) |
| 2357 loader->setClientRedirectSourceForHistory(m_documentLoader->didCreateGlo
balHistoryEntry() ? m_documentLoader->urlForHistory() : m_documentLoader->client
RedirectSourceForHistory()); |
2357 load(loader.get()); | 2358 load(loader.get()); |
2358 } | 2359 } |
2359 | 2360 |
2360 void FrameLoader::load(const ResourceRequest& request, const String& frameName,
bool lockHistory) | 2361 void FrameLoader::load(const ResourceRequest& request, const String& frameName,
bool lockHistory) |
2361 { | 2362 { |
2362 if (frameName.isEmpty()) { | 2363 if (frameName.isEmpty()) { |
2363 load(request, lockHistory); | 2364 load(request, lockHistory); |
2364 return; | 2365 return; |
2365 } | 2366 } |
2366 | 2367 |
2367 Frame* frame = findFrameForNavigation(frameName); | 2368 Frame* frame = findFrameForNavigation(frameName); |
2368 if (frame) { | 2369 if (frame) { |
2369 frame->loader()->load(request, lockHistory); | 2370 frame->loader()->load(request, lockHistory); |
2370 return; | 2371 return; |
2371 } | 2372 } |
2372 | 2373 |
2373 checkNewWindowPolicy(NavigationAction(request.url(), NavigationTypeOther), r
equest, 0, frameName); | 2374 checkNewWindowPolicy(NavigationAction(request.url(), NavigationTypeOther), r
equest, 0, frameName); |
2374 } | 2375 } |
2375 | 2376 |
2376 void FrameLoader::loadWithNavigationAction(const ResourceRequest& request, const
NavigationAction& action, bool lockHistory, FrameLoadType type, PassRefPtr<Form
State> formState) | 2377 void FrameLoader::loadWithNavigationAction(const ResourceRequest& request, const
NavigationAction& action, bool lockHistory, FrameLoadType type, PassRefPtr<Form
State> formState) |
2377 { | 2378 { |
2378 RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(request, Subs
tituteData()); | 2379 RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(request, Subs
tituteData()); |
2379 loader->setURLForHistoryReflectsClientRedirect(lockHistory); | 2380 if (lockHistory && m_documentLoader) |
| 2381 loader->setClientRedirectSourceForHistory(m_documentLoader->didCreateGlo
balHistoryEntry() ? m_documentLoader->urlForHistory() : m_documentLoader->client
RedirectSourceForHistory()); |
2380 | 2382 |
2381 loader->setTriggeringAction(action); | 2383 loader->setTriggeringAction(action); |
2382 if (m_documentLoader) { | 2384 if (m_documentLoader) { |
2383 // if the load type is not FrameLoadTypeReload, | 2385 // if the load type is not FrameLoadTypeReload, |
2384 // we need not use original encoding override. | 2386 // we need not use original encoding override. |
2385 if (type == FrameLoadTypeReload) | 2387 if (type == FrameLoadTypeReload) |
2386 loader->setOverrideEncoding(m_documentLoader->overrideEncoding()); | 2388 loader->setOverrideEncoding(m_documentLoader->overrideEncoding()); |
2387 else | 2389 else |
2388 loader->setOverrideEncoding(String()); | 2390 loader->setOverrideEncoding(String()); |
2389 } | 2391 } |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2776 ASSERT(!loader || loader->frameLoader() == this); | 2778 ASSERT(!loader || loader->frameLoader() == this); |
2777 | 2779 |
2778 m_client->prepareForDataSourceReplacement(); | 2780 m_client->prepareForDataSourceReplacement(); |
2779 detachChildren(); | 2781 detachChildren(); |
2780 if (m_documentLoader) | 2782 if (m_documentLoader) |
2781 m_documentLoader->detachFromFrame(); | 2783 m_documentLoader->detachFromFrame(); |
2782 | 2784 |
2783 m_documentLoader = loader; | 2785 m_documentLoader = loader; |
2784 } | 2786 } |
2785 | 2787 |
2786 DocumentLoader* FrameLoader::documentLoader() const | |
2787 { | |
2788 return m_documentLoader.get(); | |
2789 } | |
2790 | |
2791 void FrameLoader::setPolicyDocumentLoader(DocumentLoader* loader) | 2788 void FrameLoader::setPolicyDocumentLoader(DocumentLoader* loader) |
2792 { | 2789 { |
2793 if (m_policyDocumentLoader == loader) | 2790 if (m_policyDocumentLoader == loader) |
2794 return; | 2791 return; |
2795 | 2792 |
2796 ASSERT(m_frame); | 2793 ASSERT(m_frame); |
2797 if (loader) | 2794 if (loader) |
2798 loader->setFrame(m_frame); | 2795 loader->setFrame(m_frame); |
2799 if (m_policyDocumentLoader | 2796 if (m_policyDocumentLoader |
2800 && m_policyDocumentLoader != m_provisionalDocumentLoader | 2797 && m_policyDocumentLoader != m_provisionalDocumentLoader |
2801 && m_policyDocumentLoader != m_documentLoader) | 2798 && m_policyDocumentLoader != m_documentLoader) |
2802 m_policyDocumentLoader->detachFromFrame(); | 2799 m_policyDocumentLoader->detachFromFrame(); |
2803 | 2800 |
2804 m_policyDocumentLoader = loader; | 2801 m_policyDocumentLoader = loader; |
2805 } | 2802 } |
2806 | 2803 |
2807 DocumentLoader* FrameLoader::policyDocumentLoader() const | |
2808 { | |
2809 return m_policyDocumentLoader.get(); | |
2810 } | |
2811 | |
2812 DocumentLoader* FrameLoader::provisionalDocumentLoader() const | |
2813 { | |
2814 return m_provisionalDocumentLoader.get(); | |
2815 } | |
2816 | |
2817 void FrameLoader::setProvisionalDocumentLoader(DocumentLoader* loader) | 2804 void FrameLoader::setProvisionalDocumentLoader(DocumentLoader* loader) |
2818 { | 2805 { |
2819 ASSERT(!loader || !m_provisionalDocumentLoader); | 2806 ASSERT(!loader || !m_provisionalDocumentLoader); |
2820 ASSERT(!loader || loader->frameLoader() == this); | 2807 ASSERT(!loader || loader->frameLoader() == this); |
2821 | 2808 |
2822 if (m_provisionalDocumentLoader && m_provisionalDocumentLoader != m_document
Loader) | 2809 if (m_provisionalDocumentLoader && m_provisionalDocumentLoader != m_document
Loader) |
2823 m_provisionalDocumentLoader->detachFromFrame(); | 2810 m_provisionalDocumentLoader->detachFromFrame(); |
2824 | 2811 |
2825 m_provisionalDocumentLoader = loader; | 2812 m_provisionalDocumentLoader = loader; |
2826 } | 2813 } |
2827 | 2814 |
2828 FrameState FrameLoader::state() const | |
2829 { | |
2830 return m_state; | |
2831 } | |
2832 | |
2833 double FrameLoader::timeOfLastCompletedLoad() | 2815 double FrameLoader::timeOfLastCompletedLoad() |
2834 { | 2816 { |
2835 return storedTimeOfLastCompletedLoad; | 2817 return storedTimeOfLastCompletedLoad; |
2836 } | 2818 } |
2837 | 2819 |
2838 void FrameLoader::setState(FrameState newState) | 2820 void FrameLoader::setState(FrameState newState) |
2839 { | 2821 { |
2840 m_state = newState; | 2822 m_state = newState; |
2841 | 2823 |
2842 if (newState == FrameStateProvisional) | 2824 if (newState == FrameStateProvisional) |
(...skipping 1963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4806 // If the navigation occured during load and this is a subframe, update the
current | 4788 // If the navigation occured during load and this is a subframe, update the
current |
4807 // back/forward item rather than adding a new one and don't add the new URL
to global | 4789 // back/forward item rather than adding a new one and don't add the new URL
to global |
4808 // history at all. But do add it to visited links. <rdar://problem/5333496> | 4790 // history at all. But do add it to visited links. <rdar://problem/5333496> |
4809 bool frameNavigationDuringLoad = false; | 4791 bool frameNavigationDuringLoad = false; |
4810 if (m_navigationDuringLoad) { | 4792 if (m_navigationDuringLoad) { |
4811 HTMLFrameOwnerElement* owner = m_frame->ownerElement(); | 4793 HTMLFrameOwnerElement* owner = m_frame->ownerElement(); |
4812 frameNavigationDuringLoad = owner && !owner->createdByParser(); | 4794 frameNavigationDuringLoad = owner && !owner->createdByParser(); |
4813 m_navigationDuringLoad = false; | 4795 m_navigationDuringLoad = false; |
4814 } | 4796 } |
4815 | 4797 |
4816 bool didUpdateGlobalHistory = false; | |
4817 if (!frameNavigationDuringLoad && !documentLoader()->isClientRedirect()) { | 4798 if (!frameNavigationDuringLoad && !documentLoader()->isClientRedirect()) { |
4818 if (!historyURL.isEmpty()) { | 4799 if (!historyURL.isEmpty()) { |
4819 addBackForwardItemClippedAtTarget(true); | 4800 addBackForwardItemClippedAtTarget(true); |
4820 if (!needPrivacy) { | 4801 if (!needPrivacy) { |
4821 m_client->updateGlobalHistory(); | 4802 m_client->updateGlobalHistory(); |
4822 didUpdateGlobalHistory = true; | 4803 m_documentLoader->setDidCreateGlobalHistoryEntry(true); |
4823 } | 4804 } |
4824 if (Page* page = m_frame->page()) | 4805 if (Page* page = m_frame->page()) |
4825 page->setGlobalHistoryItem(needPrivacy ? 0 : page->backForwardLi
st()->currentItem()); | 4806 page->setGlobalHistoryItem(needPrivacy ? 0 : page->backForwardLi
st()->currentItem()); |
4826 } | 4807 } |
4827 } else if (documentLoader()->unreachableURL().isEmpty() && m_currentHistoryI
tem) { | 4808 } else if (documentLoader()->unreachableURL().isEmpty() && m_currentHistoryI
tem) { |
4828 m_currentHistoryItem->setURL(documentLoader()->url()); | 4809 m_currentHistoryItem->setURL(documentLoader()->url()); |
4829 m_currentHistoryItem->setFormInfoFromRequest(documentLoader()->request()
); | 4810 m_currentHistoryItem->setFormInfoFromRequest(documentLoader()->request()
); |
4830 } | 4811 } |
4831 | 4812 |
4832 if (!historyURL.isEmpty() && !needPrivacy) { | 4813 if (!historyURL.isEmpty() && !needPrivacy) { |
4833 if (Page* page = m_frame->page()) | 4814 if (Page* page = m_frame->page()) |
4834 page->group().addVisitedLink(historyURL); | 4815 page->group().addVisitedLink(historyURL); |
4835 | 4816 |
4836 if (!didUpdateGlobalHistory && !url().isEmpty()) | 4817 if (!m_documentLoader->didCreateGlobalHistoryEntry() && documentLoader()
->unreachableURL().isEmpty() && !url().isEmpty()) |
4837 m_client->updateGlobalHistoryForRedirectWithoutHistoryItem(); | 4818 m_client->updateGlobalHistoryRedirectLinks(); |
4838 } | 4819 } |
4839 } | 4820 } |
4840 | 4821 |
4841 void FrameLoader::updateHistoryForClientRedirect() | 4822 void FrameLoader::updateHistoryForClientRedirect() |
4842 { | 4823 { |
4843 #if !LOG_DISABLED | 4824 #if !LOG_DISABLED |
4844 if (documentLoader()) | 4825 if (documentLoader()) |
4845 LOG(History, "WebCoreHistory: Updating History for client redirect in fr
ame %s", documentLoader()->title().utf8().data()); | 4826 LOG(History, "WebCoreHistory: Updating History for client redirect in fr
ame %s", documentLoader()->title().utf8().data()); |
4846 #endif | 4827 #endif |
4847 | 4828 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4896 { | 4877 { |
4897 #if !LOG_DISABLED | 4878 #if !LOG_DISABLED |
4898 if (documentLoader()) | 4879 if (documentLoader()) |
4899 LOG(History, "WebCoreHistory: Updating History for redirect load in fram
e %s", documentLoader()->title().utf8().data()); | 4880 LOG(History, "WebCoreHistory: Updating History for redirect load in fram
e %s", documentLoader()->title().utf8().data()); |
4900 #endif | 4881 #endif |
4901 | 4882 |
4902 Settings* settings = m_frame->settings(); | 4883 Settings* settings = m_frame->settings(); |
4903 bool needPrivacy = !settings || settings->privateBrowsingEnabled(); | 4884 bool needPrivacy = !settings || settings->privateBrowsingEnabled(); |
4904 const KURL& historyURL = documentLoader()->urlForHistory(); | 4885 const KURL& historyURL = documentLoader()->urlForHistory(); |
4905 | 4886 |
4906 bool didUpdateGlobalHistory = false; | |
4907 if (documentLoader()->isClientRedirect()) { | 4887 if (documentLoader()->isClientRedirect()) { |
4908 if (!m_currentHistoryItem && !m_frame->tree()->parent()) { | 4888 if (!m_currentHistoryItem && !m_frame->tree()->parent()) { |
4909 if (!historyURL.isEmpty()) { | 4889 if (!historyURL.isEmpty()) { |
4910 addBackForwardItemClippedAtTarget(true); | 4890 addBackForwardItemClippedAtTarget(true); |
4911 if (!needPrivacy) { | 4891 if (!needPrivacy) { |
4912 m_client->updateGlobalHistory(); | 4892 m_client->updateGlobalHistory(); |
4913 didUpdateGlobalHistory = true; | 4893 m_documentLoader->setDidCreateGlobalHistoryEntry(true); |
4914 } | 4894 } |
4915 if (Page* page = m_frame->page()) | 4895 if (Page* page = m_frame->page()) |
4916 page->setGlobalHistoryItem(needPrivacy ? 0 : page->backForwa
rdList()->currentItem()); | 4896 page->setGlobalHistoryItem(needPrivacy ? 0 : page->backForwa
rdList()->currentItem()); |
4917 } | 4897 } |
4918 } | 4898 } |
4919 if (m_currentHistoryItem) { | 4899 if (m_currentHistoryItem) { |
4920 m_currentHistoryItem->setURL(documentLoader()->url()); | 4900 m_currentHistoryItem->setURL(documentLoader()->url()); |
4921 m_currentHistoryItem->setFormInfoFromRequest(documentLoader()->reque
st()); | 4901 m_currentHistoryItem->setFormInfoFromRequest(documentLoader()->reque
st()); |
4922 } | 4902 } |
4923 } else { | 4903 } else { |
4924 Frame* parentFrame = m_frame->tree()->parent(); | 4904 Frame* parentFrame = m_frame->tree()->parent(); |
4925 if (parentFrame && parentFrame->loader()->m_currentHistoryItem) | 4905 if (parentFrame && parentFrame->loader()->m_currentHistoryItem) |
4926 parentFrame->loader()->m_currentHistoryItem->addChildItem(createHist
oryItem(true)); | 4906 parentFrame->loader()->m_currentHistoryItem->addChildItem(createHist
oryItem(true)); |
4927 } | 4907 } |
4928 | 4908 |
4929 if (!historyURL.isEmpty() && !needPrivacy) { | 4909 if (!historyURL.isEmpty() && !needPrivacy) { |
4930 if (Page* page = m_frame->page()) | 4910 if (Page* page = m_frame->page()) |
4931 page->group().addVisitedLink(historyURL); | 4911 page->group().addVisitedLink(historyURL); |
4932 | 4912 |
4933 if (!didUpdateGlobalHistory && !url().isEmpty()) | 4913 if (!m_documentLoader->didCreateGlobalHistoryEntry() && documentLoader()
->unreachableURL().isEmpty() && !url().isEmpty()) |
4934 m_client->updateGlobalHistoryForRedirectWithoutHistoryItem(); | 4914 m_client->updateGlobalHistoryRedirectLinks(); |
4935 } | 4915 } |
4936 } | 4916 } |
4937 | 4917 |
4938 void FrameLoader::updateHistoryForCommit() | 4918 void FrameLoader::updateHistoryForCommit() |
4939 { | 4919 { |
4940 #if !LOG_DISABLED | 4920 #if !LOG_DISABLED |
4941 if (documentLoader()) | 4921 if (documentLoader()) |
4942 LOG(History, "WebCoreHistory: Updating History for commit in frame %s",
documentLoader()->title().utf8().data()); | 4922 LOG(History, "WebCoreHistory: Updating History for commit in frame %s",
documentLoader()->title().utf8().data()); |
4943 #endif | 4923 #endif |
4944 FrameLoadType type = loadType(); | 4924 FrameLoadType type = loadType(); |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5515 } | 5495 } |
5516 | 5496 |
5517 #endif | 5497 #endif |
5518 | 5498 |
5519 bool FrameLoaderClient::hasHTMLView() const | 5499 bool FrameLoaderClient::hasHTMLView() const |
5520 { | 5500 { |
5521 return true; | 5501 return true; |
5522 } | 5502 } |
5523 | 5503 |
5524 } // namespace WebCore | 5504 } // namespace WebCore |
OLD | NEW |