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

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

Issue 2735183003: PlzNavigate: stop navigations when opening a document for write (Closed)
Patch Set: Addressed commemts Created 3 years, 9 months 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/frame_tree_node.h" 5 #include "content/browser/frame_host/frame_tree_node.h"
6 6
7 #include <queue> 7 #include <queue>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 // notifications for Javascript URLS. 377 // notifications for Javascript URLS.
378 DCHECK(!navigation_request->common_params().url.SchemeIs( 378 DCHECK(!navigation_request->common_params().url.SchemeIs(
379 url::kJavaScriptScheme)); 379 url::kJavaScriptScheme));
380 380
381 bool was_previously_loading = frame_tree()->IsLoading(); 381 bool was_previously_loading = frame_tree()->IsLoading();
382 382
383 // There's no need to reset the state: there's still an ongoing load, and the 383 // There's no need to reset the state: there's still an ongoing load, and the
384 // RenderFrameHostManager will take care of updates to the speculative 384 // RenderFrameHostManager will take care of updates to the speculative
385 // RenderFrameHost in DidCreateNavigationRequest below. 385 // RenderFrameHost in DidCreateNavigationRequest below.
386 if (was_previously_loading) 386 if (was_previously_loading)
387 ResetNavigationRequest(true); 387 ResetNavigationRequest(true, true);
388 388
389 navigation_request_ = std::move(navigation_request); 389 navigation_request_ = std::move(navigation_request);
390 render_manager()->DidCreateNavigationRequest(navigation_request_.get()); 390 render_manager()->DidCreateNavigationRequest(navigation_request_.get());
391 391
392 bool to_different_document = !FrameMsg_Navigate_Type::IsSameDocument( 392 bool to_different_document = !FrameMsg_Navigate_Type::IsSameDocument(
393 navigation_request_->common_params().navigation_type); 393 navigation_request_->common_params().navigation_type);
394 394
395 DidStartLoading(to_different_document, was_previously_loading); 395 DidStartLoading(to_different_document, was_previously_loading);
396 } 396 }
397 397
398 void FrameTreeNode::ResetNavigationRequest(bool keep_state) { 398 void FrameTreeNode::ResetNavigationRequest(bool keep_state,
399 bool inform_renderer) {
399 CHECK(IsBrowserSideNavigationEnabled()); 400 CHECK(IsBrowserSideNavigationEnabled());
400 if (!navigation_request_) 401 if (!navigation_request_)
401 return; 402 return;
402 bool was_renderer_initiated = !navigation_request_->browser_initiated(); 403 bool was_renderer_initiated = !navigation_request_->browser_initiated();
403 NavigationRequest::AssociatedSiteInstanceType site_instance_type = 404 NavigationRequest::AssociatedSiteInstanceType site_instance_type =
404 navigation_request_->associated_site_instance_type(); 405 navigation_request_->associated_site_instance_type();
405 navigation_request_.reset(); 406 navigation_request_.reset();
406 407
407 if (keep_state) 408 if (keep_state)
408 return; 409 return;
409 410
410 // The RenderFrameHostManager should clean up any speculative RenderFrameHost 411 // The RenderFrameHostManager should clean up any speculative RenderFrameHost
411 // it created for the navigation. Also register that the load stopped. 412 // it created for the navigation. Also register that the load stopped.
412 DidStopLoading(); 413 DidStopLoading();
413 render_manager_.CleanUpNavigation(); 414 render_manager_.CleanUpNavigation();
414 415
415 // When reusing the same SiteInstance, a pending WebUI may have been created 416 // When reusing the same SiteInstance, a pending WebUI may have been created
416 // on behalf of the navigation in the current RenderFrameHost. Clear it. 417 // on behalf of the navigation in the current RenderFrameHost. Clear it.
417 if (site_instance_type == 418 if (site_instance_type ==
418 NavigationRequest::AssociatedSiteInstanceType::CURRENT) { 419 NavigationRequest::AssociatedSiteInstanceType::CURRENT) {
419 current_frame_host()->ClearPendingWebUI(); 420 current_frame_host()->ClearPendingWebUI();
420 } 421 }
421 422
422 // If the navigation is renderer-initiated, the renderer should also be 423 // If the navigation is renderer-initiated, the renderer should also be
423 // informed that the navigation stopped. 424 // informed that the navigation stopped if needed. In the case the renderer
424 if (was_renderer_initiated) { 425 // process asked for the navigation to be aborted, e.g. following a
426 // document.open, do not send an IPC to the renderer process as it already
427 // expects the navigation to stop.
428 if (was_renderer_initiated && inform_renderer) {
425 current_frame_host()->Send( 429 current_frame_host()->Send(
426 new FrameMsg_Stop(current_frame_host()->GetRoutingID())); 430 new FrameMsg_Stop(current_frame_host()->GetRoutingID()));
427 } 431 }
428 432
429 } 433 }
430 434
431 bool FrameTreeNode::has_started_loading() const { 435 bool FrameTreeNode::has_started_loading() const {
432 return loading_progress_ != kLoadingProgressNotStarted; 436 return loading_progress_ != kLoadingProgressNotStarted;
433 } 437 }
434 438
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 loading_progress_ = load_progress; 497 loading_progress_ = load_progress;
494 frame_tree_->UpdateLoadProgress(); 498 frame_tree_->UpdateLoadProgress();
495 } 499 }
496 500
497 bool FrameTreeNode::StopLoading() { 501 bool FrameTreeNode::StopLoading() {
498 if (IsBrowserSideNavigationEnabled()) { 502 if (IsBrowserSideNavigationEnabled()) {
499 if (navigation_request_) { 503 if (navigation_request_) {
500 navigation_request_->navigation_handle()->set_net_error_code( 504 navigation_request_->navigation_handle()->set_net_error_code(
501 net::ERR_ABORTED); 505 net::ERR_ABORTED);
502 } 506 }
503 ResetNavigationRequest(false); 507 ResetNavigationRequest(false, true);
504 } 508 }
505 509
506 // TODO(nasko): see if child frames should send IPCs in site-per-process 510 // TODO(nasko): see if child frames should send IPCs in site-per-process
507 // mode. 511 // mode.
508 if (!IsMainFrame()) 512 if (!IsMainFrame())
509 return true; 513 return true;
510 514
511 render_manager_.Stop(); 515 render_manager_.Stop();
512 return true; 516 return true;
513 } 517 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 } 562 }
559 return parent_->child_at(i + relative_offset); 563 return parent_->child_at(i + relative_offset);
560 } 564 }
561 } 565 }
562 566
563 NOTREACHED() << "FrameTreeNode not found in its parent's children."; 567 NOTREACHED() << "FrameTreeNode not found in its parent's children.";
564 return nullptr; 568 return nullptr;
565 } 569 }
566 570
567 } // namespace content 571 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/frame_tree_node.h ('k') | content/browser/frame_host/navigation_controller_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698