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