OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/frame_host/navigation_request.h" | 5 #include "content/browser/frame_host/navigation_request.h" |
6 | 6 |
| 7 #include "content/browser/frame_host/frame_tree_node.h" |
7 #include "content/browser/frame_host/navigation_request_info.h" | 8 #include "content/browser/frame_host/navigation_request_info.h" |
| 9 #include "content/browser/frame_host/navigator.h" |
| 10 #include "content/browser/loader/navigation_url_loader.h" |
8 #include "content/common/resource_request_body.h" | 11 #include "content/common/resource_request_body.h" |
| 12 #include "content/public/browser/navigation_controller.h" |
| 13 #include "content/public/browser/stream_handle.h" |
| 14 #include "net/url_request/redirect_info.h" |
9 | 15 |
10 namespace content { | 16 namespace content { |
11 | 17 |
12 NavigationRequest::NavigationRequest( | 18 NavigationRequest::NavigationRequest( |
13 FrameTreeNode* frame_tree_node, | 19 FrameTreeNode* frame_tree_node, |
14 const CommonNavigationParams& common_params, | 20 const CommonNavigationParams& common_params, |
15 const CommitNavigationParams& commit_params) | 21 const CommitNavigationParams& commit_params) |
16 : frame_tree_node_(frame_tree_node), | 22 : frame_tree_node_(frame_tree_node), |
17 common_params_(common_params), | 23 common_params_(common_params), |
18 commit_params_(commit_params) { | 24 commit_params_(commit_params) { |
19 } | 25 } |
20 | 26 |
21 NavigationRequest::~NavigationRequest() { | 27 NavigationRequest::~NavigationRequest() { |
22 } | 28 } |
23 | 29 |
24 void NavigationRequest::BeginNavigation( | 30 void NavigationRequest::BeginNavigation( |
25 scoped_ptr<NavigationRequestInfo> info, | 31 scoped_ptr<NavigationRequestInfo> info, |
26 scoped_refptr<ResourceRequestBody> request_body) { | 32 scoped_refptr<ResourceRequestBody> request_body) { |
27 info_ = info.Pass(); | 33 DCHECK(!loader_); |
| 34 loader_ = NavigationURLLoader::Create( |
| 35 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), |
| 36 frame_tree_node_->frame_tree_node_id(), common_params_, info.Pass(), |
| 37 request_body.get(), this); |
| 38 |
| 39 // TODO(davidben): Fire (and add as necessary) observer methods such as |
| 40 // DidStartProvisionalLoadForFrame for the navigation. |
| 41 } |
| 42 |
| 43 void NavigationRequest::OnRequestRedirected( |
| 44 const net::RedirectInfo& redirect_info, |
| 45 const scoped_refptr<ResourceResponse>& response) { |
| 46 // TODO(davidben): Track other changes from redirects. These are important |
| 47 // for, e.g., reloads. |
| 48 common_params_.url = redirect_info.new_url; |
| 49 |
| 50 // TODO(davidben): This where prerender and navigation_interceptor should be |
| 51 // integrated. For now, just always follow all redirects. |
| 52 loader_->FollowRedirect(); |
| 53 } |
| 54 |
| 55 void NavigationRequest::OnResponseStarted( |
| 56 const scoped_refptr<ResourceResponse>& response, |
| 57 scoped_ptr<StreamHandle> body) { |
| 58 frame_tree_node_->navigator()->CommitNavigation(frame_tree_node_, |
| 59 response.get(), body.Pass()); |
| 60 } |
| 61 |
| 62 void NavigationRequest::OnRequestFailed(int net_error) { |
| 63 // TODO(davidben): Network failures should display a network error page. |
28 NOTIMPLEMENTED(); | 64 NOTIMPLEMENTED(); |
29 } | 65 } |
30 | 66 |
31 } // namespace content | 67 } // namespace content |
OLD | NEW |