Chromium Code Reviews| 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/frame_tree_node.h" |
| 8 #include "content/browser/frame_host/navigation_entry_impl.h" | |
| 8 #include "content/browser/frame_host/navigation_request_info.h" | 9 #include "content/browser/frame_host/navigation_request_info.h" |
| 9 #include "content/browser/frame_host/navigator.h" | 10 #include "content/browser/frame_host/navigator.h" |
| 10 #include "content/browser/loader/navigation_url_loader.h" | 11 #include "content/browser/loader/navigation_url_loader.h" |
| 12 #include "content/browser/site_instance_impl.h" | |
| 11 #include "content/common/resource_request_body.h" | 13 #include "content/common/resource_request_body.h" |
| 12 #include "content/public/browser/navigation_controller.h" | 14 #include "content/public/browser/navigation_controller.h" |
| 13 #include "content/public/browser/stream_handle.h" | 15 #include "content/public/browser/stream_handle.h" |
| 14 #include "net/url_request/redirect_info.h" | 16 #include "net/url_request/redirect_info.h" |
| 15 | 17 |
| 16 namespace content { | 18 namespace content { |
| 17 | 19 |
| 18 NavigationRequest::NavigationRequest( | 20 NavigationRequest::NavigationRequest( |
| 19 FrameTreeNode* frame_tree_node, | 21 FrameTreeNode* frame_tree_node, |
| 20 const CommonNavigationParams& common_params, | 22 const CommonNavigationParams& common_params, |
| 21 const CommitNavigationParams& commit_params) | 23 const CommitNavigationParams& commit_params) |
| 22 : frame_tree_node_(frame_tree_node), | 24 : frame_tree_node_(frame_tree_node), |
| 23 common_params_(common_params), | 25 common_params_(common_params), |
| 24 commit_params_(commit_params), | 26 commit_params_(commit_params), |
| 25 state_(NOT_STARTED) { | 27 state_(NOT_STARTED), |
| 28 is_restore_(false), | |
| 29 is_view_source_(false), | |
| 30 bindings_(NavigationEntryImpl::kInvalidBindings) { | |
| 26 } | 31 } |
| 27 | 32 |
| 28 NavigationRequest::~NavigationRequest() { | 33 NavigationRequest::~NavigationRequest() { |
| 29 } | 34 } |
| 30 | 35 |
| 31 void NavigationRequest::BeginNavigation( | 36 void NavigationRequest::BeginNavigation( |
| 32 scoped_ptr<NavigationRequestInfo> info, | 37 scoped_ptr<NavigationRequestInfo> info, |
| 33 scoped_refptr<ResourceRequestBody> request_body) { | 38 scoped_refptr<ResourceRequestBody> request_body) { |
| 34 DCHECK(!loader_); | 39 DCHECK(!loader_); |
| 35 DCHECK(state_ == NOT_STARTED || state_ == WAITING_FOR_RENDERER_RESPONSE); | 40 DCHECK(state_ == NOT_STARTED || state_ == WAITING_FOR_RENDERER_RESPONSE); |
| 36 state_ = STARTED; | 41 state_ = STARTED; |
| 37 loader_ = NavigationURLLoader::Create( | 42 loader_ = NavigationURLLoader::Create( |
| 38 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), | 43 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), |
| 39 frame_tree_node_->frame_tree_node_id(), common_params_, info.Pass(), | 44 frame_tree_node_->frame_tree_node_id(), common_params_, info.Pass(), |
| 40 request_body.get(), this); | 45 request_body.get(), this); |
| 41 | 46 |
| 42 // TODO(davidben): Fire (and add as necessary) observer methods such as | 47 // TODO(davidben): Fire (and add as necessary) observer methods such as |
| 43 // DidStartProvisionalLoadForFrame for the navigation. | 48 // DidStartProvisionalLoadForFrame for the navigation. |
| 44 } | 49 } |
| 45 | 50 |
| 51 void NavigationRequest::CopyDataFrom(const NavigationEntryImpl& nav_entry) { | |
| 52 source_site_instance_ = nav_entry.source_site_instance(); | |
| 53 dest_site_instance_ = nav_entry.site_instance(); | |
| 54 is_restore_ = nav_entry.restore_type() != NavigationEntryImpl::RESTORE_NONE; | |
|
nasko
2015/01/16 15:03:24
Why not store the restore type directly?
carlosk
2015/01/19 15:02:52
The reason was that we only need to know if it is
| |
| 55 is_view_source_ = nav_entry.IsViewSourceMode(); | |
| 56 bindings_ = nav_entry.bindings(); | |
| 57 } | |
| 58 | |
| 46 void NavigationRequest::OnRequestRedirected( | 59 void NavigationRequest::OnRequestRedirected( |
| 47 const net::RedirectInfo& redirect_info, | 60 const net::RedirectInfo& redirect_info, |
| 48 const scoped_refptr<ResourceResponse>& response) { | 61 const scoped_refptr<ResourceResponse>& response) { |
| 49 // TODO(davidben): Track other changes from redirects. These are important | 62 // TODO(davidben): Track other changes from redirects. These are important |
| 50 // for, e.g., reloads. | 63 // for, e.g., reloads. |
| 51 common_params_.url = redirect_info.new_url; | 64 common_params_.url = redirect_info.new_url; |
| 52 | 65 |
| 53 // TODO(davidben): This where prerender and navigation_interceptor should be | 66 // TODO(davidben): This where prerender and navigation_interceptor should be |
| 54 // integrated. For now, just always follow all redirects. | 67 // integrated. For now, just always follow all redirects. |
| 55 loader_->FollowRedirect(); | 68 loader_->FollowRedirect(); |
| 56 } | 69 } |
| 57 | 70 |
| 58 void NavigationRequest::OnResponseStarted( | 71 void NavigationRequest::OnResponseStarted( |
| 59 const scoped_refptr<ResourceResponse>& response, | 72 const scoped_refptr<ResourceResponse>& response, |
| 60 scoped_ptr<StreamHandle> body) { | 73 scoped_ptr<StreamHandle> body) { |
| 61 DCHECK(state_ == STARTED); | 74 DCHECK(state_ == STARTED); |
| 62 state_ = RESPONSE_STARTED; | 75 state_ = RESPONSE_STARTED; |
| 63 frame_tree_node_->navigator()->CommitNavigation(frame_tree_node_, | 76 frame_tree_node_->navigator()->CommitNavigation(frame_tree_node_, |
| 64 response.get(), body.Pass()); | 77 response.get(), body.Pass()); |
| 65 } | 78 } |
| 66 | 79 |
| 67 void NavigationRequest::OnRequestFailed(int net_error) { | 80 void NavigationRequest::OnRequestFailed(int net_error) { |
| 68 DCHECK(state_ == STARTED); | 81 DCHECK(state_ == STARTED); |
| 69 state_ = FAILED; | 82 state_ = FAILED; |
| 70 // TODO(davidben): Network failures should display a network error page. | 83 // TODO(davidben): Network failures should display a network error page. |
| 71 NOTIMPLEMENTED(); | 84 NOTIMPLEMENTED(); |
| 72 } | 85 } |
| 73 | 86 |
| 74 } // namespace content | 87 } // namespace content |
| OLD | NEW |