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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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() { |
373 double progress = 0.0; | 374 double progress = 0.0; |
| 375 ProgressBarCompletion completion = GetProgressBarCompletionPolicy(); |
374 int frame_count = 0; | 376 int frame_count = 0; |
375 | 377 switch (completion) { |
376 for (FrameTreeNode* node : Nodes()) { | 378 case ProgressBarCompletion::DOM_CONTENT_LOADED: |
377 // Ignore the current frame if it has not started loading. | 379 case ProgressBarCompletion::RESOURCES_BEFORE_DCL: |
378 if (!node->has_started_loading()) | 380 if (root_->has_started_loading()) |
379 continue; | 381 progress = root_->loading_progress(); |
380 | 382 break; |
381 // Collect progress. | 383 case ProgressBarCompletion::LOAD_EVENT: |
382 progress += node->loading_progress(); | 384 for (FrameTreeNode* node : Nodes()) { |
383 frame_count++; | 385 // Ignore the current frame if it has not started loading. |
| 386 if (!node->has_started_loading()) |
| 387 continue; |
| 388 progress += node->loading_progress(); |
| 389 frame_count++; |
| 390 } |
| 391 break; |
| 392 case ProgressBarCompletion::RESOURCES_BEFORE_DCL_AND_SAME_ORIGIN_IFRAMES: |
| 393 for (FrameTreeNode* node : Nodes()) { |
| 394 // Ignore the current frame if it has not started loading, |
| 395 // if the frame is cross-origin, or about:blank. |
| 396 if (!node->has_started_loading() || !node->HasSameOrigin(*root_) || |
| 397 node->current_url() == GURL(url::kAboutBlankURL)) |
| 398 continue; |
| 399 progress += node->loading_progress(); |
| 400 frame_count++; |
| 401 } |
| 402 break; |
| 403 default: |
| 404 NOTREACHED(); |
384 } | 405 } |
385 | 406 |
386 if (frame_count != 0) | 407 if (frame_count != 0) |
387 progress /= frame_count; | 408 progress /= frame_count; |
388 | 409 |
389 if (progress <= load_progress_) | 410 if (progress <= load_progress_) |
390 return; | 411 return; |
391 load_progress_ = progress; | 412 load_progress_ = progress; |
392 | 413 |
393 // Notify the WebContents. | 414 // Notify the WebContents. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 // This is only used to set page-level focus in cross-process subframes, and | 448 // 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. | 449 // requests to set focus in main frame's SiteInstance are ignored. |
429 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { | 450 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { |
430 RenderFrameProxyHost* proxy = | 451 RenderFrameProxyHost* proxy = |
431 root_manager->GetRenderFrameProxyHost(instance); | 452 root_manager->GetRenderFrameProxyHost(instance); |
432 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); | 453 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); |
433 } | 454 } |
434 } | 455 } |
435 | 456 |
436 } // namespace content | 457 } // namespace content |
OLD | NEW |