OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "platform/testing/weburl_loader_mock.h" | 5 #include "platform/testing/weburl_loader_mock.h" |
6 | 6 |
7 #include "platform/testing/weburl_loader_mock_factory_impl.h" | 7 #include "platform/testing/weburl_loader_mock_factory_impl.h" |
8 #include "public/platform/URLConversion.h" | 8 #include "public/platform/URLConversion.h" |
9 #include "public/platform/WebData.h" | 9 #include "public/platform/WebData.h" |
10 #include "public/platform/WebURLError.h" | 10 #include "public/platform/WebURLError.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 newRequest.setFrameType(request.getFrameType()); | 75 newRequest.setFrameType(request.getFrameType()); |
76 newRequest.setSkipServiceWorker(request.skipServiceWorker()); | 76 newRequest.setSkipServiceWorker(request.skipServiceWorker()); |
77 newRequest.setShouldResetAppCache(request.shouldResetAppCache()); | 77 newRequest.setShouldResetAppCache(request.shouldResetAppCache()); |
78 newRequest.setFetchRequestMode(request.getFetchRequestMode()); | 78 newRequest.setFetchRequestMode(request.getFetchRequestMode()); |
79 newRequest.setFetchCredentialsMode(request.getFetchCredentialsMode()); | 79 newRequest.setFetchCredentialsMode(request.getFetchCredentialsMode()); |
80 newRequest.setHTTPMethod(request.httpMethod()); | 80 newRequest.setHTTPMethod(request.httpMethod()); |
81 newRequest.setHTTPBody(request.httpBody()); | 81 newRequest.setHTTPBody(request.httpBody()); |
82 | 82 |
83 WeakPtr<WebURLLoaderMock> self = weak_factory_.createWeakPtr(); | 83 WeakPtr<WebURLLoaderMock> self = weak_factory_.createWeakPtr(); |
84 | 84 |
85 client_->willFollowRedirect(this, newRequest, redirectResponse); | 85 bool follow = client_->willFollowRedirect(this, newRequest, redirectResponse); |
| 86 if (!follow) |
| 87 newRequest = WebURLRequest(); |
86 | 88 |
87 // |this| might be deleted in willFollowRedirect(). | 89 // |this| might be deleted in willFollowRedirect(). |
88 if (!self) | 90 if (!self) |
89 return newRequest; | 91 return newRequest; |
90 | 92 |
91 if (redirectURL != KURL(newRequest.url())) { | 93 if (!follow) |
92 // Only follow the redirect if WebKit left the URL unmodified. | |
93 // We assume that WebKit only changes the URL to suppress a redirect, and we | |
94 // assume that it does so by setting it to be invalid. | |
95 DCHECK(!newRequest.url().isValid()); | |
96 cancel(); | 94 cancel(); |
97 } | |
98 | 95 |
99 return newRequest; | 96 return newRequest; |
100 } | 97 } |
101 | 98 |
102 void WebURLLoaderMock::loadSynchronously(const WebURLRequest& request, | 99 void WebURLLoaderMock::loadSynchronously(const WebURLRequest& request, |
103 WebURLResponse& response, | 100 WebURLResponse& response, |
104 WebURLError& error, | 101 WebURLError& error, |
105 WebData& data, | 102 WebData& data, |
106 int64_t& encoded_data_length) { | 103 int64_t& encoded_data_length) { |
107 if (factory_->IsMockedURL(request.url())) { | 104 if (factory_->IsMockedURL(request.url())) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 // In principle this is NOTIMPLEMENTED(), but if we put that here it floods | 157 // In principle this is NOTIMPLEMENTED(), but if we put that here it floods |
161 // the console during webkit unit tests, so we leave the function empty. | 158 // the console during webkit unit tests, so we leave the function empty. |
162 DCHECK(runner); | 159 DCHECK(runner); |
163 } | 160 } |
164 | 161 |
165 WeakPtr<WebURLLoaderMock> WebURLLoaderMock::GetWeakPtr() { | 162 WeakPtr<WebURLLoaderMock> WebURLLoaderMock::GetWeakPtr() { |
166 return weak_factory_.createWeakPtr(); | 163 return weak_factory_.createWeakPtr(); |
167 } | 164 } |
168 | 165 |
169 } // namespace blink | 166 } // namespace blink |
OLD | NEW |