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/renderer/render_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "base/memory/shared_memory.h" | 22 #include "base/memory/shared_memory.h" |
23 #include "base/memory/weak_ptr.h" | 23 #include "base/memory/weak_ptr.h" |
24 #include "base/metrics/field_trial.h" | 24 #include "base/metrics/field_trial.h" |
25 #include "base/metrics/histogram.h" | 25 #include "base/metrics/histogram.h" |
26 #include "base/process/process.h" | 26 #include "base/process/process.h" |
27 #include "base/stl_util.h" | 27 #include "base/stl_util.h" |
28 #include "base/strings/string16.h" | 28 #include "base/strings/string16.h" |
29 #include "base/strings/utf_string_conversions.h" | 29 #include "base/strings/utf_string_conversions.h" |
30 #include "base/thread_task_runner_handle.h" | 30 #include "base/thread_task_runner_handle.h" |
31 #include "base/time/time.h" | 31 #include "base/time/time.h" |
| 32 #include "base/trace_event/trace_event_argument.h" |
32 #include "build/build_config.h" | 33 #include "build/build_config.h" |
33 #include "cc/base/switches.h" | 34 #include "cc/base/switches.h" |
34 #include "components/scheduler/renderer/renderer_scheduler.h" | 35 #include "components/scheduler/renderer/renderer_scheduler.h" |
35 #include "content/child/appcache/appcache_dispatcher.h" | 36 #include "content/child/appcache/appcache_dispatcher.h" |
36 #include "content/child/permissions/permission_dispatcher.h" | 37 #include "content/child/permissions/permission_dispatcher.h" |
37 #include "content/child/plugin_messages.h" | 38 #include "content/child/plugin_messages.h" |
38 #include "content/child/quota_dispatcher.h" | 39 #include "content/child/quota_dispatcher.h" |
39 #include "content/child/request_extra_data.h" | 40 #include "content/child/request_extra_data.h" |
40 #include "content/child/service_worker/service_worker_handle_reference.h" | 41 #include "content/child/service_worker/service_worker_handle_reference.h" |
41 #include "content/child/service_worker/service_worker_network_provider.h" | 42 #include "content/child/service_worker/service_worker_network_provider.h" |
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 int32_t widget_routing_id, | 827 int32_t widget_routing_id, |
827 bool hidden, | 828 bool hidden, |
828 const blink::WebScreenInfo& screen_info, | 829 const blink::WebScreenInfo& screen_info, |
829 CompositorDependencies* compositor_deps, | 830 CompositorDependencies* compositor_deps, |
830 blink::WebFrame* opener) { | 831 blink::WebFrame* opener) { |
831 // A main frame RenderFrame must have a RenderWidget. | 832 // A main frame RenderFrame must have a RenderWidget. |
832 DCHECK_NE(MSG_ROUTING_NONE, widget_routing_id); | 833 DCHECK_NE(MSG_ROUTING_NONE, widget_routing_id); |
833 | 834 |
834 RenderFrameImpl* render_frame = | 835 RenderFrameImpl* render_frame = |
835 RenderFrameImpl::Create(render_view, routing_id); | 836 RenderFrameImpl::Create(render_view, routing_id); |
| 837 render_frame->InitializeBlameContext(nullptr); |
836 WebLocalFrame* web_frame = WebLocalFrame::create( | 838 WebLocalFrame* web_frame = WebLocalFrame::create( |
837 blink::WebTreeScopeType::Document, render_frame, opener); | 839 blink::WebTreeScopeType::Document, render_frame, opener); |
838 render_frame->BindToWebFrame(web_frame); | 840 render_frame->BindToWebFrame(web_frame); |
839 render_view->webview()->setMainFrame(web_frame); | 841 render_view->webview()->setMainFrame(web_frame); |
840 render_frame->render_widget_ = RenderWidget::CreateForFrame( | 842 render_frame->render_widget_ = RenderWidget::CreateForFrame( |
841 widget_routing_id, hidden, screen_info, compositor_deps, web_frame); | 843 widget_routing_id, hidden, screen_info, compositor_deps, web_frame); |
842 // TODO(kenrb): Observing shouldn't be necessary when we sort out | 844 // TODO(kenrb): Observing shouldn't be necessary when we sort out |
843 // WasShown and WasHidden, separating page-level visibility from | 845 // WasShown and WasHidden, separating page-level visibility from |
844 // frame-level visibility. | 846 // frame-level visibility. |
845 // TODO(avi): This DCHECK is to track cleanup for https://crbug.com/545684 | 847 // TODO(avi): This DCHECK is to track cleanup for https://crbug.com/545684 |
(...skipping 26 matching lines...) Expand all Loading... |
872 | 874 |
873 blink::WebFrame* previous_sibling_web_frame = nullptr; | 875 blink::WebFrame* previous_sibling_web_frame = nullptr; |
874 RenderFrameProxy* previous_sibling_proxy = | 876 RenderFrameProxy* previous_sibling_proxy = |
875 RenderFrameProxy::FromRoutingID(previous_sibling_routing_id); | 877 RenderFrameProxy::FromRoutingID(previous_sibling_routing_id); |
876 if (previous_sibling_proxy) | 878 if (previous_sibling_proxy) |
877 previous_sibling_web_frame = previous_sibling_proxy->web_frame(); | 879 previous_sibling_web_frame = previous_sibling_proxy->web_frame(); |
878 | 880 |
879 // Create the RenderFrame and WebLocalFrame, linking the two. | 881 // Create the RenderFrame and WebLocalFrame, linking the two. |
880 render_frame = | 882 render_frame = |
881 RenderFrameImpl::Create(parent_proxy->render_view(), routing_id); | 883 RenderFrameImpl::Create(parent_proxy->render_view(), routing_id); |
| 884 render_frame->InitializeBlameContext(FromRoutingID(parent_routing_id)); |
882 web_frame = parent_web_frame->createLocalChild( | 885 web_frame = parent_web_frame->createLocalChild( |
883 replicated_state.scope, WebString::fromUTF8(replicated_state.name), | 886 replicated_state.scope, WebString::fromUTF8(replicated_state.name), |
884 WebString::fromUTF8(replicated_state.unique_name), | 887 WebString::fromUTF8(replicated_state.unique_name), |
885 replicated_state.sandbox_flags, render_frame, | 888 replicated_state.sandbox_flags, render_frame, |
886 previous_sibling_web_frame, frame_owner_properties, | 889 previous_sibling_web_frame, frame_owner_properties, |
887 ResolveOpener(opener_routing_id, nullptr)); | 890 ResolveOpener(opener_routing_id, nullptr)); |
888 | 891 |
889 // The RenderFrame is created and inserted into the frame tree in the above | 892 // The RenderFrame is created and inserted into the frame tree in the above |
890 // call to createLocalChild. | 893 // call to createLocalChild. |
891 render_frame->in_frame_tree_ = true; | 894 render_frame->in_frame_tree_ = true; |
892 } else { | 895 } else { |
893 RenderFrameProxy* proxy = | 896 RenderFrameProxy* proxy = |
894 RenderFrameProxy::FromRoutingID(proxy_routing_id); | 897 RenderFrameProxy::FromRoutingID(proxy_routing_id); |
895 // The remote frame could've been detached while the remote-to-local | 898 // The remote frame could've been detached while the remote-to-local |
896 // navigation was being initiated in the browser process. Drop the | 899 // navigation was being initiated in the browser process. Drop the |
897 // navigation and don't create the frame in that case. See | 900 // navigation and don't create the frame in that case. See |
898 // https://crbug.com/526304. | 901 // https://crbug.com/526304. |
899 if (!proxy) | 902 if (!proxy) |
900 return; | 903 return; |
901 | 904 |
902 render_frame = RenderFrameImpl::Create(proxy->render_view(), routing_id); | 905 render_frame = RenderFrameImpl::Create(proxy->render_view(), routing_id); |
| 906 render_frame->InitializeBlameContext(nullptr); |
903 render_frame->proxy_routing_id_ = proxy_routing_id; | 907 render_frame->proxy_routing_id_ = proxy_routing_id; |
904 web_frame = blink::WebLocalFrame::createProvisional( | 908 web_frame = blink::WebLocalFrame::createProvisional( |
905 render_frame, proxy->web_frame(), replicated_state.sandbox_flags, | 909 render_frame, proxy->web_frame(), replicated_state.sandbox_flags, |
906 frame_owner_properties); | 910 frame_owner_properties); |
907 } | 911 } |
908 render_frame->BindToWebFrame(web_frame); | 912 render_frame->BindToWebFrame(web_frame); |
909 CHECK(parent_routing_id != MSG_ROUTING_NONE || !web_frame->parent()); | 913 CHECK(parent_routing_id != MSG_ROUTING_NONE || !web_frame->parent()); |
910 | 914 |
911 if (widget_params.routing_id != MSG_ROUTING_NONE) { | 915 if (widget_params.routing_id != MSG_ROUTING_NONE) { |
912 CHECK(!web_frame->parent() || | 916 CHECK(!web_frame->parent() || |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 geolocation_dispatcher_(NULL), | 1021 geolocation_dispatcher_(NULL), |
1018 push_messaging_dispatcher_(NULL), | 1022 push_messaging_dispatcher_(NULL), |
1019 presentation_dispatcher_(NULL), | 1023 presentation_dispatcher_(NULL), |
1020 screen_orientation_dispatcher_(NULL), | 1024 screen_orientation_dispatcher_(NULL), |
1021 manifest_manager_(NULL), | 1025 manifest_manager_(NULL), |
1022 accessibility_mode_(AccessibilityModeOff), | 1026 accessibility_mode_(AccessibilityModeOff), |
1023 renderer_accessibility_(NULL), | 1027 renderer_accessibility_(NULL), |
1024 media_player_delegate_(NULL), | 1028 media_player_delegate_(NULL), |
1025 is_using_lofi_(false), | 1029 is_using_lofi_(false), |
1026 is_pasting_(false), | 1030 is_pasting_(false), |
| 1031 blame_context_(nullptr), |
1027 weak_factory_(this) { | 1032 weak_factory_(this) { |
1028 std::pair<RoutingIDFrameMap::iterator, bool> result = | 1033 std::pair<RoutingIDFrameMap::iterator, bool> result = |
1029 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); | 1034 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); |
1030 CHECK(result.second) << "Inserting a duplicate item."; | 1035 CHECK(result.second) << "Inserting a duplicate item."; |
1031 | 1036 |
1032 RenderThread::Get()->AddRoute(routing_id_, this); | 1037 RenderThread::Get()->AddRoute(routing_id_, this); |
1033 | 1038 |
1034 render_view_->RegisterRenderFrame(this); | 1039 render_view_->RegisterRenderFrame(this); |
1035 | 1040 |
1036 // Everything below subclasses RenderFrameObserver and is automatically | 1041 // Everything below subclasses RenderFrameObserver and is automatically |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 devtools_agent_ = new DevToolsAgent(this); | 1116 devtools_agent_ = new DevToolsAgent(this); |
1112 } | 1117 } |
1113 | 1118 |
1114 RegisterMojoServices(); | 1119 RegisterMojoServices(); |
1115 | 1120 |
1116 // We delay calling this until we have the WebFrame so that any observer or | 1121 // We delay calling this until we have the WebFrame so that any observer or |
1117 // embedder can call GetWebFrame on any RenderFrame. | 1122 // embedder can call GetWebFrame on any RenderFrame. |
1118 GetContentClient()->renderer()->RenderFrameCreated(this); | 1123 GetContentClient()->renderer()->RenderFrameCreated(this); |
1119 } | 1124 } |
1120 | 1125 |
| 1126 void RenderFrameImpl::InitializeBlameContext(RenderFrameImpl* parent_frame) { |
| 1127 DCHECK(!blame_context_); |
| 1128 blame_context_ = new FrameBlameContext(this, parent_frame); |
| 1129 blame_context_->Initialize(); |
| 1130 } |
| 1131 |
1121 RenderWidget* RenderFrameImpl::GetRenderWidget() { | 1132 RenderWidget* RenderFrameImpl::GetRenderWidget() { |
1122 RenderFrameImpl* local_root = | 1133 RenderFrameImpl* local_root = |
1123 RenderFrameImpl::FromWebFrame(frame_->localRoot()); | 1134 RenderFrameImpl::FromWebFrame(frame_->localRoot()); |
1124 return local_root->render_widget_.get(); | 1135 return local_root->render_widget_.get(); |
1125 } | 1136 } |
1126 | 1137 |
1127 #if defined(ENABLE_PLUGINS) | 1138 #if defined(ENABLE_PLUGINS) |
1128 void RenderFrameImpl::PepperPluginCreated(RendererPpapiHost* host) { | 1139 void RenderFrameImpl::PepperPluginCreated(RendererPpapiHost* host) { |
1129 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, | 1140 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, |
1130 DidCreatePepperPlugin(host)); | 1141 DidCreatePepperPlugin(host)); |
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2527 return external_popup_menu_.get(); | 2538 return external_popup_menu_.get(); |
2528 #else | 2539 #else |
2529 return NULL; | 2540 return NULL; |
2530 #endif | 2541 #endif |
2531 } | 2542 } |
2532 | 2543 |
2533 blink::WebCookieJar* RenderFrameImpl::cookieJar() { | 2544 blink::WebCookieJar* RenderFrameImpl::cookieJar() { |
2534 return &cookie_jar_; | 2545 return &cookie_jar_; |
2535 } | 2546 } |
2536 | 2547 |
| 2548 blink::BlameContext* RenderFrameImpl::frameBlameContext() { |
| 2549 DCHECK(blame_context_); |
| 2550 return blame_context_; |
| 2551 } |
| 2552 |
2537 blink::WebServiceWorkerProvider* | 2553 blink::WebServiceWorkerProvider* |
2538 RenderFrameImpl::createServiceWorkerProvider() { | 2554 RenderFrameImpl::createServiceWorkerProvider() { |
2539 // At this point we should have non-null data source. | 2555 // At this point we should have non-null data source. |
2540 DCHECK(frame_->dataSource()); | 2556 DCHECK(frame_->dataSource()); |
2541 if (!ChildThreadImpl::current()) | 2557 if (!ChildThreadImpl::current()) |
2542 return nullptr; // May be null in some tests. | 2558 return nullptr; // May be null in some tests. |
2543 ServiceWorkerNetworkProvider* provider = | 2559 ServiceWorkerNetworkProvider* provider = |
2544 ServiceWorkerNetworkProvider::FromDocumentState( | 2560 ServiceWorkerNetworkProvider::FromDocumentState( |
2545 DocumentState::FromDataSource(frame_->dataSource())); | 2561 DocumentState::FromDataSource(frame_->dataSource())); |
2546 DCHECK(provider); | 2562 DCHECK(provider); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2600 | 2616 |
2601 // Tracing analysis uses this to find main frames when this value is | 2617 // Tracing analysis uses this to find main frames when this value is |
2602 // MSG_ROUTING_NONE, and build the frame tree otherwise. | 2618 // MSG_ROUTING_NONE, and build the frame tree otherwise. |
2603 TRACE_EVENT2("navigation", "RenderFrameImpl::createChildFrame", | 2619 TRACE_EVENT2("navigation", "RenderFrameImpl::createChildFrame", |
2604 "id", routing_id_, | 2620 "id", routing_id_, |
2605 "child", child_routing_id); | 2621 "child", child_routing_id); |
2606 | 2622 |
2607 // Create the RenderFrame and WebLocalFrame, linking the two. | 2623 // Create the RenderFrame and WebLocalFrame, linking the two. |
2608 RenderFrameImpl* child_render_frame = RenderFrameImpl::Create( | 2624 RenderFrameImpl* child_render_frame = RenderFrameImpl::Create( |
2609 render_view_.get(), child_routing_id); | 2625 render_view_.get(), child_routing_id); |
| 2626 child_render_frame->InitializeBlameContext(this); |
2610 blink::WebLocalFrame* web_frame = | 2627 blink::WebLocalFrame* web_frame = |
2611 WebLocalFrame::create(scope, child_render_frame); | 2628 WebLocalFrame::create(scope, child_render_frame); |
2612 child_render_frame->BindToWebFrame(web_frame); | 2629 child_render_frame->BindToWebFrame(web_frame); |
2613 | 2630 |
2614 // Add the frame to the frame tree and initialize it. | 2631 // Add the frame to the frame tree and initialize it. |
2615 parent->appendChild(web_frame); | 2632 parent->appendChild(web_frame); |
2616 child_render_frame->in_frame_tree_ = true; | 2633 child_render_frame->in_frame_tree_ = true; |
2617 child_render_frame->Initialize(); | 2634 child_render_frame->Initialize(); |
2618 | 2635 |
2619 return web_frame; | 2636 return web_frame; |
(...skipping 3391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6011 int match_count, | 6028 int match_count, |
6012 int ordinal, | 6029 int ordinal, |
6013 const WebRect& selection_rect, | 6030 const WebRect& selection_rect, |
6014 bool final_status_update) { | 6031 bool final_status_update) { |
6015 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, | 6032 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, |
6016 selection_rect, ordinal, | 6033 selection_rect, ordinal, |
6017 final_status_update)); | 6034 final_status_update)); |
6018 } | 6035 } |
6019 | 6036 |
6020 } // namespace content | 6037 } // namespace content |
OLD | NEW |