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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 if (!frame->parent()) { | 362 if (!frame->parent()) { |
| 362 CHECK_EQ(frame, root_); | 363 CHECK_EQ(frame, root_); |
| 363 return; | 364 return; |
| 364 } | 365 } |
| 365 | 366 |
| 366 // Notify observers of the frame removal. | 367 // Notify observers of the frame removal. |
| 367 if (!on_frame_removed_.is_null()) | 368 if (!on_frame_removed_.is_null()) |
| 368 on_frame_removed_.Run(frame->current_frame_host()); | 369 on_frame_removed_.Run(frame->current_frame_host()); |
| 369 } | 370 } |
| 370 | 371 |
| 371 void FrameTree::UpdateLoadProgress() { | 372 void FrameTree::UpdateLoadProgress(FrameTreeNode* frame) { |
| 372 double progress = 0.0; | 373 double progress = 0.0; |
| 373 int frame_count = 0; | 374 if (GetProgressBarCompletionOptions() == |
| 375 PROGRESS_BAR_COMPLETION_LOAD_EVENT) { | |
| 376 int frame_count = 0; | |
| 377 for (FrameTreeNode* node : Nodes()) { | |
| 378 // Ignore the current frame if it has not started loading. | |
| 379 if (!node->has_started_loading()) | |
| 380 continue; | |
| 374 | 381 |
| 375 for (FrameTreeNode* node : Nodes()) { | 382 // Collect progress. |
| 376 // Ignore the current frame if it has not started loading. | 383 progress += node->loading_progress(); |
| 377 if (!node->has_started_loading()) | 384 frame_count++; |
| 378 continue; | 385 } |
| 379 | 386 if (frame_count != 0) |
| 380 // Collect progress. | 387 progress /= frame_count; |
| 381 progress += node->loading_progress(); | 388 } else if (root_ == frame && root_->has_started_loading()) { |
|
dcheng
2016/05/10 06:28:50
Maybe just use frame->IsMainFrame()?
Nate Chapin
2016/05/11 00:06:58
Done.
| |
| 382 frame_count++; | 389 progress = frame->loading_progress(); |
| 383 } | 390 } |
| 384 | 391 |
| 385 if (frame_count != 0) | |
| 386 progress /= frame_count; | |
| 387 | |
| 388 if (progress <= load_progress_) | 392 if (progress <= load_progress_) |
| 389 return; | 393 return; |
| 390 load_progress_ = progress; | 394 load_progress_ = progress; |
| 391 | 395 |
| 392 // Notify the WebContents. | 396 // Notify the WebContents. |
| 393 root_->navigator()->GetDelegate()->DidChangeLoadProgress(); | 397 root_->navigator()->GetDelegate()->DidChangeLoadProgress(); |
| 394 } | 398 } |
| 395 | 399 |
| 396 void FrameTree::ResetLoadProgress() { | 400 void FrameTree::ResetLoadProgress() { |
| 397 for (FrameTreeNode* node : Nodes()) | 401 for (FrameTreeNode* node : Nodes()) |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 426 // This is only used to set page-level focus in cross-process subframes, and | 430 // This is only used to set page-level focus in cross-process subframes, and |
| 427 // requests to set focus in main frame's SiteInstance are ignored. | 431 // requests to set focus in main frame's SiteInstance are ignored. |
| 428 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { | 432 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { |
| 429 RenderFrameProxyHost* proxy = | 433 RenderFrameProxyHost* proxy = |
| 430 root_manager->GetRenderFrameProxyHost(instance); | 434 root_manager->GetRenderFrameProxyHost(instance); |
| 431 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); | 435 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); |
| 432 } | 436 } |
| 433 } | 437 } |
| 434 | 438 |
| 435 } // namespace content | 439 } // namespace content |
| OLD | NEW |