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

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

Issue 2456493003: Add frame-specific InterfaceProviderSpec. (Closed)
Patch Set: . Created 4 years, 1 month 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 <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 #include "content/public/browser/stream_handle.h" 81 #include "content/public/browser/stream_handle.h"
82 #include "content/public/browser/user_metrics.h" 82 #include "content/public/browser/user_metrics.h"
83 #include "content/public/common/browser_side_navigation_policy.h" 83 #include "content/public/common/browser_side_navigation_policy.h"
84 #include "content/public/common/content_constants.h" 84 #include "content/public/common/content_constants.h"
85 #include "content/public/common/content_features.h" 85 #include "content/public/common/content_features.h"
86 #include "content/public/common/content_switches.h" 86 #include "content/public/common/content_switches.h"
87 #include "content/public/common/file_chooser_file_info.h" 87 #include "content/public/common/file_chooser_file_info.h"
88 #include "content/public/common/file_chooser_params.h" 88 #include "content/public/common/file_chooser_params.h"
89 #include "content/public/common/isolated_world_ids.h" 89 #include "content/public/common/isolated_world_ids.h"
90 #include "content/public/common/service_manager_connection.h" 90 #include "content/public/common/service_manager_connection.h"
91 #include "content/public/common/service_names.h"
91 #include "content/public/common/url_constants.h" 92 #include "content/public/common/url_constants.h"
92 #include "content/public/common/url_utils.h" 93 #include "content/public/common/url_utils.h"
93 #include "device/generic_sensor/sensor_provider_impl.h" 94 #include "device/generic_sensor/sensor_provider_impl.h"
94 #include "device/geolocation/geolocation_service_context.h" 95 #include "device/geolocation/geolocation_service_context.h"
95 #include "device/vibration/vibration_manager_impl.h" 96 #include "device/vibration/vibration_manager_impl.h"
96 #include "device/wake_lock/wake_lock_service_context.h" 97 #include "device/wake_lock/wake_lock_service_context.h"
97 #include "media/base/media_switches.h" 98 #include "media/base/media_switches.h"
98 #include "media/mojo/interfaces/media_service.mojom.h" 99 #include "media/mojo/interfaces/media_service.mojom.h"
99 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" 100 #include "mojo/public/cpp/bindings/associated_interface_ptr.h"
100 #include "mojo/public/cpp/bindings/strong_binding.h" 101 #include "mojo/public/cpp/bindings/strong_binding.h"
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 806
806 // Any future UpdateState or UpdateTitle messages from this or a recreated 807 // Any future UpdateState or UpdateTitle messages from this or a recreated
807 // process should be ignored until the next commit. 808 // process should be ignored until the next commit.
808 set_nav_entry_id(0); 809 set_nav_entry_id(0);
809 } 810 }
810 811
811 void RenderFrameHostImpl::Create( 812 void RenderFrameHostImpl::Create(
812 const service_manager::Identity& remote_identity, 813 const service_manager::Identity& remote_identity,
813 media::mojom::InterfaceFactoryRequest request) { 814 media::mojom::InterfaceFactoryRequest request) {
814 auto registry = base::MakeUnique<service_manager::InterfaceRegistry>( 815 auto registry = base::MakeUnique<service_manager::InterfaceRegistry>(
815 service_manager::Identity(), service_manager::InterfaceProviderSpec()); 816 std::string());
816 #if defined(OS_ANDROID) && defined(ENABLE_MOJO_CDM) 817 #if defined(OS_ANDROID) && defined(ENABLE_MOJO_CDM)
817 registry->AddInterface( 818 registry->AddInterface(
818 base::Bind(&ProvisionFetcherImpl::Create, this)); 819 base::Bind(&ProvisionFetcherImpl::Create, this));
819 #endif 820 #endif
820 GetContentClient()->browser()->ExposeInterfacesToMediaService(registry.get(), 821 GetContentClient()->browser()->ExposeInterfacesToMediaService(registry.get(),
821 this); 822 this);
822 service_manager::mojom::InterfaceProviderPtr interfaces; 823 service_manager::mojom::InterfaceProviderPtr interfaces;
823 registry->Bind(GetProxy(&interfaces), 824 registry->Bind(GetProxy(&interfaces),
824 service_manager::Identity(), 825 service_manager::Identity(),
826 service_manager::InterfaceProviderSpec(),
827 service_manager::Identity(),
825 service_manager::InterfaceProviderSpec()); 828 service_manager::InterfaceProviderSpec());
826 media_registries_.push_back(std::move(registry)); 829 media_registries_.push_back(std::move(registry));
827 830
828 // TODO(slan): Use the BrowserContext Connector instead. See crbug.com/638950. 831 // TODO(slan): Use the BrowserContext Connector instead. See crbug.com/638950.
829 media::mojom::MediaServicePtr media_service; 832 media::mojom::MediaServicePtr media_service;
830 service_manager::Connector* connector = 833 service_manager::Connector* connector =
831 ServiceManagerConnection::GetForProcess()->GetConnector(); 834 ServiceManagerConnection::GetForProcess()->GetConnector();
832 connector->ConnectToInterface("service:media", &media_service); 835 connector->ConnectToInterface("service:media", &media_service);
833 media_service->CreateInterfaceFactory(std::move(request), 836 media_service->CreateInterfaceFactory(std::move(request),
834 std::move(interfaces)); 837 std::move(interfaces));
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 1532
1530 bool deleted = 1533 bool deleted =
1531 frame_tree_node_->render_manager()->DeleteFromPendingList(this); 1534 frame_tree_node_->render_manager()->DeleteFromPendingList(this);
1532 CHECK(deleted); 1535 CHECK(deleted);
1533 } 1536 }
1534 1537
1535 void RenderFrameHostImpl::DisableSwapOutTimerForTesting() { 1538 void RenderFrameHostImpl::DisableSwapOutTimerForTesting() {
1536 swapout_event_monitor_timeout_.reset(); 1539 swapout_event_monitor_timeout_.reset();
1537 } 1540 }
1538 1541
1542 void RenderFrameHostImpl::OnRendererConnect(
1543 const service_manager::ServiceInfo& local_info,
1544 const service_manager::ServiceInfo& remote_info) {
1545 if (remote_info.identity.name() != kRendererServiceName)
1546 return;
1547 browser_info_ = local_info;
1548 renderer_info_ = remote_info;
1549 }
1550
1539 void RenderFrameHostImpl::OnContextMenu(const ContextMenuParams& params) { 1551 void RenderFrameHostImpl::OnContextMenu(const ContextMenuParams& params) {
1540 // Validate the URLs in |params|. If the renderer can't request the URLs 1552 // Validate the URLs in |params|. If the renderer can't request the URLs
1541 // directly, don't show them in the context menu. 1553 // directly, don't show them in the context menu.
1542 ContextMenuParams validated_params(params); 1554 ContextMenuParams validated_params(params);
1543 RenderProcessHost* process = GetProcess(); 1555 RenderProcessHost* process = GetProcess();
1544 1556
1545 // We don't validate |unfiltered_link_url| so that this field can be used 1557 // We don't validate |unfiltered_link_url| so that this field can be used
1546 // when users want to copy the original link URL. 1558 // when users want to copy the original link URL.
1547 process->FilterURL(true, &validated_params.link_url); 1559 process->FilterURL(true, &validated_params.link_url);
1548 process->FilterURL(true, &validated_params.src_url); 1560 process->FilterURL(true, &validated_params.src_url);
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after
2580 // An error page is expected to commit, hence why is_loading_ is set to true. 2592 // An error page is expected to commit, hence why is_loading_ is set to true.
2581 is_loading_ = true; 2593 is_loading_ = true;
2582 frame_tree_node_->ResetNavigationRequest(true); 2594 frame_tree_node_->ResetNavigationRequest(true);
2583 } 2595 }
2584 2596
2585 void RenderFrameHostImpl::SetUpMojoIfNeeded() { 2597 void RenderFrameHostImpl::SetUpMojoIfNeeded() {
2586 if (interface_registry_.get()) 2598 if (interface_registry_.get())
2587 return; 2599 return;
2588 2600
2589 interface_registry_ = base::MakeUnique<service_manager::InterfaceRegistry>( 2601 interface_registry_ = base::MakeUnique<service_manager::InterfaceRegistry>(
2590 service_manager::Identity(), service_manager::InterfaceProviderSpec()); 2602 mojom::kNavigation_FrameSpec);
2603
2604 ServiceManagerConnection* service_manager_connection =
2605 BrowserContext::GetServiceManagerConnectionFor(
2606 GetProcess()->GetBrowserContext());
2607 // |service_manager_connection| may not be set in unit tests using
2608 // TestBrowserContext.
2609 if (service_manager_connection) {
2610 on_connect_handler_id_ = service_manager_connection->AddOnConnectHandler(
2611 base::Bind(&RenderFrameHostImpl::OnRendererConnect,
2612 weak_ptr_factory_.GetWeakPtr()));
2613 }
2614
2591 if (!GetProcess()->GetRemoteInterfaces()) 2615 if (!GetProcess()->GetRemoteInterfaces())
2592 return; 2616 return;
2593 2617
2594 RegisterMojoInterfaces(); 2618 RegisterMojoInterfaces();
2595 mojom::FrameFactoryPtr frame_factory; 2619 mojom::FrameFactoryPtr frame_factory;
2596 GetProcess()->GetRemoteInterfaces()->GetInterface(&frame_factory); 2620 GetProcess()->GetRemoteInterfaces()->GetInterface(&frame_factory);
2597 frame_factory->CreateFrame(routing_id_, GetProxy(&frame_), 2621 frame_factory->CreateFrame(routing_id_, GetProxy(&frame_),
2598 frame_host_binding_.CreateInterfacePtrAndBind()); 2622 frame_host_binding_.CreateInterfacePtrAndBind());
2599 2623
2600 service_manager::mojom::InterfaceProviderPtr remote_interfaces; 2624 service_manager::mojom::InterfaceProviderPtr remote_interfaces;
2601 service_manager::mojom::InterfaceProviderRequest remote_interfaces_request = 2625 service_manager::mojom::InterfaceProviderRequest remote_interfaces_request =
2602 GetProxy(&remote_interfaces); 2626 GetProxy(&remote_interfaces);
2603 remote_interfaces_.reset(new service_manager::InterfaceProvider); 2627 remote_interfaces_.reset(new service_manager::InterfaceProvider);
2604 remote_interfaces_->Bind(std::move(remote_interfaces)); 2628 remote_interfaces_->Bind(std::move(remote_interfaces));
2605 frame_->GetInterfaceProvider(std::move(remote_interfaces_request)); 2629 frame_->GetInterfaceProvider(std::move(remote_interfaces_request));
2606 } 2630 }
2607 2631
2608 void RenderFrameHostImpl::InvalidateMojoConnection() { 2632 void RenderFrameHostImpl::InvalidateMojoConnection() {
2609 interface_registry_.reset(); 2633 interface_registry_.reset();
2634
2635 ServiceManagerConnection* service_manager_connection =
2636 BrowserContext::GetServiceManagerConnectionFor(
2637 GetProcess()->GetBrowserContext());
2638 // |service_manager_connection| may be null in tests using TestBrowserContext.
2639 if (service_manager_connection) {
2640 service_manager_connection->RemoveOnConnectHandler(on_connect_handler_id_);
2641 on_connect_handler_id_ = 0;
2642 }
2643
2610 frame_.reset(); 2644 frame_.reset();
2611 frame_host_binding_.Close(); 2645 frame_host_binding_.Close();
2612 2646
2613 // Disconnect with ImageDownloader Mojo service in RenderFrame. 2647 // Disconnect with ImageDownloader Mojo service in RenderFrame.
2614 mojo_image_downloader_.reset(); 2648 mojo_image_downloader_.reset();
2615 } 2649 }
2616 2650
2617 bool RenderFrameHostImpl::IsFocused() { 2651 bool RenderFrameHostImpl::IsFocused() {
2618 return GetRenderWidgetHost()->is_focused() && 2652 return GetRenderWidgetHost()->is_focused() &&
2619 frame_tree_->GetFocusedFrame() && 2653 frame_tree_->GetFocusedFrame() &&
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
2868 file_system_context->CrackURL(file.file_system_url) 2902 file_system_context->CrackURL(file.file_system_url)
2869 .mount_filesystem_id()); 2903 .mount_filesystem_id());
2870 } 2904 }
2871 } 2905 }
2872 2906
2873 Send(new FrameMsg_RunFileChooserResponse(routing_id_, files)); 2907 Send(new FrameMsg_RunFileChooserResponse(routing_id_, files));
2874 } 2908 }
2875 2909
2876 void RenderFrameHostImpl::GetInterfaceProvider( 2910 void RenderFrameHostImpl::GetInterfaceProvider(
2877 service_manager::mojom::InterfaceProviderRequest interfaces) { 2911 service_manager::mojom::InterfaceProviderRequest interfaces) {
2912 service_manager::InterfaceProviderSpec browser_spec, renderer_spec;
2913 // TODO(beng): CHECK these return true.
2914 service_manager::GetInterfaceProviderSpec(
2915 mojom::kNavigation_FrameSpec, browser_info_.interface_provider_specs,
2916 &browser_spec);
2917 service_manager::GetInterfaceProviderSpec(
2918 mojom::kNavigation_FrameSpec, renderer_info_.interface_provider_specs,
2919 &renderer_spec);
2878 interface_registry_->Bind(std::move(interfaces), 2920 interface_registry_->Bind(std::move(interfaces),
2879 service_manager::Identity(), 2921 browser_info_.identity, browser_spec,
2880 service_manager::InterfaceProviderSpec()); 2922 renderer_info_.identity, renderer_spec);
2881 } 2923 }
2882 2924
2883 #if defined(USE_EXTERNAL_POPUP_MENU) 2925 #if defined(USE_EXTERNAL_POPUP_MENU)
2884 #if defined(OS_MACOSX) 2926 #if defined(OS_MACOSX)
2885 2927
2886 void RenderFrameHostImpl::DidSelectPopupMenuItem(int selected_index) { 2928 void RenderFrameHostImpl::DidSelectPopupMenuItem(int selected_index) {
2887 Send(new FrameMsg_SelectPopupMenuItem(routing_id_, selected_index)); 2929 Send(new FrameMsg_SelectPopupMenuItem(routing_id_, selected_index));
2888 } 2930 }
2889 2931
2890 void RenderFrameHostImpl::DidCancelPopupMenu() { 2932 void RenderFrameHostImpl::DidCancelPopupMenu() {
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
3151 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind( 3193 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind(
3152 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this))); 3194 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this)));
3153 return web_bluetooth_service_.get(); 3195 return web_bluetooth_service_.get();
3154 } 3196 }
3155 3197
3156 void RenderFrameHostImpl::DeleteWebBluetoothService() { 3198 void RenderFrameHostImpl::DeleteWebBluetoothService() {
3157 web_bluetooth_service_.reset(); 3199 web_bluetooth_service_.reset();
3158 } 3200 }
3159 3201
3160 } // namespace content 3202 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698