1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/test/test_navigation_url_loader.h"
7 #include "content/browser/loader/navigation_url_loader_delegate.h"
8 #include "content/public/browser/stream_handle.h"
9 #include "content/public/common/resource_response.h"
10 #include "net/url_request/redirect_info.h"
14 TestNavigationURLLoader::TestNavigationURLLoader(
15 scoped_ptr
<NavigationRequestInfo
> request_info
,
16 NavigationURLLoaderDelegate
* delegate
)
17 : request_info_(request_info
.Pass()),
22 void TestNavigationURLLoader::FollowRedirect() {
26 void TestNavigationURLLoader::SimulateServerRedirect(const GURL
& redirect_url
) {
27 net::RedirectInfo redirect_info
;
28 redirect_info
.status_code
= 302;
29 redirect_info
.new_method
= "GET";
30 redirect_info
.new_url
= redirect_url
;
31 redirect_info
.new_first_party_for_cookies
= redirect_url
;
32 scoped_refptr
<ResourceResponse
> response(new ResourceResponse
);
33 CallOnRequestRedirected(redirect_info
, response
);
36 void TestNavigationURLLoader::CallOnRequestRedirected(
37 const net::RedirectInfo
& redirect_info
,
38 const scoped_refptr
<ResourceResponse
>& response
) {
39 delegate_
->OnRequestRedirected(redirect_info
, response
);
42 void TestNavigationURLLoader::CallOnResponseStarted(
43 const scoped_refptr
<ResourceResponse
>& response
,
44 scoped_ptr
<StreamHandle
> body
) {
45 delegate_
->OnResponseStarted(response
, body
.Pass());
48 TestNavigationURLLoader::~TestNavigationURLLoader() {}
50 } // namespace content