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.h" | 5 #include "content/browser/frame_host/frame_tree.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
| 15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
| 16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 17 #include "content/browser/frame_host/frame_tree_node.h" | 17 #include "content/browser/frame_host/frame_tree_node.h" |
| 18 #include "content/browser/frame_host/navigator.h" | 18 #include "content/browser/frame_host/navigator.h" |
| 19 #include "content/browser/frame_host/render_frame_host_factory.h" | 19 #include "content/browser/frame_host/render_frame_host_factory.h" |
| 20 #include "content/browser/frame_host/render_frame_host_impl.h" | 20 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 21 #include "content/browser/frame_host/render_frame_proxy_host.h" | 21 #include "content/browser/frame_host/render_frame_proxy_host.h" |
| 22 #include "content/browser/renderer_host/render_view_host_factory.h" | 22 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 23 #include "content/browser/renderer_host/render_view_host_impl.h" | 23 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 24 #include "content/common/content_switches_internal.h" | |
| 24 #include "content/common/input_messages.h" | 25 #include "content/common/input_messages.h" |
| 25 #include "content/common/site_isolation_policy.h" | 26 #include "content/common/site_isolation_policy.h" |
| 26 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 27 #include "third_party/WebKit/public/web/WebSandboxFlags.h" |
| 27 | 28 |
| 28 namespace content { | 29 namespace content { |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 // Helper function to collect SiteInstances involved in rendering a single | 33 // Helper function to collect SiteInstances involved in rendering a single |
| 33 // FrameTree (which is a subset of SiteInstances in main frame's proxy_hosts_ | 34 // FrameTree (which is a subset of SiteInstances in main frame's proxy_hosts_ |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 362 if (!frame->parent()) { | 363 if (!frame->parent()) { |
| 363 CHECK_EQ(frame, root_); | 364 CHECK_EQ(frame, root_); |
| 364 return; | 365 return; |
| 365 } | 366 } |
| 366 | 367 |
| 367 // Notify observers of the frame removal. | 368 // Notify observers of the frame removal. |
| 368 if (!on_frame_removed_.is_null()) | 369 if (!on_frame_removed_.is_null()) |
| 369 on_frame_removed_.Run(frame->current_frame_host()); | 370 on_frame_removed_.Run(frame->current_frame_host()); |
| 370 } | 371 } |
| 371 | 372 |
| 372 void FrameTree::UpdateLoadProgress() { | 373 void FrameTree::UpdateLoadProgress(FrameTreeNode* frame) { |
| 373 double progress = 0.0; | 374 double progress = 0.0; |
| 374 int frame_count = 0; | 375 ProgressBarCompletionOptions options = GetProgressBarCompletionOptions(); |
| 376 if (options == ProgressBarCompletionOptions::DOM_CONTENT_LOADED || | |
| 377 options == ProgressBarCompletionOptions::RESOURCES_BEFORE_DCL) { | |
|
kinuko
2016/06/08 14:26:29
nit: slightly prefer switch/case than if/else for
Nate Chapin
2016/06/14 22:51:46
Done.
| |
| 378 if (frame->IsMainFrame() && frame->has_started_loading()) | |
|
dcheng
2016/06/08 06:54:17
I wonder if we really need to pass in |frame| here
Nate Chapin
2016/06/14 22:51:46
True. Done.
| |
| 379 progress = frame->loading_progress(); | |
| 380 } else { | |
| 381 int frame_count = 0; | |
| 382 for (FrameTreeNode* node : Nodes()) { | |
| 383 // Ignore the current frame if it has not started loading. | |
| 384 if (!node->has_started_loading()) | |
| 385 continue; | |
| 386 if (options == ProgressBarCompletionOptions:: | |
| 387 RESOURCES_BEFORE_DCL_AND_SAME_ORIGIN_IFRAMES && | |
| 388 (!node->HasSameOrigin(*root_) || | |
| 389 node->current_url() == GURL(url::kAboutBlankURL))) | |
| 390 continue; | |
| 375 | 391 |
| 376 for (FrameTreeNode* node : Nodes()) { | 392 // Collect progress. |
| 377 // Ignore the current frame if it has not started loading. | 393 progress += node->loading_progress(); |
| 378 if (!node->has_started_loading()) | 394 frame_count++; |
| 379 continue; | 395 } |
| 380 | 396 if (frame_count != 0) |
| 381 // Collect progress. | 397 progress /= frame_count; |
| 382 progress += node->loading_progress(); | |
| 383 frame_count++; | |
| 384 } | 398 } |
| 385 | 399 |
| 386 if (frame_count != 0) | |
| 387 progress /= frame_count; | |
| 388 | |
| 389 if (progress <= load_progress_) | 400 if (progress <= load_progress_) |
| 390 return; | 401 return; |
| 391 load_progress_ = progress; | 402 load_progress_ = progress; |
| 392 | 403 |
| 393 // Notify the WebContents. | 404 // Notify the WebContents. |
| 394 root_->navigator()->GetDelegate()->DidChangeLoadProgress(); | 405 root_->navigator()->GetDelegate()->DidChangeLoadProgress(); |
| 395 } | 406 } |
| 396 | 407 |
| 397 void FrameTree::ResetLoadProgress() { | 408 void FrameTree::ResetLoadProgress() { |
| 398 for (FrameTreeNode* node : Nodes()) | 409 for (FrameTreeNode* node : Nodes()) |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 427 // This is only used to set page-level focus in cross-process subframes, and | 438 // This is only used to set page-level focus in cross-process subframes, and |
| 428 // requests to set focus in main frame's SiteInstance are ignored. | 439 // requests to set focus in main frame's SiteInstance are ignored. |
| 429 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { | 440 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { |
| 430 RenderFrameProxyHost* proxy = | 441 RenderFrameProxyHost* proxy = |
| 431 root_manager->GetRenderFrameProxyHost(instance); | 442 root_manager->GetRenderFrameProxyHost(instance); |
| 432 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); | 443 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); |
| 433 } | 444 } |
| 434 } | 445 } |
| 435 | 446 |
| 436 } // namespace content | 447 } // namespace content |
| OLD | NEW |