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 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 if (!frame()->script().callFunction(function, receiver, argc, static_cast<v8
::Local<v8::Value>*>(argv)).ToLocal(&result)) | 906 if (!frame()->script().callFunction(function, receiver, argc, static_cast<v8
::Local<v8::Value>*>(argv)).ToLocal(&result)) |
907 return v8::Local<v8::Value>(); | 907 return v8::Local<v8::Value>(); |
908 return result; | 908 return result; |
909 } | 909 } |
910 | 910 |
911 v8::Local<v8::Context> WebLocalFrameImpl::mainWorldScriptContext() const | 911 v8::Local<v8::Context> WebLocalFrameImpl::mainWorldScriptContext() const |
912 { | 912 { |
913 return toV8Context(frame(), DOMWrapperWorld::mainWorld()); | 913 return toV8Context(frame(), DOMWrapperWorld::mainWorld()); |
914 } | 914 } |
915 | 915 |
| 916 WebURLRequest WebLocalFrameImpl::RequestFromHistoryItem(const WebHistoryItem& it
em, |
| 917 WebURLRequest::CachePolicy cachePolicy) const |
| 918 { |
| 919 RefPtrWillBeRawPtr<HistoryItem> historyItem = PassRefPtrWillBeRawPtr<History
Item>(item); |
| 920 ResourceRequest request = FrameLoader::resourceRequestFromHistoryItem( |
| 921 historyItem.get(), static_cast<ResourceRequestCachePolicy>(cachePolicy))
; |
| 922 return WrappedResourceRequest(request); |
| 923 } |
| 924 |
| 925 WebURLRequest WebLocalFrameImpl::RequestForReload(const WebHistoryItem& item, |
| 926 WebFrameLoadType loadType, const WebURL& overrideUrl) const |
| 927 { |
| 928 ASSERT(frame()); |
| 929 RefPtrWillBeRawPtr<HistoryItem> historyItem = PassRefPtrWillBeRawPtr<History
Item>(item); |
| 930 ResourceRequest request = FrameLoader::resourceRequestForReload( |
| 931 historyItem.get(), *frame(), static_cast<FrameLoadType>(loadType), overr
ideUrl); |
| 932 return WrappedResourceRequest(request); |
| 933 } |
| 934 |
| 935 WebHistoryItem WebLocalFrameImpl::CurrentItem() const |
| 936 { |
| 937 return WebHistoryItem(frame()->loader().currentItem()); |
| 938 } |
| 939 |
916 void WebLocalFrameImpl::reload(bool ignoreCache) | 940 void WebLocalFrameImpl::reload(bool ignoreCache) |
917 { | 941 { |
918 ASSERT(frame()); | 942 // TODO(clamy): Remove this function once RenderFrame calls loadRequest for |
919 frame()->loader().reload(ignoreCache ? EndToEndReload : NormalReload); | 943 // all requests. |
| 944 reloadWithOverrideURL(KURL(), ignoreCache); |
920 } | 945 } |
921 | 946 |
922 void WebLocalFrameImpl::reloadWithOverrideURL(const WebURL& overrideUrl, bool ig
noreCache) | 947 void WebLocalFrameImpl::reloadWithOverrideURL(const WebURL& overrideUrl, bool ig
noreCache) |
923 { | 948 { |
| 949 // TODO(clamy): Remove this function once RenderFrame calls loadRequest for |
| 950 // all requests. |
924 ASSERT(frame()); | 951 ASSERT(frame()); |
925 frame()->loader().reload(ignoreCache ? EndToEndReload : NormalReload, overri
deUrl); | 952 WebFrameLoadType loadType = ignoreCache ? |
| 953 WebFrameLoadTypeReloadFromOrigin : WebFrameLoadTypeReload; |
| 954 WebHistoryItem item = CurrentItem(); |
| 955 if (item.isNull()) |
| 956 return; |
| 957 WebURLRequest request = RequestForReload(item, loadType, overrideUrl); |
| 958 loadRequest(request, loadType, WebHistoryItem()); |
926 } | 959 } |
927 | 960 |
928 void WebLocalFrameImpl::reloadImage(const WebNode& webNode) | 961 void WebLocalFrameImpl::reloadImage(const WebNode& webNode) |
929 { | 962 { |
930 const Node* node = webNode.constUnwrap<Node>(); | 963 const Node* node = webNode.constUnwrap<Node>(); |
931 if (isHTMLImageElement(*node)) { | 964 if (isHTMLImageElement(*node)) { |
932 const HTMLImageElement& imageElement = toHTMLImageElement(*node); | 965 const HTMLImageElement& imageElement = toHTMLImageElement(*node); |
933 imageElement.forceReload(); | 966 imageElement.forceReload(); |
934 } | 967 } |
935 } | 968 } |
936 | 969 |
937 void WebLocalFrameImpl::loadRequest(const WebURLRequest& request) | 970 void WebLocalFrameImpl::loadRequest(const WebURLRequest& request, WebFrameLoadTy
pe webFrameLoadType, |
| 971 const WebHistoryItem& item) |
938 { | 972 { |
939 ASSERT(frame()); | 973 ASSERT(frame()); |
940 ASSERT(!request.isNull()); | 974 ASSERT(!request.isNull()); |
941 const ResourceRequest& resourceRequest = request.toResourceRequest(); | 975 const ResourceRequest& resourceRequest = request.toResourceRequest(); |
942 | 976 |
943 if (resourceRequest.url().protocolIs("javascript")) { | 977 if (resourceRequest.url().protocolIs("javascript") |
| 978 && webFrameLoadType == WebFrameLoadTypeStandard) { |
944 loadJavaScriptURL(resourceRequest.url()); | 979 loadJavaScriptURL(resourceRequest.url()); |
945 return; | 980 return; |
946 } | 981 } |
947 | 982 |
948 frame()->loader().load(FrameLoadRequest(0, resourceRequest)); | 983 FrameLoadRequest frameRequest = FrameLoadRequest(nullptr, resourceRequest); |
| 984 if (webFrameLoadType == WebFrameLoadTypeReload |
| 985 || webFrameLoadType == WebFrameLoadTypeReloadFromOrigin) |
| 986 frameRequest = FrameLoader::frameRequestForReload(resourceRequest); |
| 987 |
| 988 RefPtrWillBeRawPtr<HistoryItem> historyItem = PassRefPtrWillBeRawPtr<History
Item>(item); |
| 989 frame()->loader().load( |
| 990 frameRequest, static_cast<FrameLoadType>(webFrameLoadType), historyItem.
get()); |
949 } | 991 } |
950 | 992 |
951 void WebLocalFrameImpl::loadHistoryItem(const WebHistoryItem& item, WebHistoryLo
adType loadType, WebURLRequest::CachePolicy cachePolicy) | 993 void WebLocalFrameImpl::loadHistoryItem(const WebHistoryItem& item, WebHistoryLo
adType loadType, |
| 994 WebURLRequest::CachePolicy cachePolicy) |
952 { | 995 { |
953 ASSERT(frame()); | 996 // TODO(clamy): Remove this function once RenderFrame calls loadRequest for |
954 RefPtrWillBeRawPtr<HistoryItem> historyItem = PassRefPtrWillBeRawPtr<History
Item>(item); | 997 // all requests. |
955 ASSERT(historyItem); | 998 WebURLRequest request = RequestFromHistoryItem(item, cachePolicy); |
956 frame()->loader().loadHistoryItem(historyItem.get(), FrameLoadTypeBackForwar
d, | 999 WebFrameLoadType frameLoadType = loadType == WebHistorySameDocumentLoad ? |
957 static_cast<HistoryLoadType>(loadType), static_cast<ResourceRequestCache
Policy>(cachePolicy)); | 1000 WebFrameLoadTypeHistorySameDocument : WebFrameLoadTypeBackForward; |
| 1001 loadRequest(request, frameLoadType, item); |
958 } | 1002 } |
959 | 1003 |
960 void WebLocalFrameImpl::loadData(const WebData& data, const WebString& mimeType,
const WebString& textEncoding, const WebURL& baseURL, const WebURL& unreachable
URL, bool replace) | 1004 void WebLocalFrameImpl::loadData(const WebData& data, const WebString& mimeType,
const WebString& textEncoding, const WebURL& baseURL, const WebURL& unreachable
URL, bool replace) |
961 { | 1005 { |
962 ASSERT(frame()); | 1006 ASSERT(frame()); |
963 | 1007 |
964 // If we are loading substitute data to replace an existing load, then | 1008 // If we are loading substitute data to replace an existing load, then |
965 // inherit all of the properties of that original request. This way, | 1009 // inherit all of the properties of that original request. This way, |
966 // reload will re-attempt the original request. It is essential that | 1010 // reload will re-attempt the original request. It is essential that |
967 // we only do this when there is an unreachableURL since a non-empty | 1011 // we only do this when there is an unreachableURL since a non-empty |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1702 // it may dispatch a load event in the parent. | 1746 // it may dispatch a load event in the parent. |
1703 if (!child->tree().parent()) | 1747 if (!child->tree().parent()) |
1704 return nullptr; | 1748 return nullptr; |
1705 | 1749 |
1706 // If we're moving in the back/forward list, we might want to replace the co
ntent | 1750 // If we're moving in the back/forward list, we might want to replace the co
ntent |
1707 // of this child frame with whatever was there at that point. | 1751 // of this child frame with whatever was there at that point. |
1708 RefPtrWillBeRawPtr<HistoryItem> childItem = nullptr; | 1752 RefPtrWillBeRawPtr<HistoryItem> childItem = nullptr; |
1709 if (isBackForwardLoadType(frame()->loader().loadType()) && !frame()->documen
t()->loadEventFinished()) | 1753 if (isBackForwardLoadType(frame()->loader().loadType()) && !frame()->documen
t()->loadEventFinished()) |
1710 childItem = PassRefPtrWillBeRawPtr<HistoryItem>(webframeChild->client()-
>historyItemForNewChildFrame(webframeChild)); | 1754 childItem = PassRefPtrWillBeRawPtr<HistoryItem>(webframeChild->client()-
>historyItemForNewChildFrame(webframeChild)); |
1711 | 1755 |
1712 if (childItem) | 1756 FrameLoadRequest newRequest = request; |
1713 child->loader().loadHistoryItem(childItem.get(), FrameLoadTypeInitialHis
toryLoad); | 1757 FrameLoadType loadType = FrameLoadTypeStandard; |
1714 else | 1758 if (childItem) { |
1715 child->loader().load(request); | 1759 newRequest = FrameLoadRequest(request.originDocument(), |
| 1760 FrameLoader::resourceRequestFromHistoryItem(childItem.get(), UseProt
ocolCachePolicy)); |
| 1761 loadType = FrameLoadTypeInitialHistoryLoad; |
| 1762 } |
| 1763 child->loader().load(newRequest, loadType, childItem.get()); |
1716 | 1764 |
1717 // Note a synchronous navigation (about:blank) would have already processed | 1765 // Note a synchronous navigation (about:blank) would have already processed |
1718 // onload, so it is possible for the child frame to have already been | 1766 // onload, so it is possible for the child frame to have already been |
1719 // detached by script in the page. | 1767 // detached by script in the page. |
1720 if (!child->tree().parent()) | 1768 if (!child->tree().parent()) |
1721 return nullptr; | 1769 return nullptr; |
1722 return child; | 1770 return child; |
1723 } | 1771 } |
1724 | 1772 |
1725 void WebLocalFrameImpl::didChangeContentsSize(const IntSize& size) | 1773 void WebLocalFrameImpl::didChangeContentsSize(const IntSize& size) |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2088 { | 2136 { |
2089 m_frameWidget = frameWidget; | 2137 m_frameWidget = frameWidget; |
2090 } | 2138 } |
2091 | 2139 |
2092 WebFrameWidgetImpl* WebLocalFrameImpl::frameWidget() const | 2140 WebFrameWidgetImpl* WebLocalFrameImpl::frameWidget() const |
2093 { | 2141 { |
2094 return m_frameWidget; | 2142 return m_frameWidget; |
2095 } | 2143 } |
2096 | 2144 |
2097 } // namespace blink | 2145 } // namespace blink |
OLD | NEW |