Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: third_party/WebKit/Source/web/WebLocalFrameImpl.cpp

Issue 2710983003: Move HistoryItem handling to DocumentLoader (Closed)
Patch Set: Experiment to fix DCHECKing tests Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1671 // If we're moving in the back/forward list, we might want to replace the 1671 // If we're moving in the back/forward list, we might want to replace the
1672 // content of this child frame with whatever was there at that point. 1672 // content of this child frame with whatever was there at that point.
1673 HistoryItem* childItem = nullptr; 1673 HistoryItem* childItem = nullptr;
1674 if (isBackForwardLoadType(frame()->loader().documentLoader()->loadType()) && 1674 if (isBackForwardLoadType(frame()->loader().documentLoader()->loadType()) &&
1675 !frame()->document()->loadEventFinished()) 1675 !frame()->document()->loadEventFinished())
1676 childItem = webframeChild->client()->historyItemForNewChildFrame(); 1676 childItem = webframeChild->client()->historyItemForNewChildFrame();
1677 1677
1678 FrameLoadRequest newRequest = request; 1678 FrameLoadRequest newRequest = request;
1679 FrameLoadType loadType = FrameLoadTypeStandard; 1679 FrameLoadType loadType = FrameLoadTypeStandard;
1680 if (childItem) { 1680 if (childItem) {
1681 newRequest = FrameLoadRequest( 1681 newRequest = FrameLoadRequest(request.originDocument(),
1682 request.originDocument(), 1682 childItem->generateResourceRequest(
1683 FrameLoader::resourceRequestFromHistoryItem( 1683 WebCachePolicy::UseProtocolCachePolicy));
1684 childItem, WebCachePolicy::UseProtocolCachePolicy));
1685 loadType = FrameLoadTypeInitialHistoryLoad; 1684 loadType = FrameLoadTypeInitialHistoryLoad;
1686 } 1685 }
1687 webframeChild->frame()->loader().load(newRequest, loadType, childItem); 1686 webframeChild->frame()->loader().load(newRequest, loadType, childItem);
1688 1687
1689 // Note a synchronous navigation (about:blank) would have already processed 1688 // Note a synchronous navigation (about:blank) would have already processed
1690 // onload, so it is possible for the child frame to have already been 1689 // onload, so it is possible for the child frame to have already been
1691 // detached by script in the page. 1690 // detached by script in the page.
1692 if (!webframeChild->parent()) 1691 if (!webframeChild->parent())
1693 return nullptr; 1692 return nullptr;
1694 return webframeChild->frame(); 1693 return webframeChild->frame();
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1988 if (!frame()) 1987 if (!frame())
1989 return true; 1988 return true;
1990 1989
1991 return frame()->loader().shouldClose(isReload); 1990 return frame()->loader().shouldClose(isReload);
1992 } 1991 }
1993 1992
1994 WebURLRequest WebLocalFrameImpl::requestFromHistoryItem( 1993 WebURLRequest WebLocalFrameImpl::requestFromHistoryItem(
1995 const WebHistoryItem& item, 1994 const WebHistoryItem& item,
1996 WebCachePolicy cachePolicy) const { 1995 WebCachePolicy cachePolicy) const {
1997 HistoryItem* historyItem = item; 1996 HistoryItem* historyItem = item;
1998 ResourceRequest request = 1997 return WrappedResourceRequest(
1999 FrameLoader::resourceRequestFromHistoryItem(historyItem, cachePolicy); 1998 historyItem->generateResourceRequest(cachePolicy));
2000 return WrappedResourceRequest(request);
2001 } 1999 }
2002 2000
2003 WebURLRequest WebLocalFrameImpl::requestForReload( 2001 WebURLRequest WebLocalFrameImpl::requestForReload(
2004 WebFrameLoadType loadType, 2002 WebFrameLoadType loadType,
2005 const WebURL& overrideUrl) const { 2003 const WebURL& overrideUrl) const {
2006 DCHECK(frame()); 2004 DCHECK(frame());
2007 ResourceRequest request = frame()->loader().resourceRequestForReload( 2005 ResourceRequest request = frame()->loader().resourceRequestForReload(
2008 static_cast<FrameLoadType>(loadType), overrideUrl); 2006 static_cast<FrameLoadType>(loadType), overrideUrl);
2009 return WrappedResourceRequest(request); 2007 return WrappedResourceRequest(request);
2010 } 2008 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2045 bool isClientRedirect) { 2043 bool isClientRedirect) {
2046 DCHECK(frame()); 2044 DCHECK(frame());
2047 2045
2048 // If we are loading substitute data to replace an existing load, then 2046 // If we are loading substitute data to replace an existing load, then
2049 // inherit all of the properties of that original request. This way, 2047 // inherit all of the properties of that original request. This way,
2050 // reload will re-attempt the original request. It is essential that 2048 // reload will re-attempt the original request. It is essential that
2051 // we only do this when there is an unreachableURL since a non-empty 2049 // we only do this when there is an unreachableURL since a non-empty
2052 // unreachableURL informs FrameLoader::reload to load unreachableURL 2050 // unreachableURL informs FrameLoader::reload to load unreachableURL
2053 // instead of the currently loaded URL. 2051 // instead of the currently loaded URL.
2054 ResourceRequest request; 2052 ResourceRequest request;
2055 if (replace && !unreachableURL.isEmpty() && 2053 HistoryItem* historyItem = item;
2056 frame()->loader().provisionalDocumentLoader()) 2054 DocumentLoader* provisionalDocumentLoader =
2057 request = frame()->loader().provisionalDocumentLoader()->originalRequest(); 2055 frame()->loader().provisionalDocumentLoader();
2056 if (replace && !unreachableURL.isEmpty() && provisionalDocumentLoader) {
2057 request = provisionalDocumentLoader->originalRequest();
2058 if (provisionalDocumentLoader->loadType() == FrameLoadTypeBackForward) {
2059 historyItem = provisionalDocumentLoader->historyItem();
yhirano 2017/03/29 09:38:13 Where is this line (i.e., L2059) from?
Nate Chapin 2017/03/29 18:23:06 Yeah, I should have mentioned this, sorry. This li
kinuko 2017/03/30 05:05:00 Could we note some of this as code comment, e.g. '
Nate Chapin 2017/03/30 20:13:56 Done.
2060 webFrameLoadType = WebFrameLoadType::BackForward;
2061 }
2062 }
2058 request.setURL(baseURL); 2063 request.setURL(baseURL);
2059 request.setCheckForBrowserSideNavigation(false); 2064 request.setCheckForBrowserSideNavigation(false);
2060 2065
2061 FrameLoadRequest frameRequest( 2066 FrameLoadRequest frameRequest(
2062 0, request, SubstituteData(data, mimeType, textEncoding, unreachableURL)); 2067 0, request, SubstituteData(data, mimeType, textEncoding, unreachableURL));
2063 DCHECK(frameRequest.substituteData().isValid()); 2068 DCHECK(frameRequest.substituteData().isValid());
2064 frameRequest.setReplacesCurrentItem(replace); 2069 frameRequest.setReplacesCurrentItem(replace);
2065 if (isClientRedirect) 2070 if (isClientRedirect)
2066 frameRequest.setClientRedirect(ClientRedirectPolicy::ClientRedirect); 2071 frameRequest.setClientRedirect(ClientRedirectPolicy::ClientRedirect);
2067 2072
2068 HistoryItem* historyItem = item;
2069 frame()->loader().load( 2073 frame()->loader().load(
2070 frameRequest, static_cast<FrameLoadType>(webFrameLoadType), historyItem, 2074 frameRequest, static_cast<FrameLoadType>(webFrameLoadType), historyItem,
2071 static_cast<HistoryLoadType>(webHistoryLoadType)); 2075 static_cast<HistoryLoadType>(webHistoryLoadType));
2072 } 2076 }
2073 2077
2074 bool WebLocalFrameImpl::maybeRenderFallbackContent( 2078 bool WebLocalFrameImpl::maybeRenderFallbackContent(
2075 const WebURLError& error) const { 2079 const WebURLError& error) const {
2076 DCHECK(frame()); 2080 DCHECK(frame());
2077 2081
2078 if (!frame()->owner() || !frame()->owner()->canRenderFallbackContent()) 2082 if (!frame()->owner() || !frame()->owner()->canRenderFallbackContent())
2079 return false; 2083 return false;
2080 2084
2081 FrameLoader& frameloader = frame()->loader(); 2085 DCHECK(frame()->loader().provisionalDocumentLoader());
2082 DCHECK(frameloader.provisionalDocumentLoader()); 2086 frame()->loader().provisionalDocumentLoader()->loadFailed(error);
2083 frameloader.loadFailed(frameloader.provisionalDocumentLoader(), error);
2084 return true; 2087 return true;
2085 } 2088 }
2086 2089
2087 // Called when a navigation is blocked because a Content Security Policy (CSP) 2090 // Called when a navigation is blocked because a Content Security Policy (CSP)
2088 // is infringed. 2091 // is infringed.
2089 void WebLocalFrameImpl::reportContentSecurityPolicyViolation( 2092 void WebLocalFrameImpl::reportContentSecurityPolicyViolation(
2090 const blink::WebContentSecurityPolicyViolation& violation) { 2093 const blink::WebContentSecurityPolicyViolation& violation) {
2091 DCHECK(frame() && frame()->document()); 2094 DCHECK(frame() && frame()->document());
2092 Document* document = frame()->document(); 2095 Document* document = frame()->document();
2093 Vector<String> reportEndpoints; 2096 Vector<String> reportEndpoints;
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
2505 createMarkup(startPosition, endPosition, AnnotateForInterchange, 2508 createMarkup(startPosition, endPosition, AnnotateForInterchange,
2506 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); 2509 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs);
2507 } else { 2510 } else {
2508 clipHtml = 2511 clipHtml =
2509 createMarkup(endPosition, startPosition, AnnotateForInterchange, 2512 createMarkup(endPosition, startPosition, AnnotateForInterchange,
2510 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); 2513 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs);
2511 } 2514 }
2512 } 2515 }
2513 2516
2514 } // namespace blink 2517 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698