Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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. |
|
Charlie Reis
2017/03/22 23:54:41
nit: Update comment, maybe giving an example of wh
clamy
2017/03/23 13:17:52
Done.
| |
| 424 if (was_renderer_initiated) { | 425 if (was_renderer_initiated && inform_renderer) { |
| 425 current_frame_host()->Send( | 426 current_frame_host()->Send( |
| 426 new FrameMsg_Stop(current_frame_host()->GetRoutingID())); | 427 new FrameMsg_Stop(current_frame_host()->GetRoutingID())); |
| 427 } | 428 } |
| 428 | 429 |
| 429 } | 430 } |
| 430 | 431 |
| 431 bool FrameTreeNode::has_started_loading() const { | 432 bool FrameTreeNode::has_started_loading() const { |
| 432 return loading_progress_ != kLoadingProgressNotStarted; | 433 return loading_progress_ != kLoadingProgressNotStarted; |
| 433 } | 434 } |
| 434 | 435 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 loading_progress_ = load_progress; | 494 loading_progress_ = load_progress; |
| 494 frame_tree_->UpdateLoadProgress(); | 495 frame_tree_->UpdateLoadProgress(); |
| 495 } | 496 } |
| 496 | 497 |
| 497 bool FrameTreeNode::StopLoading() { | 498 bool FrameTreeNode::StopLoading() { |
| 498 if (IsBrowserSideNavigationEnabled()) { | 499 if (IsBrowserSideNavigationEnabled()) { |
| 499 if (navigation_request_) { | 500 if (navigation_request_) { |
| 500 navigation_request_->navigation_handle()->set_net_error_code( | 501 navigation_request_->navigation_handle()->set_net_error_code( |
| 501 net::ERR_ABORTED); | 502 net::ERR_ABORTED); |
| 502 } | 503 } |
| 503 ResetNavigationRequest(false); | 504 ResetNavigationRequest(false, true); |
| 504 } | 505 } |
| 505 | 506 |
| 506 // TODO(nasko): see if child frames should send IPCs in site-per-process | 507 // TODO(nasko): see if child frames should send IPCs in site-per-process |
| 507 // mode. | 508 // mode. |
| 508 if (!IsMainFrame()) | 509 if (!IsMainFrame()) |
| 509 return true; | 510 return true; |
| 510 | 511 |
| 511 render_manager_.Stop(); | 512 render_manager_.Stop(); |
| 512 return true; | 513 return true; |
| 513 } | 514 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 558 } | 559 } |
| 559 return parent_->child_at(i + relative_offset); | 560 return parent_->child_at(i + relative_offset); |
| 560 } | 561 } |
| 561 } | 562 } |
| 562 | 563 |
| 563 NOTREACHED() << "FrameTreeNode not found in its parent's children."; | 564 NOTREACHED() << "FrameTreeNode not found in its parent's children."; |
| 564 return nullptr; | 565 return nullptr; |
| 565 } | 566 } |
| 566 | 567 |
| 567 } // namespace content | 568 } // namespace content |
| OLD | NEW |