Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Side by Side Diff: content/browser/frame_host/navigation_request.cc

Issue 2482873002: Add is_srcdoc to FrameNavigationEntry and restore about::srcdoc URL. (Closed)
Patch Set: Addressed comments (@nasko) Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 const BeginNavigationParams& begin_params, 211 const BeginNavigationParams& begin_params,
212 const RequestNavigationParams& request_params, 212 const RequestNavigationParams& request_params,
213 bool browser_initiated, 213 bool browser_initiated,
214 const FrameNavigationEntry* frame_entry, 214 const FrameNavigationEntry* frame_entry,
215 const NavigationEntryImpl* entry) 215 const NavigationEntryImpl* entry)
216 : frame_tree_node_(frame_tree_node), 216 : frame_tree_node_(frame_tree_node),
217 common_params_(common_params), 217 common_params_(common_params),
218 begin_params_(begin_params), 218 begin_params_(begin_params),
219 request_params_(request_params), 219 request_params_(request_params),
220 browser_initiated_(browser_initiated), 220 browser_initiated_(browser_initiated),
221 is_srcdoc_(false),
221 state_(NOT_STARTED), 222 state_(NOT_STARTED),
222 restore_type_(RestoreType::NONE), 223 restore_type_(RestoreType::NONE),
223 is_view_source_(false), 224 is_view_source_(false),
224 bindings_(NavigationEntryImpl::kInvalidBindings), 225 bindings_(NavigationEntryImpl::kInvalidBindings),
225 associated_site_instance_type_(AssociatedSiteInstanceType::NONE) { 226 associated_site_instance_type_(AssociatedSiteInstanceType::NONE) {
226 DCHECK(!browser_initiated || (entry != nullptr && frame_entry != nullptr)); 227 DCHECK(!browser_initiated || (entry != nullptr && frame_entry != nullptr));
227 if (browser_initiated) { 228 if (browser_initiated) {
228 FrameNavigationEntry* frame_entry = entry->GetFrameEntry(frame_tree_node); 229 FrameNavigationEntry* frame_entry = entry->GetFrameEntry(frame_tree_node);
229 if (frame_entry) { 230 if (frame_entry) {
230 source_site_instance_ = frame_entry->source_site_instance(); 231 source_site_instance_ = frame_entry->source_site_instance();
231 dest_site_instance_ = frame_entry->site_instance(); 232 dest_site_instance_ = frame_entry->site_instance();
233 is_srcdoc_ = frame_entry->is_srcdoc();
232 } 234 }
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();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 begin_params_.request_context_type, 280 begin_params_.request_context_type,
279 base::Bind(&NavigationRequest::OnStartChecksComplete, 281 base::Bind(&NavigationRequest::OnStartChecksComplete,
280 base::Unretained(this))); 282 base::Unretained(this)));
281 return; 283 return;
282 } 284 }
283 285
284 // There is no need to make a network request for this navigation, so commit 286 // There is no need to make a network request for this navigation, so commit
285 // it immediately. 287 // it immediately.
286 state_ = RESPONSE_STARTED; 288 state_ = RESPONSE_STARTED;
287 289
290 // Iframes with the srcdoc attribute have the "about:srcdoc" URL inside the
291 // renderer and the "about:blank" URL inside the browser. The conversion is
292 // made in RenderFrameHostImpl::OnDidCommitProvisionalLoad. The initial url
293 // must be restored here when the navigation is committed into the renderer.
294 if (is_srcdoc_)
295 common_params_.url = GURL(content::kAboutSrcDocURL);
296
288 // Select an appropriate RenderFrameHost. 297 // Select an appropriate RenderFrameHost.
289 RenderFrameHostImpl* render_frame_host = 298 RenderFrameHostImpl* render_frame_host =
290 frame_tree_node_->render_manager()->GetFrameHostForNavigation(*this); 299 frame_tree_node_->render_manager()->GetFrameHostForNavigation(*this);
291 NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host, 300 NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host,
292 common_params_.url); 301 common_params_.url);
293 302
294 // Inform the NavigationHandle that the navigation will commit. 303 // Inform the NavigationHandle that the navigation will commit.
295 navigation_handle_->ReadyToCommitNavigation(render_frame_host); 304 navigation_handle_->ReadyToCommitNavigation(render_frame_host);
296 305
297 CommitNavigation(); 306 CommitNavigation();
298 } 307 }
299 308
300 void NavigationRequest::CreateNavigationHandle(int pending_nav_entry_id) { 309 void NavigationRequest::CreateNavigationHandle(int pending_nav_entry_id) {
301 // TODO(nasko): Update the NavigationHandle creation to ensure that the 310 // TODO(nasko): Update the NavigationHandle creation to ensure that the
302 // proper values are specified for is_same_page and is_srcdoc. 311 // proper values is specified for is_same_page.
303 navigation_handle_ = NavigationHandleImpl::Create( 312 navigation_handle_ = NavigationHandleImpl::Create(
304 common_params_.url, frame_tree_node_, !browser_initiated_, 313 common_params_.url, frame_tree_node_, !browser_initiated_,
305 false, // is_same_page 314 false, // is_same_page
306 false, // is_srcdoc 315 is_srcdoc_, // is_srcdoc
307 common_params_.navigation_start, pending_nav_entry_id, 316 common_params_.navigation_start, pending_nav_entry_id,
308 false); // started_in_context_menu 317 false); // started_in_context_menu
309 } 318 }
310 319
311 void NavigationRequest::TransferNavigationHandleOwnership( 320 void NavigationRequest::TransferNavigationHandleOwnership(
312 RenderFrameHostImpl* render_frame_host) { 321 RenderFrameHostImpl* render_frame_host) {
313 render_frame_host->SetNavigationHandle(std::move(navigation_handle_)); 322 render_frame_host->SetNavigationHandle(std::move(navigation_handle_));
314 } 323 }
315 324
316 void NavigationRequest::OnRequestRedirected( 325 void NavigationRequest::OnRequestRedirected(
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); 598 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture);
590 599
591 render_frame_host->CommitNavigation(response_.get(), std::move(body_), 600 render_frame_host->CommitNavigation(response_.get(), std::move(body_),
592 common_params_, request_params_, 601 common_params_, request_params_,
593 is_view_source_); 602 is_view_source_);
594 603
595 frame_tree_node_->ResetNavigationRequest(true); 604 frame_tree_node_->ResetNavigationRequest(true);
596 } 605 }
597 606
598 } // namespace content 607 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_request.h ('k') | content/browser/frame_host/navigator_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698