OLD | NEW |
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 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1670 // If we're moving in the back/forward list, we might want to replace the | 1670 // If we're moving in the back/forward list, we might want to replace the |
1671 // content of this child frame with whatever was there at that point. | 1671 // content of this child frame with whatever was there at that point. |
1672 HistoryItem* childItem = nullptr; | 1672 HistoryItem* childItem = nullptr; |
1673 if (isBackForwardLoadType(frame()->loader().documentLoader()->loadType()) && | 1673 if (isBackForwardLoadType(frame()->loader().documentLoader()->loadType()) && |
1674 !frame()->document()->loadEventFinished()) | 1674 !frame()->document()->loadEventFinished()) |
1675 childItem = webframeChild->client()->historyItemForNewChildFrame(); | 1675 childItem = webframeChild->client()->historyItemForNewChildFrame(); |
1676 | 1676 |
1677 FrameLoadRequest newRequest = request; | 1677 FrameLoadRequest newRequest = request; |
1678 FrameLoadType loadType = FrameLoadTypeStandard; | 1678 FrameLoadType loadType = FrameLoadTypeStandard; |
1679 if (childItem) { | 1679 if (childItem) { |
1680 newRequest = FrameLoadRequest( | 1680 newRequest = FrameLoadRequest(request.originDocument(), |
1681 request.originDocument(), | 1681 childItem->generateResourceRequest( |
1682 FrameLoader::resourceRequestFromHistoryItem( | 1682 WebCachePolicy::UseProtocolCachePolicy)); |
1683 childItem, WebCachePolicy::UseProtocolCachePolicy)); | |
1684 loadType = FrameLoadTypeInitialHistoryLoad; | 1683 loadType = FrameLoadTypeInitialHistoryLoad; |
1685 } | 1684 } |
1686 webframeChild->frame()->loader().load(newRequest, loadType, childItem); | 1685 webframeChild->frame()->loader().load(newRequest, loadType, childItem); |
1687 | 1686 |
1688 // Note a synchronous navigation (about:blank) would have already processed | 1687 // Note a synchronous navigation (about:blank) would have already processed |
1689 // onload, so it is possible for the child frame to have already been | 1688 // onload, so it is possible for the child frame to have already been |
1690 // detached by script in the page. | 1689 // detached by script in the page. |
1691 if (!webframeChild->parent()) | 1690 if (!webframeChild->parent()) |
1692 return nullptr; | 1691 return nullptr; |
1693 return webframeChild->frame(); | 1692 return webframeChild->frame(); |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1987 if (!frame()) | 1986 if (!frame()) |
1988 return true; | 1987 return true; |
1989 | 1988 |
1990 return frame()->loader().shouldClose(isReload); | 1989 return frame()->loader().shouldClose(isReload); |
1991 } | 1990 } |
1992 | 1991 |
1993 WebURLRequest WebLocalFrameImpl::requestFromHistoryItem( | 1992 WebURLRequest WebLocalFrameImpl::requestFromHistoryItem( |
1994 const WebHistoryItem& item, | 1993 const WebHistoryItem& item, |
1995 WebCachePolicy cachePolicy) const { | 1994 WebCachePolicy cachePolicy) const { |
1996 HistoryItem* historyItem = item; | 1995 HistoryItem* historyItem = item; |
1997 ResourceRequest request = | 1996 return WrappedResourceRequest( |
1998 FrameLoader::resourceRequestFromHistoryItem(historyItem, cachePolicy); | 1997 historyItem->generateResourceRequest(cachePolicy)); |
1999 return WrappedResourceRequest(request); | |
2000 } | 1998 } |
2001 | 1999 |
2002 WebURLRequest WebLocalFrameImpl::requestForReload( | 2000 WebURLRequest WebLocalFrameImpl::requestForReload( |
2003 WebFrameLoadType loadType, | 2001 WebFrameLoadType loadType, |
2004 const WebURL& overrideUrl) const { | 2002 const WebURL& overrideUrl) const { |
2005 DCHECK(frame()); | 2003 DCHECK(frame()); |
2006 ResourceRequest request = frame()->loader().resourceRequestForReload( | 2004 ResourceRequest request = frame()->loader().resourceRequestForReload( |
2007 static_cast<FrameLoadType>(loadType), overrideUrl); | 2005 static_cast<FrameLoadType>(loadType), overrideUrl); |
2008 return WrappedResourceRequest(request); | 2006 return WrappedResourceRequest(request); |
2009 } | 2007 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2044 bool isClientRedirect) { | 2042 bool isClientRedirect) { |
2045 DCHECK(frame()); | 2043 DCHECK(frame()); |
2046 | 2044 |
2047 // If we are loading substitute data to replace an existing load, then | 2045 // If we are loading substitute data to replace an existing load, then |
2048 // inherit all of the properties of that original request. This way, | 2046 // inherit all of the properties of that original request. This way, |
2049 // reload will re-attempt the original request. It is essential that | 2047 // reload will re-attempt the original request. It is essential that |
2050 // we only do this when there is an unreachableURL since a non-empty | 2048 // we only do this when there is an unreachableURL since a non-empty |
2051 // unreachableURL informs FrameLoader::reload to load unreachableURL | 2049 // unreachableURL informs FrameLoader::reload to load unreachableURL |
2052 // instead of the currently loaded URL. | 2050 // instead of the currently loaded URL. |
2053 ResourceRequest request; | 2051 ResourceRequest request; |
2054 if (replace && !unreachableURL.isEmpty() && | 2052 HistoryItem* historyItem = item; |
2055 frame()->loader().provisionalDocumentLoader()) | 2053 DocumentLoader* provisionalDocumentLoader = |
2056 request = frame()->loader().provisionalDocumentLoader()->originalRequest(); | 2054 frame()->loader().provisionalDocumentLoader(); |
| 2055 if (replace && !unreachableURL.isEmpty() && provisionalDocumentLoader) { |
| 2056 request = provisionalDocumentLoader->originalRequest(); |
| 2057 // When replacing a failed back/forward provisional navigation with an error |
| 2058 // page, retain the HistoryItem for the failed provisional navigation |
| 2059 // and reuse it for the error page navigation. |
| 2060 if (provisionalDocumentLoader->loadType() == FrameLoadTypeBackForward) { |
| 2061 historyItem = provisionalDocumentLoader->historyItem(); |
| 2062 webFrameLoadType = WebFrameLoadType::BackForward; |
| 2063 } |
| 2064 } |
2057 request.setURL(baseURL); | 2065 request.setURL(baseURL); |
2058 request.setCheckForBrowserSideNavigation(false); | 2066 request.setCheckForBrowserSideNavigation(false); |
2059 | 2067 |
2060 FrameLoadRequest frameRequest( | 2068 FrameLoadRequest frameRequest( |
2061 0, request, SubstituteData(data, mimeType, textEncoding, unreachableURL)); | 2069 0, request, SubstituteData(data, mimeType, textEncoding, unreachableURL)); |
2062 DCHECK(frameRequest.substituteData().isValid()); | 2070 DCHECK(frameRequest.substituteData().isValid()); |
2063 frameRequest.setReplacesCurrentItem(replace); | 2071 frameRequest.setReplacesCurrentItem(replace); |
2064 if (isClientRedirect) | 2072 if (isClientRedirect) |
2065 frameRequest.setClientRedirect(ClientRedirectPolicy::ClientRedirect); | 2073 frameRequest.setClientRedirect(ClientRedirectPolicy::ClientRedirect); |
2066 | 2074 |
2067 HistoryItem* historyItem = item; | |
2068 frame()->loader().load( | 2075 frame()->loader().load( |
2069 frameRequest, static_cast<FrameLoadType>(webFrameLoadType), historyItem, | 2076 frameRequest, static_cast<FrameLoadType>(webFrameLoadType), historyItem, |
2070 static_cast<HistoryLoadType>(webHistoryLoadType)); | 2077 static_cast<HistoryLoadType>(webHistoryLoadType)); |
2071 } | 2078 } |
2072 | 2079 |
2073 bool WebLocalFrameImpl::maybeRenderFallbackContent( | 2080 bool WebLocalFrameImpl::maybeRenderFallbackContent( |
2074 const WebURLError& error) const { | 2081 const WebURLError& error) const { |
2075 DCHECK(frame()); | 2082 DCHECK(frame()); |
2076 | 2083 |
2077 if (!frame()->owner() || !frame()->owner()->canRenderFallbackContent()) | 2084 if (!frame()->owner() || !frame()->owner()->canRenderFallbackContent()) |
2078 return false; | 2085 return false; |
2079 | 2086 |
2080 FrameLoader& frameloader = frame()->loader(); | 2087 DCHECK(frame()->loader().provisionalDocumentLoader()); |
2081 DCHECK(frameloader.provisionalDocumentLoader()); | 2088 frame()->loader().provisionalDocumentLoader()->loadFailed(error); |
2082 frameloader.loadFailed(frameloader.provisionalDocumentLoader(), error); | |
2083 return true; | 2089 return true; |
2084 } | 2090 } |
2085 | 2091 |
2086 // Called when a navigation is blocked because a Content Security Policy (CSP) | 2092 // Called when a navigation is blocked because a Content Security Policy (CSP) |
2087 // is infringed. | 2093 // is infringed. |
2088 void WebLocalFrameImpl::reportContentSecurityPolicyViolation( | 2094 void WebLocalFrameImpl::reportContentSecurityPolicyViolation( |
2089 const blink::WebContentSecurityPolicyViolation& violation) { | 2095 const blink::WebContentSecurityPolicyViolation& violation) { |
2090 addMessageToConsole(blink::WebConsoleMessage( | 2096 addMessageToConsole(blink::WebConsoleMessage( |
2091 WebConsoleMessage::LevelError, violation.consoleMessage, | 2097 WebConsoleMessage::LevelError, violation.consoleMessage, |
2092 violation.sourceLocation.url, violation.sourceLocation.lineNumber, | 2098 violation.sourceLocation.url, violation.sourceLocation.lineNumber, |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2510 createMarkup(startPosition, endPosition, AnnotateForInterchange, | 2516 createMarkup(startPosition, endPosition, AnnotateForInterchange, |
2511 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); | 2517 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); |
2512 } else { | 2518 } else { |
2513 clipHtml = | 2519 clipHtml = |
2514 createMarkup(endPosition, startPosition, AnnotateForInterchange, | 2520 createMarkup(endPosition, startPosition, AnnotateForInterchange, |
2515 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); | 2521 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); |
2516 } | 2522 } |
2517 } | 2523 } |
2518 | 2524 |
2519 } // namespace blink | 2525 } // namespace blink |
OLD | NEW |