Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 2821473002: Service CreateNewWindow on the UI thread with a new mojo interface (Closed)
Patch Set: MakeShared goodness Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/render_frame_host_impl.h" 5 #include "content/browser/frame_host/render_frame_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/containers/hash_tables.h" 12 #include "base/containers/hash_tables.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/metrics/histogram_macros.h" 15 #include "base/metrics/histogram_macros.h"
16 #include "base/metrics/user_metrics.h" 16 #include "base/metrics/user_metrics.h"
17 #include "base/process/kill.h" 17 #include "base/process/kill.h"
18 #include "base/time/time.h" 18 #include "base/time/time.h"
19 #include "build/build_config.h" 19 #include "build/build_config.h"
20 #include "content/browser/accessibility/browser_accessibility_manager.h" 20 #include "content/browser/accessibility/browser_accessibility_manager.h"
21 #include "content/browser/accessibility/browser_accessibility_state_impl.h" 21 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
22 #include "content/browser/bluetooth/web_bluetooth_service_impl.h" 22 #include "content/browser/bluetooth/web_bluetooth_service_impl.h"
23 #include "content/browser/browser_main_loop.h" 23 #include "content/browser/browser_main_loop.h"
24 #include "content/browser/child_process_security_policy_impl.h" 24 #include "content/browser/child_process_security_policy_impl.h"
25 #include "content/browser/devtools/render_frame_devtools_agent_host.h" 25 #include "content/browser/devtools/render_frame_devtools_agent_host.h"
26 #include "content/browser/dom_storage/dom_storage_context_wrapper.h"
26 #include "content/browser/download/mhtml_generation_manager.h" 27 #include "content/browser/download/mhtml_generation_manager.h"
27 #include "content/browser/frame_host/cross_process_frame_connector.h" 28 #include "content/browser/frame_host/cross_process_frame_connector.h"
28 #include "content/browser/frame_host/debug_urls.h" 29 #include "content/browser/frame_host/debug_urls.h"
29 #include "content/browser/frame_host/frame_tree.h" 30 #include "content/browser/frame_host/frame_tree.h"
30 #include "content/browser/frame_host/frame_tree_node.h" 31 #include "content/browser/frame_host/frame_tree_node.h"
31 #include "content/browser/frame_host/navigation_entry_impl.h" 32 #include "content/browser/frame_host/navigation_entry_impl.h"
32 #include "content/browser/frame_host/navigation_handle_impl.h" 33 #include "content/browser/frame_host/navigation_handle_impl.h"
33 #include "content/browser/frame_host/navigation_request.h" 34 #include "content/browser/frame_host/navigation_request.h"
34 #include "content/browser/frame_host/navigator.h" 35 #include "content/browser/frame_host/navigator.h"
35 #include "content/browser/frame_host/navigator_impl.h" 36 #include "content/browser/frame_host/navigator_impl.h"
(...skipping 16 matching lines...) Expand all
52 #include "content/browser/renderer_host/render_view_host_delegate_view.h" 53 #include "content/browser/renderer_host/render_view_host_delegate_view.h"
53 #include "content/browser/renderer_host/render_view_host_impl.h" 54 #include "content/browser/renderer_host/render_view_host_impl.h"
54 #include "content/browser/renderer_host/render_widget_host_delegate.h" 55 #include "content/browser/renderer_host/render_widget_host_delegate.h"
55 #include "content/browser/renderer_host/render_widget_host_impl.h" 56 #include "content/browser/renderer_host/render_widget_host_impl.h"
56 #include "content/browser/renderer_host/render_widget_host_view_base.h" 57 #include "content/browser/renderer_host/render_widget_host_view_base.h"
57 #include "content/browser/shared_worker/shared_worker_service_impl.h" 58 #include "content/browser/shared_worker/shared_worker_service_impl.h"
58 #include "content/browser/websockets/websocket_manager.h" 59 #include "content/browser/websockets/websocket_manager.h"
59 #include "content/browser/webui/web_ui_controller_factory_registry.h" 60 #include "content/browser/webui/web_ui_controller_factory_registry.h"
60 #include "content/common/accessibility_messages.h" 61 #include "content/common/accessibility_messages.h"
61 #include "content/common/associated_interface_provider_impl.h" 62 #include "content/common/associated_interface_provider_impl.h"
63 #include "content/common/associated_interface_registry_impl.h"
62 #include "content/common/associated_interfaces.mojom.h" 64 #include "content/common/associated_interfaces.mojom.h"
63 #include "content/common/content_security_policy/content_security_policy.h" 65 #include "content/common/content_security_policy/content_security_policy.h"
64 #include "content/common/frame_messages.h" 66 #include "content/common/frame_messages.h"
65 #include "content/common/frame_owner_properties.h" 67 #include "content/common/frame_owner_properties.h"
66 #include "content/common/input_messages.h" 68 #include "content/common/input_messages.h"
67 #include "content/common/inter_process_time_ticks_converter.h" 69 #include "content/common/inter_process_time_ticks_converter.h"
68 #include "content/common/navigation_params.h" 70 #include "content/common/navigation_params.h"
69 #include "content/common/render_message_filter.mojom.h" 71 #include "content/common/render_message_filter.mojom.h"
70 #include "content/common/renderer.mojom.h" 72 #include "content/common/renderer.mojom.h"
71 #include "content/common/site_isolation_policy.h" 73 #include "content/common/site_isolation_policy.h"
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 nav_entry_id_(0), 387 nav_entry_id_(0),
386 accessibility_reset_token_(0), 388 accessibility_reset_token_(0),
387 accessibility_reset_count_(0), 389 accessibility_reset_count_(0),
388 browser_plugin_embedder_ax_tree_id_(ui::AXTreeIDRegistry::kNoAXTreeID), 390 browser_plugin_embedder_ax_tree_id_(ui::AXTreeIDRegistry::kNoAXTreeID),
389 no_create_browser_accessibility_manager_for_testing_(false), 391 no_create_browser_accessibility_manager_for_testing_(false),
390 web_ui_type_(WebUI::kNoWebUI), 392 web_ui_type_(WebUI::kNoWebUI),
391 pending_web_ui_type_(WebUI::kNoWebUI), 393 pending_web_ui_type_(WebUI::kNoWebUI),
392 should_reuse_web_ui_(false), 394 should_reuse_web_ui_(false),
393 has_selection_(false), 395 has_selection_(false),
394 last_navigation_previews_state_(PREVIEWS_UNSPECIFIED), 396 last_navigation_previews_state_(PREVIEWS_UNSPECIFIED),
395 frame_host_binding_(this), 397 frame_host_interface_broker_binding_(this),
398 frame_host_associated_binding_(this),
396 waiting_for_init_(renderer_initiated_creation), 399 waiting_for_init_(renderer_initiated_creation),
397 has_focused_editable_element_(false), 400 has_focused_editable_element_(false),
398 weak_ptr_factory_(this) { 401 weak_ptr_factory_(this) {
399 frame_tree_->AddRenderViewHostRef(render_view_host_); 402 frame_tree_->AddRenderViewHostRef(render_view_host_);
400 GetProcess()->AddRoute(routing_id_, this); 403 GetProcess()->AddRoute(routing_id_, this);
401 g_routing_id_frame_map.Get().insert(std::make_pair( 404 g_routing_id_frame_map.Get().insert(std::make_pair(
402 RenderFrameHostID(GetProcess()->GetID(), routing_id_), 405 RenderFrameHostID(GetProcess()->GetID(), routing_id_),
403 this)); 406 this));
404 site_instance_->AddObserver(this); 407 site_instance_->AddObserver(this);
405 GetSiteInstance()->IncrementActiveFrameCount(); 408 GetSiteInstance()->IncrementActiveFrameCount();
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 IPC_MESSAGE_HANDLER(FrameHostMsg_ShowCreatedWindow, OnShowCreatedWindow) 824 IPC_MESSAGE_HANDLER(FrameHostMsg_ShowCreatedWindow, OnShowCreatedWindow)
822 IPC_END_MESSAGE_MAP() 825 IPC_END_MESSAGE_MAP()
823 826
824 // No further actions here, since we may have been deleted. 827 // No further actions here, since we may have been deleted.
825 return handled; 828 return handled;
826 } 829 }
827 830
828 void RenderFrameHostImpl::OnAssociatedInterfaceRequest( 831 void RenderFrameHostImpl::OnAssociatedInterfaceRequest(
829 const std::string& interface_name, 832 const std::string& interface_name,
830 mojo::ScopedInterfaceEndpointHandle handle) { 833 mojo::ScopedInterfaceEndpointHandle handle) {
831 delegate_->OnAssociatedInterfaceRequest( 834 if (associated_registry_->CanBindRequest(interface_name)) {
832 this, interface_name, std::move(handle)); 835 associated_registry_->BindRequest(interface_name, std::move(handle));
836 } else {
837 delegate_->OnAssociatedInterfaceRequest(this, interface_name,
838 std::move(handle));
839 }
833 } 840 }
834 841
835 void RenderFrameHostImpl::AccessibilityPerformAction( 842 void RenderFrameHostImpl::AccessibilityPerformAction(
836 const ui::AXActionData& action_data) { 843 const ui::AXActionData& action_data) {
837 Send(new AccessibilityMsg_PerformAction(routing_id_, action_data)); 844 Send(new AccessibilityMsg_PerformAction(routing_id_, action_data));
838 } 845 }
839 846
840 bool RenderFrameHostImpl::AccessibilityViewHasFocus() const { 847 bool RenderFrameHostImpl::AccessibilityViewHasFocus() const {
841 RenderWidgetHostView* view = render_view_host_->GetWidget()->GetView(); 848 RenderWidgetHostView* view = render_view_host_->GetWidget()->GetView();
842 if (view) 849 if (view)
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 // shutdown). Ignore such messages. 1115 // shutdown). Ignore such messages.
1109 if (!is_active() || frame_tree_node_->current_frame_host() != this || 1116 if (!is_active() || frame_tree_node_->current_frame_host() != this ||
1110 !render_frame_created_) 1117 !render_frame_created_)
1111 return; 1118 return;
1112 1119
1113 frame_tree_->AddFrame(frame_tree_node_, GetProcess()->GetID(), new_routing_id, 1120 frame_tree_->AddFrame(frame_tree_node_, GetProcess()->GetID(), new_routing_id,
1114 scope, frame_name, frame_unique_name, sandbox_flags, 1121 scope, frame_name, frame_unique_name, sandbox_flags,
1115 container_policy, frame_owner_properties); 1122 container_policy, frame_owner_properties);
1116 } 1123 }
1117 1124
1118 void RenderFrameHostImpl::OnCreateNewWindow(
1119 int32_t render_view_route_id,
1120 int32_t main_frame_route_id,
1121 int32_t main_frame_widget_route_id,
1122 const mojom::CreateNewWindowParams& params,
1123 SessionStorageNamespace* session_storage_namespace) {
1124 mojom::CreateNewWindowParamsPtr validated_params(params.Clone());
1125 GetProcess()->FilterURL(false, &validated_params->target_url);
1126
1127 // TODO(nick): http://crbug.com/674307 |opener_url|, |opener_security_origin|,
1128 // and |opener_top_level_frame_url| should not be parameters; we can just use
1129 // last_committed_url(), etc. Of these, |opener_top_level_frame_url| is
1130 // particularly egregious, since an oopif isn't expected to know its top URL.
1131 GetProcess()->FilterURL(false, &validated_params->opener_url);
1132 GetProcess()->FilterURL(true, &validated_params->opener_security_origin);
1133
1134 // Ignore creation when sent from a frame that's not current.
1135 if (frame_tree_node_->current_frame_host() == this) {
1136 delegate_->CreateNewWindow(GetSiteInstance(), render_view_route_id,
1137 main_frame_route_id, main_frame_widget_route_id,
1138 *validated_params, session_storage_namespace);
1139 }
1140
1141 // Our caller (RenderWidgetHelper::OnCreateNewWindowOnUI) will send
1142 // ViewMsg_Close if the above step did not adopt |main_frame_route_id|.
1143 }
1144
1145 void RenderFrameHostImpl::SetLastCommittedOrigin(const url::Origin& origin) { 1125 void RenderFrameHostImpl::SetLastCommittedOrigin(const url::Origin& origin) {
1146 last_committed_origin_ = origin; 1126 last_committed_origin_ = origin;
1147 CSPContext::SetSelf(origin); 1127 CSPContext::SetSelf(origin);
1148 } 1128 }
1149 1129
1150 void RenderFrameHostImpl::OnDetach() { 1130 void RenderFrameHostImpl::OnDetach() {
1151 frame_tree_->RemoveFrame(frame_tree_node_); 1131 frame_tree_->RemoveFrame(frame_tree_node_);
1152 } 1132 }
1153 1133
1154 void RenderFrameHostImpl::OnFrameFocused() { 1134 void RenderFrameHostImpl::OnFrameFocused() {
(...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after
2451 #endif 2431 #endif
2452 2432
2453 void RenderFrameHostImpl::OnShowCreatedWindow(int pending_widget_routing_id, 2433 void RenderFrameHostImpl::OnShowCreatedWindow(int pending_widget_routing_id,
2454 WindowOpenDisposition disposition, 2434 WindowOpenDisposition disposition,
2455 const gfx::Rect& initial_rect, 2435 const gfx::Rect& initial_rect,
2456 bool user_gesture) { 2436 bool user_gesture) {
2457 delegate_->ShowCreatedWindow(GetProcess()->GetID(), pending_widget_routing_id, 2437 delegate_->ShowCreatedWindow(GetProcess()->GetID(), pending_widget_routing_id,
2458 disposition, initial_rect, user_gesture); 2438 disposition, initial_rect, user_gesture);
2459 } 2439 }
2460 2440
2441 void RenderFrameHostImpl::CreateNewWindow(
2442 mojom::CreateNewWindowParamsPtr params,
2443 const CreateNewWindowCallback& callback) {
2444 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2445
2446 bool no_javascript_access = false;
2447
2448 // Ignore creation when sent from a frame that's not current or created.
2449 bool can_create_window =
2450 frame_tree_node_->current_frame_host() == this && render_frame_created_ &&
2451 GetContentClient()->browser()->CanCreateWindow(
2452 this, params->opener_url, params->opener_top_level_frame_url,
2453 params->opener_security_origin, params->window_container_type,
2454 params->target_url, params->referrer, params->frame_name,
2455 params->disposition, *params->features, params->user_gesture,
2456 params->opener_suppressed, &no_javascript_access);
2457
2458 mojom::CreateNewWindowReplyPtr reply = mojom::CreateNewWindowReply::New();
2459 if (!can_create_window) {
2460 RunCreateWindowCompleteCallback(callback, std::move(reply),
2461 MSG_ROUTING_NONE, MSG_ROUTING_NONE,
2462 MSG_ROUTING_NONE, 0);
2463 return;
2464 }
2465
2466 // This will clone the sessionStorage for namespace_id_to_clone.
2467
2468 StoragePartition* storage_partition = BrowserContext::GetStoragePartition(
2469 GetSiteInstance()->GetBrowserContext(), GetSiteInstance());
2470 DOMStorageContextWrapper* dom_storage_context =
2471 static_cast<DOMStorageContextWrapper*>(
2472 storage_partition->GetDOMStorageContext());
2473 auto cloned_namespace = base::MakeShared<SessionStorageNamespaceImpl>(
2474 dom_storage_context, params->session_storage_namespace_id);
2475 reply->cloned_session_storage_namespace_id = cloned_namespace->id();
2476
2477 // If the opener is suppressed or script access is disallowed, we should
2478 // open the window in a new BrowsingInstance, and thus a new process. That
2479 // means the current renderer process will not be able to route messages to
2480 // it. Because of this, we will immediately show and navigate the window
2481 // in OnCreateNewWindowOnUI, using the params provided here.
2482 int render_view_route_id = MSG_ROUTING_NONE;
2483 int main_frame_route_id = MSG_ROUTING_NONE;
2484 int main_frame_widget_route_id = MSG_ROUTING_NONE;
2485 int render_process_id = GetProcess()->GetID();
2486 if (!params->opener_suppressed && !no_javascript_access) {
2487 render_view_route_id = GetProcess()->GetNextRoutingID();
2488 main_frame_route_id = GetProcess()->GetNextRoutingID();
2489 // TODO(avi): When RenderViewHostImpl has-a RenderWidgetHostImpl, this
2490 // should be updated to give the widget a distinct routing ID.
2491 // https://crbug.com/545684
2492 main_frame_widget_route_id = render_view_route_id;
2493 // Block resource requests until the frame is created, since the HWND might
2494 // be needed if a response ends up creating a plugin. We'll only have a
2495 // single frame at this point. These requests will be resumed either in
2496 // WebContentsImpl::CreateNewWindow or RenderFrameHost::Init.
2497 // TODO(crbug.com/581037): Now that NPAPI is deprecated we should be able to
2498 // remove this, but more investigation is needed.
2499 auto block_requests_for_route = base::Bind(
2500 [](const GlobalFrameRoutingId& id) {
2501 auto* rdh = ResourceDispatcherHostImpl::Get();
2502 if (rdh)
2503 rdh->BlockRequestsForRoute(id);
2504 },
2505 GlobalFrameRoutingId(render_process_id, main_frame_route_id));
2506 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
2507 block_requests_for_route);
2508 }
2509
2510 DCHECK(IsRenderFrameLive());
2511
2512 // Actually validate the params and create the window.
2513 mojom::CreateNewWindowParamsPtr validated_params(params.Clone());
2514 GetProcess()->FilterURL(false, &validated_params->target_url);
2515
2516 // TODO(nick): http://crbug.com/674307 |opener_url|, |opener_security_origin|,
2517 // and |opener_top_level_frame_url| should not be parameters; we can just use
2518 // last_committed_url(), etc. Of these, |opener_top_level_frame_url| is
2519 // particularly egregious, since an oopif isn't expected to know its top URL.
2520 GetProcess()->FilterURL(false, &validated_params->opener_url);
2521 GetProcess()->FilterURL(true, &validated_params->opener_security_origin);
2522
2523 delegate_->CreateNewWindow(this, render_view_route_id, main_frame_route_id,
2524 main_frame_widget_route_id, *validated_params,
2525 cloned_namespace.get());
2526
2527 // If we did not create a WebContents to host the renderer-created
2528 // RenderFrame/RenderView/RenderWidget objects, make sure to send invalid
2529 // routing ids back to the renderer.
2530 if (main_frame_route_id != MSG_ROUTING_NONE) {
2531 bool succeeded =
2532 RenderWidgetHost::FromID(render_process_id,
2533 main_frame_widget_route_id) != nullptr;
2534 if (!succeeded) {
2535 DCHECK(!RenderFrameHost::FromID(render_process_id, main_frame_route_id));
2536 DCHECK(!RenderViewHost::FromID(render_process_id, render_view_route_id));
2537 RunCreateWindowCompleteCallback(callback, std::move(reply),
2538 MSG_ROUTING_NONE, MSG_ROUTING_NONE,
2539 MSG_ROUTING_NONE, 0);
2540 return;
2541 }
2542 DCHECK(RenderFrameHost::FromID(render_process_id, main_frame_route_id));
2543 DCHECK(RenderViewHost::FromID(render_process_id, render_view_route_id));
2544 }
2545
2546 RunCreateWindowCompleteCallback(
2547 callback, std::move(reply), render_view_route_id, main_frame_route_id,
2548 main_frame_widget_route_id, cloned_namespace->id());
2549 }
2550
2551 void RenderFrameHostImpl::RunCreateWindowCompleteCallback(
2552 const CreateNewWindowCallback& callback,
2553 mojom::CreateNewWindowReplyPtr reply,
2554 int render_view_route_id,
2555 int main_frame_route_id,
2556 int main_frame_widget_route_id,
2557 int cloned_session_storage_namespace_id) {
2558 reply->route_id = render_view_route_id;
2559 reply->main_frame_route_id = main_frame_route_id;
2560 reply->main_frame_widget_route_id = main_frame_widget_route_id;
2561 reply->cloned_session_storage_namespace_id =
2562 cloned_session_storage_namespace_id;
2563 callback.Run(std::move(reply));
2564 }
2565
2461 void RenderFrameHostImpl::RegisterMojoInterfaces() { 2566 void RenderFrameHostImpl::RegisterMojoInterfaces() {
2462 device::GeolocationServiceContext* geolocation_service_context = 2567 device::GeolocationServiceContext* geolocation_service_context =
2463 delegate_ ? delegate_->GetGeolocationServiceContext() : NULL; 2568 delegate_ ? delegate_->GetGeolocationServiceContext() : NULL;
2464 2569
2465 #if !defined(OS_ANDROID) 2570 #if !defined(OS_ANDROID)
2466 // The default (no-op) implementation of InstalledAppProvider. On Android, the 2571 // The default (no-op) implementation of InstalledAppProvider. On Android, the
2467 // real implementation is provided in Java. 2572 // real implementation is provided in Java.
2468 GetInterfaceRegistry()->AddInterface( 2573 GetInterfaceRegistry()->AddInterface(
2469 base::Bind(&InstalledAppProviderImplDefault::Create)); 2574 base::Bind(&InstalledAppProviderImplDefault::Create));
2470 #endif // !defined(OS_ANDROID) 2575 #endif // !defined(OS_ANDROID)
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
2898 3003
2899 // An error page is expected to commit, hence why is_loading_ is set to true. 3004 // An error page is expected to commit, hence why is_loading_ is set to true.
2900 is_loading_ = true; 3005 is_loading_ = true;
2901 frame_tree_node_->ResetNavigationRequest(true, true); 3006 frame_tree_node_->ResetNavigationRequest(true, true);
2902 } 3007 }
2903 3008
2904 void RenderFrameHostImpl::SetUpMojoIfNeeded() { 3009 void RenderFrameHostImpl::SetUpMojoIfNeeded() {
2905 if (interface_registry_.get()) 3010 if (interface_registry_.get())
2906 return; 3011 return;
2907 3012
3013 associated_registry_ = base::MakeUnique<AssociatedInterfaceRegistryImpl>();
2908 interface_registry_ = base::MakeUnique<service_manager::InterfaceRegistry>( 3014 interface_registry_ = base::MakeUnique<service_manager::InterfaceRegistry>(
2909 mojom::kNavigation_FrameSpec); 3015 mojom::kNavigation_FrameSpec);
2910 3016
3017 auto make_binding = [](RenderFrameHostImpl* impl,
3018 mojom::FrameHostAssociatedRequest request) {
3019 impl->frame_host_associated_binding_.Bind(std::move(request));
3020 };
3021 static_cast<AssociatedInterfaceRegistry*>(associated_registry_.get())
3022 ->AddInterface(base::Bind(make_binding, base::Unretained(this)));
3023
2911 ServiceManagerConnection* service_manager_connection = 3024 ServiceManagerConnection* service_manager_connection =
2912 BrowserContext::GetServiceManagerConnectionFor( 3025 BrowserContext::GetServiceManagerConnectionFor(
2913 GetProcess()->GetBrowserContext()); 3026 GetProcess()->GetBrowserContext());
2914 // |service_manager_connection| may not be set in unit tests using 3027 // |service_manager_connection| may not be set in unit tests using
2915 // TestBrowserContext. 3028 // TestBrowserContext.
2916 if (service_manager_connection) { 3029 if (service_manager_connection) {
2917 on_connect_handler_id_ = service_manager_connection->AddOnConnectHandler( 3030 on_connect_handler_id_ = service_manager_connection->AddOnConnectHandler(
2918 base::Bind(&RenderFrameHostImpl::OnRendererConnect, 3031 base::Bind(&RenderFrameHostImpl::OnRendererConnect,
2919 weak_ptr_factory_.GetWeakPtr())); 3032 weak_ptr_factory_.GetWeakPtr()));
2920 } 3033 }
2921 3034
2922 RegisterMojoInterfaces(); 3035 RegisterMojoInterfaces();
2923 mojom::FrameFactoryPtr frame_factory; 3036 mojom::FrameFactoryPtr frame_factory;
2924 BindInterface(GetProcess(), &frame_factory); 3037 BindInterface(GetProcess(), &frame_factory);
2925 frame_factory->CreateFrame(routing_id_, MakeRequest(&frame_), 3038 frame_factory->CreateFrame(
2926 frame_host_binding_.CreateInterfacePtrAndBind()); 3039 routing_id_, MakeRequest(&frame_),
3040 frame_host_interface_broker_binding_.CreateInterfacePtrAndBind());
2927 3041
2928 service_manager::mojom::InterfaceProviderPtr remote_interfaces; 3042 service_manager::mojom::InterfaceProviderPtr remote_interfaces;
2929 service_manager::mojom::InterfaceProviderRequest remote_interfaces_request( 3043 service_manager::mojom::InterfaceProviderRequest remote_interfaces_request(
2930 &remote_interfaces); 3044 &remote_interfaces);
2931 remote_interfaces_.reset(new service_manager::InterfaceProvider); 3045 remote_interfaces_.reset(new service_manager::InterfaceProvider);
2932 remote_interfaces_->Bind(std::move(remote_interfaces)); 3046 remote_interfaces_->Bind(std::move(remote_interfaces));
2933 frame_->GetInterfaceProvider(std::move(remote_interfaces_request)); 3047 frame_->GetInterfaceProvider(std::move(remote_interfaces_request));
2934 } 3048 }
2935 3049
2936 void RenderFrameHostImpl::InvalidateMojoConnection() { 3050 void RenderFrameHostImpl::InvalidateMojoConnection() {
2937 interface_registry_.reset(); 3051 interface_registry_.reset();
2938 3052
2939 ServiceManagerConnection* service_manager_connection = 3053 ServiceManagerConnection* service_manager_connection =
2940 BrowserContext::GetServiceManagerConnectionFor( 3054 BrowserContext::GetServiceManagerConnectionFor(
2941 GetProcess()->GetBrowserContext()); 3055 GetProcess()->GetBrowserContext());
2942 // |service_manager_connection| may be null in tests using TestBrowserContext. 3056 // |service_manager_connection| may be null in tests using TestBrowserContext.
2943 if (service_manager_connection) { 3057 if (service_manager_connection) {
2944 service_manager_connection->RemoveOnConnectHandler(on_connect_handler_id_); 3058 service_manager_connection->RemoveOnConnectHandler(on_connect_handler_id_);
2945 on_connect_handler_id_ = 0; 3059 on_connect_handler_id_ = 0;
2946 } 3060 }
2947 3061
2948 frame_.reset(); 3062 frame_.reset();
2949 frame_host_binding_.Close(); 3063 frame_host_interface_broker_binding_.Close();
2950 frame_bindings_control_.reset(); 3064 frame_bindings_control_.reset();
2951 3065
2952 // Disconnect with ImageDownloader Mojo service in RenderFrame. 3066 // Disconnect with ImageDownloader Mojo service in RenderFrame.
2953 mojo_image_downloader_.reset(); 3067 mojo_image_downloader_.reset();
2954 } 3068 }
2955 3069
2956 bool RenderFrameHostImpl::IsFocused() { 3070 bool RenderFrameHostImpl::IsFocused() {
2957 return GetRenderWidgetHost()->is_focused() && 3071 return GetRenderWidgetHost()->is_focused() &&
2958 frame_tree_->GetFocusedFrame() && 3072 frame_tree_->GetFocusedFrame() &&
2959 (frame_tree_->GetFocusedFrame() == frame_tree_node() || 3073 (frame_tree_->GetFocusedFrame() == frame_tree_node() ||
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
3679 } 3793 }
3680 3794
3681 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame( 3795 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame(
3682 const std::string& interface_name, 3796 const std::string& interface_name,
3683 mojo::ScopedMessagePipeHandle pipe) { 3797 mojo::ScopedMessagePipeHandle pipe) {
3684 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe)); 3798 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe));
3685 } 3799 }
3686 #endif 3800 #endif
3687 3801
3688 } // namespace content 3802 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698