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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "content/browser/child_process_security_policy_impl.h" | 9 #include "content/browser/child_process_security_policy_impl.h" |
10 #include "content/browser/devtools/render_frame_devtools_agent_host.h" | 10 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 restore_type_(RestoreType::NONE), | 222 restore_type_(RestoreType::NONE), |
223 is_view_source_(false), | 223 is_view_source_(false), |
224 bindings_(NavigationEntryImpl::kInvalidBindings), | 224 bindings_(NavigationEntryImpl::kInvalidBindings), |
225 associated_site_instance_type_(AssociatedSiteInstanceType::NONE) { | 225 associated_site_instance_type_(AssociatedSiteInstanceType::NONE) { |
226 DCHECK(!browser_initiated || (entry != nullptr && frame_entry != nullptr)); | 226 DCHECK(!browser_initiated || (entry != nullptr && frame_entry != nullptr)); |
227 if (browser_initiated) { | 227 if (browser_initiated) { |
228 FrameNavigationEntry* frame_entry = entry->GetFrameEntry(frame_tree_node); | 228 FrameNavigationEntry* frame_entry = entry->GetFrameEntry(frame_tree_node); |
229 if (frame_entry) { | 229 if (frame_entry) { |
230 source_site_instance_ = frame_entry->source_site_instance(); | 230 source_site_instance_ = frame_entry->source_site_instance(); |
231 dest_site_instance_ = frame_entry->site_instance(); | 231 dest_site_instance_ = frame_entry->site_instance(); |
232 is_srcdoc_ = frame_entry->is_srcdoc(); | |
233 } else { | |
234 is_srcdoc_ = false; | |
232 } | 235 } |
233 | 236 |
234 restore_type_ = entry->restore_type(); | 237 restore_type_ = entry->restore_type(); |
235 is_view_source_ = entry->IsViewSourceMode(); | 238 is_view_source_ = entry->IsViewSourceMode(); |
236 bindings_ = entry->bindings(); | 239 bindings_ = entry->bindings(); |
237 } else { | 240 } else { |
238 // This is needed to have about:blank and data URLs commit in the same | 241 // This is needed to have about:blank and data URLs commit in the same |
239 // SiteInstance as the initiating renderer. | 242 // SiteInstance as the initiating renderer. |
240 source_site_instance_ = | 243 source_site_instance_ = |
241 frame_tree_node->current_frame_host()->GetSiteInstance(); | 244 frame_tree_node->current_frame_host()->GetSiteInstance(); |
245 is_srcdoc_ = false; | |
nasko
2016/11/09 01:41:01
Why not initialize is_srcdoc_ in the initializer l
arthursonzogni
2016/11/09 09:23:13
You are right.
| |
242 } | 246 } |
243 | 247 |
244 // Update the load flags with cache information. | 248 // Update the load flags with cache information. |
245 UpdateLoadFlagsWithCacheFlags(&begin_params_.load_flags, | 249 UpdateLoadFlagsWithCacheFlags(&begin_params_.load_flags, |
246 common_params_.navigation_type, | 250 common_params_.navigation_type, |
247 common_params_.method == "POST"); | 251 common_params_.method == "POST"); |
248 | 252 |
249 // Add necessary headers that may not be present in the BeginNavigationParams. | 253 // Add necessary headers that may not be present in the BeginNavigationParams. |
250 net::HttpRequestHeaders headers; | 254 net::HttpRequestHeaders headers; |
251 headers.AddHeadersFromString(begin_params_.headers); | 255 headers.AddHeadersFromString(begin_params_.headers); |
(...skipping 26 matching lines...) Expand all Loading... | |
278 begin_params_.request_context_type, | 282 begin_params_.request_context_type, |
279 base::Bind(&NavigationRequest::OnStartChecksComplete, | 283 base::Bind(&NavigationRequest::OnStartChecksComplete, |
280 base::Unretained(this))); | 284 base::Unretained(this))); |
281 return; | 285 return; |
282 } | 286 } |
283 | 287 |
284 // There is no need to make a network request for this navigation, so commit | 288 // There is no need to make a network request for this navigation, so commit |
285 // it immediately. | 289 // it immediately. |
286 state_ = RESPONSE_STARTED; | 290 state_ = RESPONSE_STARTED; |
287 | 291 |
292 // Iframes with the srcdoc attribute have the "about::srcdoc" URL inside the | |
nasko
2016/11/09 01:41:01
nit: Only one colon in "about:srcdoc".
arthursonzogni
2016/11/09 09:23:13
Done.
| |
293 // renderer and the about::blank URL inside the browser. The conversion is | |
nasko
2016/11/09 01:41:01
Ditto for about:blank.
arthursonzogni
2016/11/09 09:23:13
Done.
| |
294 // made in RenderFrameHostImpl::OnDidCommitProvisionalLoad. The initial url | |
295 // must be restored here when the navigation is committed into the renderer. | |
296 if (is_srcdoc_) | |
297 common_params_.url = GURL(content::kAboutSrcDocURL); | |
298 | |
288 // Select an appropriate RenderFrameHost. | 299 // Select an appropriate RenderFrameHost. |
289 RenderFrameHostImpl* render_frame_host = | 300 RenderFrameHostImpl* render_frame_host = |
290 frame_tree_node_->render_manager()->GetFrameHostForNavigation(*this); | 301 frame_tree_node_->render_manager()->GetFrameHostForNavigation(*this); |
291 NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host, | 302 NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host, |
292 common_params_.url); | 303 common_params_.url); |
293 | 304 |
294 // Inform the NavigationHandle that the navigation will commit. | 305 // Inform the NavigationHandle that the navigation will commit. |
295 navigation_handle_->ReadyToCommitNavigation(render_frame_host); | 306 navigation_handle_->ReadyToCommitNavigation(render_frame_host); |
296 | 307 |
297 CommitNavigation(); | 308 CommitNavigation(); |
298 } | 309 } |
299 | 310 |
300 void NavigationRequest::CreateNavigationHandle(int pending_nav_entry_id) { | 311 void NavigationRequest::CreateNavigationHandle(int pending_nav_entry_id) { |
301 // TODO(nasko): Update the NavigationHandle creation to ensure that the | 312 // TODO(nasko): Update the NavigationHandle creation to ensure that the |
302 // proper values are specified for is_same_page and is_srcdoc. | 313 // proper values is specified for is_same_page. |
303 navigation_handle_ = NavigationHandleImpl::Create( | 314 navigation_handle_ = NavigationHandleImpl::Create( |
304 common_params_.url, frame_tree_node_, !browser_initiated_, | 315 common_params_.url, frame_tree_node_, !browser_initiated_, |
305 false, // is_same_page | 316 false, // is_same_page |
306 false, // is_srcdoc | 317 is_srcdoc_, // is_srcdoc |
307 common_params_.navigation_start, pending_nav_entry_id, | 318 common_params_.navigation_start, pending_nav_entry_id, |
308 false); // started_in_context_menu | 319 false); // started_in_context_menu |
309 } | 320 } |
310 | 321 |
311 void NavigationRequest::TransferNavigationHandleOwnership( | 322 void NavigationRequest::TransferNavigationHandleOwnership( |
312 RenderFrameHostImpl* render_frame_host) { | 323 RenderFrameHostImpl* render_frame_host) { |
313 render_frame_host->SetNavigationHandle(std::move(navigation_handle_)); | 324 render_frame_host->SetNavigationHandle(std::move(navigation_handle_)); |
314 } | 325 } |
315 | 326 |
316 void NavigationRequest::OnRequestRedirected( | 327 void NavigationRequest::OnRequestRedirected( |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
589 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); | 600 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); |
590 | 601 |
591 render_frame_host->CommitNavigation(response_.get(), std::move(body_), | 602 render_frame_host->CommitNavigation(response_.get(), std::move(body_), |
592 common_params_, request_params_, | 603 common_params_, request_params_, |
593 is_view_source_); | 604 is_view_source_); |
594 | 605 |
595 frame_tree_node_->ResetNavigationRequest(true); | 606 frame_tree_node_->ResetNavigationRequest(true); |
596 } | 607 } |
597 | 608 |
598 } // namespace content | 609 } // namespace content |
OLD | NEW |