Chromium Code Reviews| 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(WebFrameLoadType loadType, | |
| 926 const WebURL& overrideUrl) const | |
| 927 { | |
| 928 ASSERT(frame()); | |
| 929 ResourceRequest request = frame()->loader().resourceRequestForReload( | |
| 930 *frame(), static_cast<FrameLoadType>(loadType), overrideUrl); | |
| 931 return WrappedResourceRequest(request); | |
| 932 } | |
| 933 | |
| 916 void WebLocalFrameImpl::reload(bool ignoreCache) | 934 void WebLocalFrameImpl::reload(bool ignoreCache) |
| 917 { | 935 { |
| 918 ASSERT(frame()); | 936 // TODO(clamy): Remove this function once RenderFrame calls loadRequest for |
| 919 frame()->loader().reload(ignoreCache ? EndToEndReload : NormalReload); | 937 // all requests. |
| 938 reloadWithOverrideURL(KURL(), ignoreCache); | |
| 920 } | 939 } |
| 921 | 940 |
| 922 void WebLocalFrameImpl::reloadWithOverrideURL(const WebURL& overrideUrl, bool ig noreCache) | 941 void WebLocalFrameImpl::reloadWithOverrideURL(const WebURL& overrideUrl, bool ig noreCache) |
| 923 { | 942 { |
| 943 // TODO(clamy): Remove this function once RenderFrame calls loadRequest for | |
| 944 // all requests. | |
| 924 ASSERT(frame()); | 945 ASSERT(frame()); |
| 925 frame()->loader().reload(ignoreCache ? EndToEndReload : NormalReload, overri deUrl); | 946 WebFrameLoadType loadType = ignoreCache ? ReloadFromOrigin : Reload; |
| 947 WebURLRequest request = requestForReload(loadType, overrideUrl); | |
| 948 if (request.isNull()) | |
| 949 return; | |
| 950 loadRequest(request, loadType, WebHistoryItem(), WebHistoryDifferentDocument Load); | |
| 926 } | 951 } |
| 927 | 952 |
| 928 void WebLocalFrameImpl::reloadImage(const WebNode& webNode) | 953 void WebLocalFrameImpl::reloadImage(const WebNode& webNode) |
| 929 { | 954 { |
| 930 const Node* node = webNode.constUnwrap<Node>(); | 955 const Node* node = webNode.constUnwrap<Node>(); |
| 931 if (isHTMLImageElement(*node)) { | 956 if (isHTMLImageElement(*node)) { |
| 932 const HTMLImageElement& imageElement = toHTMLImageElement(*node); | 957 const HTMLImageElement& imageElement = toHTMLImageElement(*node); |
| 933 imageElement.forceReload(); | 958 imageElement.forceReload(); |
| 934 } | 959 } |
| 935 } | 960 } |
| 936 | 961 |
| 937 void WebLocalFrameImpl::loadRequest(const WebURLRequest& request) | 962 void WebLocalFrameImpl::loadRequest(const WebURLRequest& request, WebFrameLoadTy pe webFrameLoadType, |
| 963 const WebHistoryItem& item, WebHistoryLoadType webHistoryLoadType) | |
| 938 { | 964 { |
| 939 ASSERT(frame()); | 965 ASSERT(frame()); |
| 940 ASSERT(!request.isNull()); | 966 ASSERT(!request.isNull()); |
| 941 const ResourceRequest& resourceRequest = request.toResourceRequest(); | 967 const ResourceRequest& resourceRequest = request.toResourceRequest(); |
| 942 | 968 |
| 943 if (resourceRequest.url().protocolIs("javascript")) { | 969 if (resourceRequest.url().protocolIs("javascript") && webFrameLoadType == St andard) { |
|
Nate Chapin
2015/06/02 17:19:35
Are there any situations where this will get calle
clamy
2015/06/03 14:39:14
I don't think so. Added an ASSERT to check that it
| |
| 944 loadJavaScriptURL(resourceRequest.url()); | 970 loadJavaScriptURL(resourceRequest.url()); |
| 945 return; | 971 return; |
| 946 } | 972 } |
| 947 | 973 |
| 948 frame()->loader().load(FrameLoadRequest(0, resourceRequest)); | 974 FrameLoadRequest frameRequest = FrameLoadRequest(nullptr, resourceRequest); |
| 975 if (webFrameLoadType == Reload || webFrameLoadType == ReloadFromOrigin) | |
| 976 frameRequest = FrameLoader::frameRequestForReload(resourceRequest); | |
| 977 | |
| 978 RefPtrWillBeRawPtr<HistoryItem> historyItem = PassRefPtrWillBeRawPtr<History Item>(item); | |
| 979 frame()->loader().load( | |
| 980 frameRequest, static_cast<FrameLoadType>(webFrameLoadType), historyItem. get(), | |
| 981 static_cast<HistoryLoadType>(webHistoryLoadType)); | |
| 949 } | 982 } |
| 950 | 983 |
| 951 void WebLocalFrameImpl::loadHistoryItem(const WebHistoryItem& item, WebHistoryLo adType loadType, WebURLRequest::CachePolicy cachePolicy) | 984 void WebLocalFrameImpl::loadHistoryItem(const WebHistoryItem& item, WebHistoryLo adType loadType, |
| 985 WebURLRequest::CachePolicy cachePolicy) | |
| 952 { | 986 { |
| 953 ASSERT(frame()); | 987 // TODO(clamy): Remove this function once RenderFrame calls loadRequest for |
| 954 RefPtrWillBeRawPtr<HistoryItem> historyItem = PassRefPtrWillBeRawPtr<History Item>(item); | 988 // all requests. |
| 955 ASSERT(historyItem); | 989 WebURLRequest request = requestFromHistoryItem(item, cachePolicy); |
| 956 frame()->loader().loadHistoryItem(historyItem.get(), FrameLoadTypeBackForwar d, | 990 loadRequest(request, BackForward, item, loadType); |
| 957 static_cast<HistoryLoadType>(loadType), static_cast<ResourceRequestCache Policy>(cachePolicy)); | |
| 958 } | 991 } |
| 959 | 992 |
| 960 void WebLocalFrameImpl::loadData(const WebData& data, const WebString& mimeType, const WebString& textEncoding, const WebURL& baseURL, const WebURL& unreachable URL, bool replace) | 993 void WebLocalFrameImpl::loadData(const WebData& data, const WebString& mimeType, const WebString& textEncoding, const WebURL& baseURL, const WebURL& unreachable URL, bool replace) |
| 961 { | 994 { |
| 962 ASSERT(frame()); | 995 ASSERT(frame()); |
| 963 | 996 |
| 964 // If we are loading substitute data to replace an existing load, then | 997 // If we are loading substitute data to replace an existing load, then |
| 965 // inherit all of the properties of that original request. This way, | 998 // inherit all of the properties of that original request. This way, |
| 966 // reload will re-attempt the original request. It is essential that | 999 // 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 | 1000 // 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. | 1735 // it may dispatch a load event in the parent. |
| 1703 if (!child->tree().parent()) | 1736 if (!child->tree().parent()) |
| 1704 return nullptr; | 1737 return nullptr; |
| 1705 | 1738 |
| 1706 // If we're moving in the back/forward list, we might want to replace the co ntent | 1739 // 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. | 1740 // of this child frame with whatever was there at that point. |
| 1708 RefPtrWillBeRawPtr<HistoryItem> childItem = nullptr; | 1741 RefPtrWillBeRawPtr<HistoryItem> childItem = nullptr; |
| 1709 if (isBackForwardLoadType(frame()->loader().loadType()) && !frame()->documen t()->loadEventFinished()) | 1742 if (isBackForwardLoadType(frame()->loader().loadType()) && !frame()->documen t()->loadEventFinished()) |
| 1710 childItem = PassRefPtrWillBeRawPtr<HistoryItem>(webframeChild->client()- >historyItemForNewChildFrame(webframeChild)); | 1743 childItem = PassRefPtrWillBeRawPtr<HistoryItem>(webframeChild->client()- >historyItemForNewChildFrame(webframeChild)); |
| 1711 | 1744 |
| 1712 if (childItem) | 1745 FrameLoadRequest newRequest = request; |
| 1713 child->loader().loadHistoryItem(childItem.get(), FrameLoadTypeInitialHis toryLoad); | 1746 FrameLoadType loadType = FrameLoadTypeStandard; |
| 1714 else | 1747 if (childItem) { |
| 1715 child->loader().load(request); | 1748 newRequest = FrameLoadRequest(request.originDocument(), |
| 1749 FrameLoader::resourceRequestFromHistoryItem(childItem.get(), UseProt ocolCachePolicy)); | |
| 1750 loadType = FrameLoadTypeInitialHistoryLoad; | |
| 1751 } | |
| 1752 child->loader().load(newRequest, loadType, childItem.get()); | |
| 1716 | 1753 |
| 1717 // Note a synchronous navigation (about:blank) would have already processed | 1754 // Note a synchronous navigation (about:blank) would have already processed |
| 1718 // onload, so it is possible for the child frame to have already been | 1755 // onload, so it is possible for the child frame to have already been |
| 1719 // detached by script in the page. | 1756 // detached by script in the page. |
| 1720 if (!child->tree().parent()) | 1757 if (!child->tree().parent()) |
| 1721 return nullptr; | 1758 return nullptr; |
| 1722 return child; | 1759 return child; |
| 1723 } | 1760 } |
| 1724 | 1761 |
| 1725 void WebLocalFrameImpl::didChangeContentsSize(const IntSize& size) | 1762 void WebLocalFrameImpl::didChangeContentsSize(const IntSize& size) |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2088 { | 2125 { |
| 2089 m_frameWidget = frameWidget; | 2126 m_frameWidget = frameWidget; |
| 2090 } | 2127 } |
| 2091 | 2128 |
| 2092 WebFrameWidgetImpl* WebLocalFrameImpl::frameWidget() const | 2129 WebFrameWidgetImpl* WebLocalFrameImpl::frameWidget() const |
| 2093 { | 2130 { |
| 2094 return m_frameWidget; | 2131 return m_frameWidget; |
| 2095 } | 2132 } |
| 2096 | 2133 |
| 2097 } // namespace blink | 2134 } // namespace blink |
| OLD | NEW |