Chromium Code Reviews| 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 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 // PlzNavigate: if the navigation is a commit of a client-handled |
| 1734 // navigation, record that there is no longer a navigation handled by the | 1734 // navigation, record that there is no longer a navigation handled by the |
| 1735 // client. | 1735 // client. |
| 1736 if (m_isNavigationHandledByClient && | 1736 if (m_isNavigationHandledByClient && |
|
Nate Chapin
2017/02/03 19:35:22
Nit: Can we make this if() block part of the new i
ananta
2017/02/03 20:42:00
Done.
| |
| 1737 !frameLoadRequest.resourceRequest().checkForBrowserSideNavigation()) { | 1737 !frameLoadRequest.resourceRequest().checkForBrowserSideNavigation()) { |
| 1738 m_isNavigationHandledByClient = false; | 1738 m_isNavigationHandledByClient = false; |
| 1739 } | 1739 } |
| 1740 if (m_isNavigationHandledByClient) { | |
| 1741 DocumentLoader* loader = createDocumentLoader( | |
| 1742 resourceRequest, frameLoadRequest, type, navigationType); | |
| 1743 // PlzNavigate: If the navigation is handled by the client, then the | |
| 1744 // didFinishDocumentLoad() event occurs before the | |
| 1745 // didStartProvisionalLoad() notification which occurs after the | |
| 1746 // navigation | |
| 1747 // is committed. This causes a number of layout tests to fail. We | |
| 1748 // workaround this by invoking the didStartProvisionalLoad() 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 consumers | |
| 1757 // of | |
| 1758 // the didStartProvisionalLoad() notification. | |
| 1759 client()->dispatchDidStartProvisionalLoad(loader); | |
| 1760 DCHECK(loader); | |
| 1761 loader->setSentDidFinishLoad(); | |
| 1762 loader->detachFromFrame(); | |
| 1763 } | |
| 1740 return; | 1764 return; |
| 1741 } | 1765 } |
| 1742 | 1766 |
| 1743 m_provisionalDocumentLoader = client()->createDocumentLoader( | 1767 m_provisionalDocumentLoader = createDocumentLoader( |
| 1744 m_frame, resourceRequest, | 1768 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 | 1769 |
| 1754 // PlzNavigate: We need to ensure that script initiated navigations are | 1770 // PlzNavigate: We need to ensure that script initiated navigations are |
| 1755 // honored. | 1771 // honored. |
| 1756 if (!m_isNavigationHandledByClient) { | 1772 if (!m_isNavigationHandledByClient) { |
| 1757 m_frame->navigationScheduler().cancel(); | 1773 m_frame->navigationScheduler().cancel(); |
| 1758 m_checkTimer.stop(); | 1774 m_checkTimer.stop(); |
| 1759 } | 1775 } |
| 1760 | 1776 |
| 1761 if (frameLoadRequest.form()) | 1777 if (frameLoadRequest.form()) |
| 1762 client()->dispatchWillSubmitForm(frameLoadRequest.form()); | 1778 client()->dispatchWillSubmitForm(frameLoadRequest.form()); |
| 1763 | 1779 |
| 1764 // If the loader wasn't waiting for the client to handle a navigation, update | 1780 // 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 | 1781 // the progress tracker. Otherwise don't, as it was already notified before |
| 1766 // sending the navigation to teh client. | 1782 // sending the navigation to teh client. |
| 1767 if (!m_isNavigationHandledByClient) | 1783 if (!m_isNavigationHandledByClient) |
| 1768 m_progressTracker->progressStarted(type); | 1784 m_progressTracker->progressStarted(type); |
| 1769 else | 1785 else |
| 1770 m_isNavigationHandledByClient = false; | 1786 m_isNavigationHandledByClient = false; |
| 1771 | 1787 |
| 1772 m_provisionalDocumentLoader->appendRedirect( | 1788 m_provisionalDocumentLoader->appendRedirect( |
| 1773 m_provisionalDocumentLoader->getRequest().url()); | 1789 m_provisionalDocumentLoader->getRequest().url()); |
| 1774 client()->dispatchDidStartProvisionalLoad(); | 1790 // TODO(ananta) |
| 1791 // We should get rid of the dependency on the DocumentLoader in consumers of | |
| 1792 // the didStartProvisionalLoad() notification. | |
| 1793 client()->dispatchDidStartProvisionalLoad(m_provisionalDocumentLoader); | |
|
Nate Chapin
2017/02/03 19:35:22
Why did this move back here? No objections, just c
ananta
2017/02/03 20:42:00
Sending the provisional load notification early ca
| |
| 1775 DCHECK(m_provisionalDocumentLoader); | 1794 DCHECK(m_provisionalDocumentLoader); |
| 1795 | |
| 1776 m_provisionalDocumentLoader->startLoadingMainResource(); | 1796 m_provisionalDocumentLoader->startLoadingMainResource(); |
| 1777 | 1797 |
| 1778 takeObjectSnapshot(); | 1798 takeObjectSnapshot(); |
| 1779 } | 1799 } |
| 1780 | 1800 |
| 1781 void FrameLoader::applyUserAgent(ResourceRequest& request) { | 1801 void FrameLoader::applyUserAgent(ResourceRequest& request) { |
| 1782 String userAgent = this->userAgent(); | 1802 String userAgent = this->userAgent(); |
| 1783 DCHECK(!userAgent.isNull()); | 1803 DCHECK(!userAgent.isNull()); |
| 1784 request.setHTTPUserAgent(AtomicString(userAgent)); | 1804 request.setHTTPUserAgent(AtomicString(userAgent)); |
| 1785 } | 1805 } |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1956 tracedValue->setString("documentLoaderURL", | 1976 tracedValue->setString("documentLoaderURL", |
| 1957 m_documentLoader ? m_documentLoader->url() : String()); | 1977 m_documentLoader ? m_documentLoader->url() : String()); |
| 1958 return tracedValue; | 1978 return tracedValue; |
| 1959 } | 1979 } |
| 1960 | 1980 |
| 1961 inline void FrameLoader::takeObjectSnapshot() const { | 1981 inline void FrameLoader::takeObjectSnapshot() const { |
| 1962 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, | 1982 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, |
| 1963 toTracedValue()); | 1983 toTracedValue()); |
| 1964 } | 1984 } |
| 1965 | 1985 |
| 1986 DocumentLoader* FrameLoader::createDocumentLoader( | |
| 1987 const ResourceRequest& request, | |
| 1988 const FrameLoadRequest& frameLoadRequest, | |
| 1989 FrameLoadType loadType, | |
| 1990 NavigationType navigationType) { | |
| 1991 DocumentLoader* loader = client()->createDocumentLoader( | |
| 1992 m_frame, request, frameLoadRequest.substituteData().isValid() | |
| 1993 ? frameLoadRequest.substituteData() | |
| 1994 : defaultSubstituteDataForURL(request.url()), | |
| 1995 frameLoadRequest.clientRedirect()); | |
| 1996 | |
| 1997 loader->setLoadType(loadType); | |
| 1998 loader->setNavigationType(navigationType); | |
| 1999 loader->setReplacesCurrentHistoryItem(loadType == | |
| 2000 FrameLoadTypeReplaceCurrentItem); | |
| 2001 return loader; | |
| 2002 } | |
| 2003 | |
| 1966 } // namespace blink | 2004 } // namespace blink |
| OLD | NEW |