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