OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights |
3 * reserved. | 3 * reserved. |
4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
6 * (http://www.torchmobile.com/) | 6 * (http://www.torchmobile.com/) |
7 * Copyright (C) 2008 Alp Toker <alp@atoker.com> | 7 * Copyright (C) 2008 Alp Toker <alp@atoker.com> |
8 * Copyright (C) Research In Motion Limited 2009. All rights reserved. | 8 * Copyright (C) Research In Motion Limited 2009. All rights reserved. |
9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> | 9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> |
10 * Copyright (C) 2011 Google Inc. All rights reserved. | 10 * Copyright (C) 2011 Google Inc. All rights reserved. |
(...skipping 1712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1723 type, resourceRequest.httpBody() || frameLoadRequest.form(), | 1723 type, resourceRequest.httpBody() || frameLoadRequest.form(), |
1724 frameLoadRequest.triggeringEvent()); | 1724 frameLoadRequest.triggeringEvent()); |
1725 resourceRequest.setRequestContext( | 1725 resourceRequest.setRequestContext( |
1726 determineRequestContextFromNavigationType(navigationType)); | 1726 determineRequestContextFromNavigationType(navigationType)); |
1727 resourceRequest.setFrameType(m_frame->isMainFrame() | 1727 resourceRequest.setFrameType(m_frame->isMainFrame() |
1728 ? WebURLRequest::FrameTypeTopLevel | 1728 ? WebURLRequest::FrameTypeTopLevel |
1729 : WebURLRequest::FrameTypeNested); | 1729 : WebURLRequest::FrameTypeNested); |
1730 | 1730 |
1731 if (!checkLoadCanStart(frameLoadRequest, type, navigationPolicy, | 1731 if (!checkLoadCanStart(frameLoadRequest, type, navigationPolicy, |
1732 navigationType)) { | 1732 navigationType)) { |
1733 // PlzNavigate: if the navigation is a commit of a client-handled | 1733 if (m_isNavigationHandledByClient) { |
1734 // navigation, record that there is no longer a navigation handled by the | 1734 // PlzNavigate: if the navigation is a commit of a client-handled |
1735 // client. | 1735 // navigation, record that there is no longer a navigation handled by the |
1736 if (m_isNavigationHandledByClient && | 1736 // client. |
1737 !frameLoadRequest.resourceRequest().checkForBrowserSideNavigation()) { | 1737 if (!frameLoadRequest.resourceRequest().checkForBrowserSideNavigation()) { |
1738 m_isNavigationHandledByClient = false; | 1738 m_isNavigationHandledByClient = false; |
| 1739 } else { |
| 1740 DocumentLoader* loader = createDocumentLoader( |
| 1741 resourceRequest, frameLoadRequest, type, navigationType); |
| 1742 // PlzNavigate: If the navigation is handled by the client, then the |
| 1743 // didFinishDocumentLoad() event occurs before the |
| 1744 // didStartProvisionalLoad() notification which occurs after the |
| 1745 // navigation |
| 1746 // is committed. This causes a number of layout tests to fail. We |
| 1747 // workaround this by invoking the didStartProvisionalLoad() |
| 1748 // notification |
| 1749 // here. Consumers of the didStartProvisionalLoad() notification rely on |
| 1750 // the provisional loader and save navigation state in it. We want to |
| 1751 // avoid |
| 1752 // this dependency on the provisional loader. For now we create a |
| 1753 // temporary |
| 1754 // loader and pass it to the didStartProvisionalLoad() function. |
| 1755 // TODO(ananta) |
| 1756 // We should get rid of the dependency on the DocumentLoader in |
| 1757 // consumers |
| 1758 // of |
| 1759 // the didStartProvisionalLoad() notification. |
| 1760 client()->dispatchDidStartProvisionalLoad(loader); |
| 1761 DCHECK(loader); |
| 1762 loader->setSentDidFinishLoad(); |
| 1763 loader->detachFromFrame(); |
| 1764 } |
1739 } | 1765 } |
1740 return; | 1766 return; |
1741 } | 1767 } |
1742 | 1768 |
1743 m_provisionalDocumentLoader = client()->createDocumentLoader( | 1769 m_provisionalDocumentLoader = createDocumentLoader( |
1744 m_frame, resourceRequest, | 1770 resourceRequest, frameLoadRequest, type, navigationType); |
1745 frameLoadRequest.substituteData().isValid() | |
1746 ? frameLoadRequest.substituteData() | |
1747 : defaultSubstituteDataForURL(resourceRequest.url()), | |
1748 frameLoadRequest.clientRedirect()); | |
1749 m_provisionalDocumentLoader->setLoadType(type); | |
1750 m_provisionalDocumentLoader->setNavigationType(navigationType); | |
1751 m_provisionalDocumentLoader->setReplacesCurrentHistoryItem( | |
1752 type == FrameLoadTypeReplaceCurrentItem); | |
1753 | 1771 |
1754 // PlzNavigate: We need to ensure that script initiated navigations are | 1772 // PlzNavigate: We need to ensure that script initiated navigations are |
1755 // honored. | 1773 // honored. |
1756 if (!m_isNavigationHandledByClient) { | 1774 if (!m_isNavigationHandledByClient) { |
1757 m_frame->navigationScheduler().cancel(); | 1775 m_frame->navigationScheduler().cancel(); |
1758 m_checkTimer.stop(); | 1776 m_checkTimer.stop(); |
1759 } | 1777 } |
1760 | 1778 |
1761 if (frameLoadRequest.form()) | 1779 if (frameLoadRequest.form()) |
1762 client()->dispatchWillSubmitForm(frameLoadRequest.form()); | 1780 client()->dispatchWillSubmitForm(frameLoadRequest.form()); |
1763 | 1781 |
1764 // If the loader wasn't waiting for the client to handle a navigation, update | 1782 // If the loader wasn't waiting for the client to handle a navigation, update |
1765 // the progress tracker. Otherwise don't, as it was already notified before | 1783 // the progress tracker. Otherwise don't, as it was already notified before |
1766 // sending the navigation to teh client. | 1784 // sending the navigation to teh client. |
1767 if (!m_isNavigationHandledByClient) | 1785 if (!m_isNavigationHandledByClient) |
1768 m_progressTracker->progressStarted(type); | 1786 m_progressTracker->progressStarted(type); |
1769 else | 1787 else |
1770 m_isNavigationHandledByClient = false; | 1788 m_isNavigationHandledByClient = false; |
1771 | 1789 |
1772 m_provisionalDocumentLoader->appendRedirect( | 1790 m_provisionalDocumentLoader->appendRedirect( |
1773 m_provisionalDocumentLoader->getRequest().url()); | 1791 m_provisionalDocumentLoader->getRequest().url()); |
1774 client()->dispatchDidStartProvisionalLoad(); | 1792 // TODO(ananta) |
| 1793 // We should get rid of the dependency on the DocumentLoader in consumers of |
| 1794 // the didStartProvisionalLoad() notification. |
| 1795 client()->dispatchDidStartProvisionalLoad(m_provisionalDocumentLoader); |
1775 DCHECK(m_provisionalDocumentLoader); | 1796 DCHECK(m_provisionalDocumentLoader); |
| 1797 |
1776 m_provisionalDocumentLoader->startLoadingMainResource(); | 1798 m_provisionalDocumentLoader->startLoadingMainResource(); |
1777 | 1799 |
1778 takeObjectSnapshot(); | 1800 takeObjectSnapshot(); |
1779 } | 1801 } |
1780 | 1802 |
1781 void FrameLoader::applyUserAgent(ResourceRequest& request) { | 1803 void FrameLoader::applyUserAgent(ResourceRequest& request) { |
1782 String userAgent = this->userAgent(); | 1804 String userAgent = this->userAgent(); |
1783 DCHECK(!userAgent.isNull()); | 1805 DCHECK(!userAgent.isNull()); |
1784 request.setHTTPUserAgent(AtomicString(userAgent)); | 1806 request.setHTTPUserAgent(AtomicString(userAgent)); |
1785 } | 1807 } |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1956 tracedValue->setString("documentLoaderURL", | 1978 tracedValue->setString("documentLoaderURL", |
1957 m_documentLoader ? m_documentLoader->url() : String()); | 1979 m_documentLoader ? m_documentLoader->url() : String()); |
1958 return tracedValue; | 1980 return tracedValue; |
1959 } | 1981 } |
1960 | 1982 |
1961 inline void FrameLoader::takeObjectSnapshot() const { | 1983 inline void FrameLoader::takeObjectSnapshot() const { |
1962 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, | 1984 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, |
1963 toTracedValue()); | 1985 toTracedValue()); |
1964 } | 1986 } |
1965 | 1987 |
| 1988 DocumentLoader* FrameLoader::createDocumentLoader( |
| 1989 const ResourceRequest& request, |
| 1990 const FrameLoadRequest& frameLoadRequest, |
| 1991 FrameLoadType loadType, |
| 1992 NavigationType navigationType) { |
| 1993 DocumentLoader* loader = client()->createDocumentLoader( |
| 1994 m_frame, request, frameLoadRequest.substituteData().isValid() |
| 1995 ? frameLoadRequest.substituteData() |
| 1996 : defaultSubstituteDataForURL(request.url()), |
| 1997 frameLoadRequest.clientRedirect()); |
| 1998 |
| 1999 loader->setLoadType(loadType); |
| 2000 loader->setNavigationType(navigationType); |
| 2001 loader->setReplacesCurrentHistoryItem(loadType == |
| 2002 FrameLoadTypeReplaceCurrentItem); |
| 2003 return loader; |
| 2004 } |
| 2005 |
1966 } // namespace blink | 2006 } // namespace blink |
OLD | NEW |