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.h" | 7 #include "content/browser/frame_host/frame_tree.h" |
| 8 #include "content/browser/frame_host/frame_tree_node.h" | 8 #include "content/browser/frame_host/frame_tree_node.h" |
| 9 #include "content/browser/frame_host/navigation_request_info.h" | 9 #include "content/browser/frame_host/navigation_request_info.h" |
| 10 #include "content/browser/frame_host/navigator.h" | 10 #include "content/browser/frame_host/navigator.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 | 78 |
| 79 FrameMsg_UILoadMetricsReportType::Value report_type = | 79 FrameMsg_UILoadMetricsReportType::Value report_type = |
| 80 FrameMsg_UILoadMetricsReportType::NO_REPORT; | 80 FrameMsg_UILoadMetricsReportType::NO_REPORT; |
| 81 base::TimeTicks ui_timestamp = base::TimeTicks(); | 81 base::TimeTicks ui_timestamp = base::TimeTicks(); |
| 82 #if defined(OS_ANDROID) | 82 #if defined(OS_ANDROID) |
| 83 if (!entry.intent_received_timestamp().is_null()) | 83 if (!entry.intent_received_timestamp().is_null()) |
| 84 report_type = FrameMsg_UILoadMetricsReportType::REPORT_INTENT; | 84 report_type = FrameMsg_UILoadMetricsReportType::REPORT_INTENT; |
| 85 ui_timestamp = entry.intent_received_timestamp(); | 85 ui_timestamp = entry.intent_received_timestamp(); |
| 86 #endif | 86 #endif |
| 87 | 87 |
| 88 const GURL history_url_for_data_url = | |
| 89 entry.GetBaseURLForDataURL().is_empty()? GURL() : entry.GetVirtualURL(); | |
|
Charlie Reis
2015/02/18 00:43:25
nit: Space before ?
clamy
2015/02/20 17:05:58
Done.
| |
| 90 | |
| 88 scoped_ptr<NavigationRequest> navigation_request(new NavigationRequest( | 91 scoped_ptr<NavigationRequest> navigation_request(new NavigationRequest( |
| 89 frame_tree_node, | 92 frame_tree_node, |
| 90 CommonNavigationParams(entry.GetURL(), entry.GetReferrer(), | 93 CommonNavigationParams(entry.GetURL(), entry.GetReferrer(), |
| 91 entry.GetTransitionType(), navigation_type, | 94 entry.GetTransitionType(), navigation_type, |
| 92 !entry.IsViewSourceMode(),ui_timestamp, | 95 !entry.IsViewSourceMode(),ui_timestamp, |
| 93 report_type), | 96 report_type, entry.GetBaseURLForDataURL(), |
| 97 history_url_for_data_url), | |
| 94 BeginNavigationParams(method, headers.ToString(), | 98 BeginNavigationParams(method, headers.ToString(), |
| 95 LoadFlagFromNavigationType(navigation_type), | 99 LoadFlagFromNavigationType(navigation_type), |
| 96 false), | 100 false), |
| 97 CommitNavigationParams(entry.GetPageState(), | 101 CommitNavigationParams(entry.GetPageState(), |
| 98 entry.GetIsOverridingUserAgent(), | 102 entry.GetIsOverridingUserAgent(), |
| 99 navigation_start), | 103 navigation_start), |
| 100 request_body, true, &entry)); | 104 request_body, true, &entry)); |
| 101 return navigation_request.Pass(); | 105 return navigation_request.Pass(); |
| 102 } | 106 } |
| 103 | 107 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 bool parent_is_main_frame = !frame_tree_node->parent() ? | 155 bool parent_is_main_frame = !frame_tree_node->parent() ? |
| 152 false : frame_tree_node->parent()->IsMainFrame(); | 156 false : frame_tree_node->parent()->IsMainFrame(); |
| 153 info_.reset(new NavigationRequestInfo( | 157 info_.reset(new NavigationRequestInfo( |
| 154 common_params, begin_params, first_party_for_cookies, | 158 common_params, begin_params, first_party_for_cookies, |
| 155 frame_tree_node->IsMainFrame(), parent_is_main_frame, body)); | 159 frame_tree_node->IsMainFrame(), parent_is_main_frame, body)); |
| 156 } | 160 } |
| 157 | 161 |
| 158 NavigationRequest::~NavigationRequest() { | 162 NavigationRequest::~NavigationRequest() { |
| 159 } | 163 } |
| 160 | 164 |
| 161 void NavigationRequest::BeginNavigation() { | 165 bool NavigationRequest::BeginNavigation() { |
| 162 DCHECK(!loader_); | 166 DCHECK(!loader_); |
| 163 DCHECK(state_ == NOT_STARTED || state_ == WAITING_FOR_RENDERER_RESPONSE); | 167 DCHECK(state_ == NOT_STARTED || state_ == WAITING_FOR_RENDERER_RESPONSE); |
| 164 state_ = STARTED; | 168 state_ = STARTED; |
| 165 loader_ = NavigationURLLoader::Create( | 169 |
| 166 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), | 170 if (ShouldMakeNetworkRequestForNavigation(common_params_.url)) { |
| 167 frame_tree_node_->frame_tree_node_id(), info_.Pass(), this); | 171 loader_ = NavigationURLLoader::Create( |
| 172 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), | |
| 173 frame_tree_node_->frame_tree_node_id(), info_.Pass(), this); | |
| 174 return true; | |
| 175 } | |
| 176 | |
| 177 state_ = RESPONSE_STARTED; | |
| 178 // There is no need to make a network request for this navigation, so commit | |
| 179 // it immediately if it was browser initiated. If it was renderer initiated, | |
| 180 // the renderer should already be trying to commit it. | |
|
Charlie Reis
2015/02/18 00:43:25
I'm not sure I agree with the second sentence. Da
clamy
2015/02/20 17:05:58
Changed the behavior so that now we always go thro
| |
| 181 if (browser_initiated_) { | |
| 182 frame_tree_node_->navigator()->CommitNavigation( | |
|
carlosk
2015/02/17 12:35:09
I find it weird that we're calling into Navigator
clamy
2015/02/17 12:54:28
I am not quite sure what you mean there. There are
carlosk
2015/02/17 14:11:23
Yes, one navigator per node. I's just an architect
Charlie Reis
2015/02/18 00:43:25
To be clear, there is not one Navigator per FrameT
carlosk
2015/02/18 15:45:08
Acknowledged.
| |
| 183 frame_tree_node_, nullptr, scoped_ptr<StreamHandle>()); | |
| 184 } | |
| 185 return false; | |
| 168 | 186 |
| 169 // TODO(davidben): Fire (and add as necessary) observer methods such as | 187 // TODO(davidben): Fire (and add as necessary) observer methods such as |
| 170 // DidStartProvisionalLoadForFrame for the navigation. | 188 // DidStartProvisionalLoadForFrame for the navigation. |
| 171 } | 189 } |
| 172 | 190 |
| 173 void NavigationRequest::OnRequestRedirected( | 191 void NavigationRequest::OnRequestRedirected( |
| 174 const net::RedirectInfo& redirect_info, | 192 const net::RedirectInfo& redirect_info, |
| 175 const scoped_refptr<ResourceResponse>& response) { | 193 const scoped_refptr<ResourceResponse>& response) { |
| 176 // TODO(davidben): Track other changes from redirects. These are important | 194 // TODO(davidben): Track other changes from redirects. These are important |
| 177 // for, e.g., reloads. | 195 // for, e.g., reloads. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 197 // TODO(davidben): Network failures should display a network error page. | 215 // TODO(davidben): Network failures should display a network error page. |
| 198 NOTIMPLEMENTED() << " where net_error=" << net_error; | 216 NOTIMPLEMENTED() << " where net_error=" << net_error; |
| 199 } | 217 } |
| 200 | 218 |
| 201 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) { | 219 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) { |
| 202 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, | 220 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, |
| 203 common_params_.url); | 221 common_params_.url); |
| 204 } | 222 } |
| 205 | 223 |
| 206 } // namespace content | 224 } // namespace content |
| OLD | NEW |