| 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 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 return result; | 933 return result; |
| 934 } | 934 } |
| 935 | 935 |
| 936 v8::Local<v8::Context> WebLocalFrameImpl::mainWorldScriptContext() const | 936 v8::Local<v8::Context> WebLocalFrameImpl::mainWorldScriptContext() const |
| 937 { | 937 { |
| 938 return toV8Context(frame(), DOMWrapperWorld::mainWorld()); | 938 return toV8Context(frame(), DOMWrapperWorld::mainWorld()); |
| 939 } | 939 } |
| 940 | 940 |
| 941 void WebLocalFrameImpl::reload(bool ignoreCache) | 941 void WebLocalFrameImpl::reload(bool ignoreCache) |
| 942 { | 942 { |
| 943 ASSERT(frame()); | 943 // TODO(clamy): Remove this function once RenderFrame calls load for all |
| 944 frame()->loader().reload(ignoreCache ? EndToEndReload : NormalReload); | 944 // requests. |
| 945 reloadWithOverrideURL(KURL(), ignoreCache); |
| 945 } | 946 } |
| 946 | 947 |
| 947 void WebLocalFrameImpl::reloadWithOverrideURL(const WebURL& overrideUrl, bool ig
noreCache) | 948 void WebLocalFrameImpl::reloadWithOverrideURL(const WebURL& overrideUrl, bool ig
noreCache) |
| 948 { | 949 { |
| 950 // TODO(clamy): Remove this function once RenderFrame calls load for all |
| 951 // requests. |
| 949 ASSERT(frame()); | 952 ASSERT(frame()); |
| 950 frame()->loader().reload(ignoreCache ? EndToEndReload : NormalReload, overri
deUrl); | 953 WebFrameLoadType loadType = ignoreCache ? |
| 954 WebFrameLoadType::ReloadFromOrigin : WebFrameLoadType::Reload; |
| 955 WebURLRequest request = requestForReload(loadType, overrideUrl); |
| 956 if (request.isNull()) |
| 957 return; |
| 958 load(request, loadType, WebHistoryItem(), WebHistoryDifferentDocumentLoad); |
| 951 } | 959 } |
| 952 | 960 |
| 953 void WebLocalFrameImpl::reloadImage(const WebNode& webNode) | 961 void WebLocalFrameImpl::reloadImage(const WebNode& webNode) |
| 954 { | 962 { |
| 955 const Node* node = webNode.constUnwrap<Node>(); | 963 const Node* node = webNode.constUnwrap<Node>(); |
| 956 if (isHTMLImageElement(*node)) { | 964 if (isHTMLImageElement(*node)) { |
| 957 const HTMLImageElement& imageElement = toHTMLImageElement(*node); | 965 const HTMLImageElement& imageElement = toHTMLImageElement(*node); |
| 958 imageElement.forceReload(); | 966 imageElement.forceReload(); |
| 959 } | 967 } |
| 960 } | 968 } |
| 961 | 969 |
| 962 void WebLocalFrameImpl::loadRequest(const WebURLRequest& request) | 970 void WebLocalFrameImpl::loadRequest(const WebURLRequest& request) |
| 963 { | 971 { |
| 964 ASSERT(frame()); | 972 // TODO(clamy): Remove this function once RenderFrame calls load for all |
| 965 ASSERT(!request.isNull()); | 973 // requests. |
| 966 const ResourceRequest& resourceRequest = request.toResourceRequest(); | 974 load(request, WebFrameLoadType::Standard, WebHistoryItem(), WebHistoryDiffer
entDocumentLoad); |
| 967 | |
| 968 if (resourceRequest.url().protocolIs("javascript")) { | |
| 969 loadJavaScriptURL(resourceRequest.url()); | |
| 970 return; | |
| 971 } | |
| 972 | |
| 973 frame()->loader().load(FrameLoadRequest(0, resourceRequest)); | |
| 974 } | 975 } |
| 975 | 976 |
| 976 void WebLocalFrameImpl::loadHistoryItem(const WebHistoryItem& item, WebHistoryLo
adType loadType, WebURLRequest::CachePolicy cachePolicy) | 977 void WebLocalFrameImpl::loadHistoryItem(const WebHistoryItem& item, WebHistoryLo
adType loadType, |
| 978 WebURLRequest::CachePolicy cachePolicy) |
| 977 { | 979 { |
| 978 ASSERT(frame()); | 980 // TODO(clamy): Remove this function once RenderFrame calls load for all |
| 979 RefPtrWillBeRawPtr<HistoryItem> historyItem = PassRefPtrWillBeRawPtr<History
Item>(item); | 981 // requests. |
| 980 ASSERT(historyItem); | 982 WebURLRequest request = requestFromHistoryItem(item, cachePolicy); |
| 981 frame()->loader().loadHistoryItem(historyItem.get(), FrameLoadTypeBackForwar
d, | 983 load(request, WebFrameLoadType::BackForward, item, loadType); |
| 982 static_cast<HistoryLoadType>(loadType), static_cast<ResourceRequestCache
Policy>(cachePolicy)); | |
| 983 } | 984 } |
| 984 | 985 |
| 985 void WebLocalFrameImpl::loadData(const WebData& data, const WebString& mimeType,
const WebString& textEncoding, const WebURL& baseURL, const WebURL& unreachable
URL, bool replace) | 986 void WebLocalFrameImpl::loadData(const WebData& data, const WebString& mimeType,
const WebString& textEncoding, const WebURL& baseURL, const WebURL& unreachable
URL, bool replace) |
| 986 { | 987 { |
| 987 ASSERT(frame()); | 988 ASSERT(frame()); |
| 988 | 989 |
| 989 // If we are loading substitute data to replace an existing load, then | 990 // If we are loading substitute data to replace an existing load, then |
| 990 // inherit all of the properties of that original request. This way, | 991 // inherit all of the properties of that original request. This way, |
| 991 // reload will re-attempt the original request. It is essential that | 992 // reload will re-attempt the original request. It is essential that |
| 992 // we only do this when there is an unreachableURL since a non-empty | 993 // we only do this when there is an unreachableURL since a non-empty |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1723 // it may dispatch a load event in the parent. | 1724 // it may dispatch a load event in the parent. |
| 1724 if (!child->tree().parent()) | 1725 if (!child->tree().parent()) |
| 1725 return nullptr; | 1726 return nullptr; |
| 1726 | 1727 |
| 1727 // If we're moving in the back/forward list, we might want to replace the co
ntent | 1728 // If we're moving in the back/forward list, we might want to replace the co
ntent |
| 1728 // of this child frame with whatever was there at that point. | 1729 // of this child frame with whatever was there at that point. |
| 1729 RefPtrWillBeRawPtr<HistoryItem> childItem = nullptr; | 1730 RefPtrWillBeRawPtr<HistoryItem> childItem = nullptr; |
| 1730 if (isBackForwardLoadType(frame()->loader().loadType()) && !frame()->documen
t()->loadEventFinished()) | 1731 if (isBackForwardLoadType(frame()->loader().loadType()) && !frame()->documen
t()->loadEventFinished()) |
| 1731 childItem = PassRefPtrWillBeRawPtr<HistoryItem>(webframeChild->client()-
>historyItemForNewChildFrame(webframeChild)); | 1732 childItem = PassRefPtrWillBeRawPtr<HistoryItem>(webframeChild->client()-
>historyItemForNewChildFrame(webframeChild)); |
| 1732 | 1733 |
| 1733 if (childItem) | 1734 FrameLoadRequest newRequest = request; |
| 1734 child->loader().loadHistoryItem(childItem.get(), FrameLoadTypeInitialHis
toryLoad); | 1735 FrameLoadType loadType = FrameLoadTypeStandard; |
| 1735 else | 1736 if (childItem) { |
| 1736 child->loader().load(request); | 1737 newRequest = FrameLoadRequest(request.originDocument(), |
| 1738 FrameLoader::resourceRequestFromHistoryItem(childItem.get(), UseProt
ocolCachePolicy)); |
| 1739 loadType = FrameLoadTypeInitialHistoryLoad; |
| 1740 } |
| 1741 child->loader().load(newRequest, loadType, childItem.get()); |
| 1737 | 1742 |
| 1738 // Note a synchronous navigation (about:blank) would have already processed | 1743 // Note a synchronous navigation (about:blank) would have already processed |
| 1739 // onload, so it is possible for the child frame to have already been | 1744 // onload, so it is possible for the child frame to have already been |
| 1740 // detached by script in the page. | 1745 // detached by script in the page. |
| 1741 if (!child->tree().parent()) | 1746 if (!child->tree().parent()) |
| 1742 return nullptr; | 1747 return nullptr; |
| 1743 return child; | 1748 return child; |
| 1744 } | 1749 } |
| 1745 | 1750 |
| 1746 void WebLocalFrameImpl::didChangeContentsSize(const IntSize& size) | 1751 void WebLocalFrameImpl::didChangeContentsSize(const IntSize& size) |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2004 } | 2009 } |
| 2005 | 2010 |
| 2006 void WebLocalFrameImpl::sendPings(const WebNode& linkNode, const WebURL& destina
tionURL) | 2011 void WebLocalFrameImpl::sendPings(const WebNode& linkNode, const WebURL& destina
tionURL) |
| 2007 { | 2012 { |
| 2008 ASSERT(frame()); | 2013 ASSERT(frame()); |
| 2009 const Node* node = linkNode.constUnwrap<Node>(); | 2014 const Node* node = linkNode.constUnwrap<Node>(); |
| 2010 if (isHTMLAnchorElement(node)) | 2015 if (isHTMLAnchorElement(node)) |
| 2011 toHTMLAnchorElement(node)->sendPings(destinationURL); | 2016 toHTMLAnchorElement(node)->sendPings(destinationURL); |
| 2012 } | 2017 } |
| 2013 | 2018 |
| 2019 WebURLRequest WebLocalFrameImpl::requestFromHistoryItem(const WebHistoryItem& it
em, |
| 2020 WebURLRequest::CachePolicy cachePolicy) const |
| 2021 { |
| 2022 RefPtrWillBeRawPtr<HistoryItem> historyItem = PassRefPtrWillBeRawPtr<History
Item>(item); |
| 2023 ResourceRequest request = FrameLoader::resourceRequestFromHistoryItem( |
| 2024 historyItem.get(), static_cast<ResourceRequestCachePolicy>(cachePolicy))
; |
| 2025 return WrappedResourceRequest(request); |
| 2026 } |
| 2027 |
| 2028 WebURLRequest WebLocalFrameImpl::requestForReload(WebFrameLoadType loadType, |
| 2029 const WebURL& overrideUrl) const |
| 2030 { |
| 2031 ASSERT(frame()); |
| 2032 ResourceRequest request = frame()->loader().resourceRequestForReload( |
| 2033 static_cast<FrameLoadType>(loadType), overrideUrl); |
| 2034 return WrappedResourceRequest(request); |
| 2035 } |
| 2036 |
| 2037 void WebLocalFrameImpl::load(const WebURLRequest& request, WebFrameLoadType webF
rameLoadType, |
| 2038 const WebHistoryItem& item, WebHistoryLoadType webHistoryLoadType) |
| 2039 { |
| 2040 ASSERT(frame()); |
| 2041 ASSERT(!request.isNull()); |
| 2042 ASSERT(webFrameLoadType != WebFrameLoadType::RedirectWithLockedBackForwardLi
st); |
| 2043 const ResourceRequest& resourceRequest = request.toResourceRequest(); |
| 2044 |
| 2045 if (resourceRequest.url().protocolIs("javascript") |
| 2046 && webFrameLoadType == WebFrameLoadType::Standard) { |
| 2047 loadJavaScriptURL(resourceRequest.url()); |
| 2048 return; |
| 2049 } |
| 2050 |
| 2051 FrameLoadRequest frameRequest = FrameLoadRequest(nullptr, resourceRequest); |
| 2052 RefPtrWillBeRawPtr<HistoryItem> historyItem = PassRefPtrWillBeRawPtr<History
Item>(item); |
| 2053 frame()->loader().load( |
| 2054 frameRequest, static_cast<FrameLoadType>(webFrameLoadType), historyItem.
get(), |
| 2055 static_cast<HistoryLoadType>(webHistoryLoadType)); |
| 2056 } |
| 2057 |
| 2014 bool WebLocalFrameImpl::isLoading() const | 2058 bool WebLocalFrameImpl::isLoading() const |
| 2015 { | 2059 { |
| 2016 if (!frame() || !frame()->document()) | 2060 if (!frame() || !frame()->document()) |
| 2017 return false; | 2061 return false; |
| 2018 return frame()->loader().stateMachine()->isDisplayingInitialEmptyDocument()
|| frame()->loader().provisionalDocumentLoader() || !frame()->document()->loadEv
entFinished(); | 2062 return frame()->loader().stateMachine()->isDisplayingInitialEmptyDocument()
|| frame()->loader().provisionalDocumentLoader() || !frame()->document()->loadEv
entFinished(); |
| 2019 } | 2063 } |
| 2020 | 2064 |
| 2021 bool WebLocalFrameImpl::isResourceLoadInProgress() const | 2065 bool WebLocalFrameImpl::isResourceLoadInProgress() const |
| 2022 { | 2066 { |
| 2023 if (!frame() || !frame()->document()) | 2067 if (!frame() || !frame()->document()) |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2108 { | 2152 { |
| 2109 m_frameWidget = frameWidget; | 2153 m_frameWidget = frameWidget; |
| 2110 } | 2154 } |
| 2111 | 2155 |
| 2112 WebFrameWidgetImpl* WebLocalFrameImpl::frameWidget() const | 2156 WebFrameWidgetImpl* WebLocalFrameImpl::frameWidget() const |
| 2113 { | 2157 { |
| 2114 return m_frameWidget; | 2158 return m_frameWidget; |
| 2115 } | 2159 } |
| 2116 | 2160 |
| 2117 } // namespace blink | 2161 } // namespace blink |
| OLD | NEW |