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

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 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 ResetLoadingState(); 805 ResetLoadingState();
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 #if defined(OS_ANDROID) && defined(ENABLE_MOJO_CDM) 816 #if defined(OS_ANDROID) && defined(ENABLE_MOJO_CDM)
817 registry->AddInterface( 817 registry->AddInterface(
818 base::Bind(&ProvisionFetcherImpl::Create, this)); 818 base::Bind(&ProvisionFetcherImpl::Create, this));
819 #endif 819 #endif
820 GetContentClient()->browser()->ExposeInterfacesToMediaService(registry.get(), 820 GetContentClient()->browser()->ExposeInterfacesToMediaService(registry.get(),
821 this); 821 this);
822 service_manager::mojom::InterfaceProviderPtr interfaces; 822 service_manager::mojom::InterfaceProviderPtr interfaces;
823 registry->Bind(GetProxy(&interfaces), 823 registry->Bind(GetProxy(&interfaces),
824 service_manager::Identity(), 824 service_manager::Identity(),
825 service_manager::InterfaceProviderSpec(),
826 service_manager::Identity(),
825 service_manager::InterfaceProviderSpec()); 827 service_manager::InterfaceProviderSpec());
826 media_registries_.push_back(std::move(registry)); 828 media_registries_.push_back(std::move(registry));
827 829
828 // TODO(slan): Use the BrowserContext Connector instead. See crbug.com/638950. 830 // TODO(slan): Use the BrowserContext Connector instead. See crbug.com/638950.
829 media::mojom::MediaServicePtr media_service; 831 media::mojom::MediaServicePtr media_service;
830 service_manager::Connector* connector = 832 service_manager::Connector* connector =
831 ServiceManagerConnection::GetForProcess()->GetConnector(); 833 ServiceManagerConnection::GetForProcess()->GetConnector();
832 connector->ConnectToInterface("service:media", &media_service); 834 connector->ConnectToInterface("service:media", &media_service);
833 media_service->CreateInterfaceFactory(std::move(request), 835 media_service->CreateInterfaceFactory(std::move(request),
834 std::move(interfaces)); 836 std::move(interfaces));
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 1527
1526 bool deleted = 1528 bool deleted =
1527 frame_tree_node_->render_manager()->DeleteFromPendingList(this); 1529 frame_tree_node_->render_manager()->DeleteFromPendingList(this);
1528 CHECK(deleted); 1530 CHECK(deleted);
1529 } 1531 }
1530 1532
1531 void RenderFrameHostImpl::DisableSwapOutTimerForTesting() { 1533 void RenderFrameHostImpl::DisableSwapOutTimerForTesting() {
1532 swapout_event_monitor_timeout_.reset(); 1534 swapout_event_monitor_timeout_.reset();
1533 } 1535 }
1534 1536
1537 void RenderFrameHostImpl::OnRendererConnect(
1538 const service_manager::ServiceInfo& local_info,
1539 const service_manager::ServiceInfo& remote_info) {
1540 if (remote_info.identity.name() != kRendererServiceName)
1541 return;
1542 local_info_ = local_info;
1543 remote_info_ = remote_info;
1544 }
1545
1535 void RenderFrameHostImpl::OnContextMenu(const ContextMenuParams& params) { 1546 void RenderFrameHostImpl::OnContextMenu(const ContextMenuParams& params) {
1536 // Validate the URLs in |params|. If the renderer can't request the URLs 1547 // Validate the URLs in |params|. If the renderer can't request the URLs
1537 // directly, don't show them in the context menu. 1548 // directly, don't show them in the context menu.
1538 ContextMenuParams validated_params(params); 1549 ContextMenuParams validated_params(params);
1539 RenderProcessHost* process = GetProcess(); 1550 RenderProcessHost* process = GetProcess();
1540 1551
1541 // We don't validate |unfiltered_link_url| so that this field can be used 1552 // We don't validate |unfiltered_link_url| so that this field can be used
1542 // when users want to copy the original link URL. 1553 // when users want to copy the original link URL.
1543 process->FilterURL(true, &validated_params.link_url); 1554 process->FilterURL(true, &validated_params.link_url);
1544 process->FilterURL(true, &validated_params.src_url); 1555 process->FilterURL(true, &validated_params.src_url);
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
2575 2586
2576 // An error page is expected to commit, hence why is_loading_ is set to true. 2587 // An error page is expected to commit, hence why is_loading_ is set to true.
2577 is_loading_ = true; 2588 is_loading_ = true;
2578 frame_tree_node_->ResetNavigationRequest(true); 2589 frame_tree_node_->ResetNavigationRequest(true);
2579 } 2590 }
2580 2591
2581 void RenderFrameHostImpl::SetUpMojoIfNeeded() { 2592 void RenderFrameHostImpl::SetUpMojoIfNeeded() {
2582 if (interface_registry_.get()) 2593 if (interface_registry_.get())
2583 return; 2594 return;
2584 2595
2585 interface_registry_ = base::MakeUnique<service_manager::InterfaceRegistry>( 2596 interface_registry_ = base::MakeUnique<service_manager::InterfaceRegistry>();
2586 service_manager::Identity(), service_manager::InterfaceProviderSpec()); 2597
2598 ServiceManagerConnection* service_manager_connection =
2599 BrowserContext::GetServiceManagerConnectionFor(
2600 GetProcess()->GetBrowserContext());
2601 on_connect_handler_id_ = service_manager_connection->AddOnConnectHandler(
2602 base::Bind(&RenderFrameHostImpl::OnRendererConnect,
2603 weak_ptr_factory_.GetWeakPtr()));
2604
2587 if (!GetProcess()->GetRemoteInterfaces()) 2605 if (!GetProcess()->GetRemoteInterfaces())
2588 return; 2606 return;
2589 2607
2590 RegisterMojoInterfaces(); 2608 RegisterMojoInterfaces();
2591 mojom::FrameFactoryPtr frame_factory; 2609 mojom::FrameFactoryPtr frame_factory;
2592 GetProcess()->GetRemoteInterfaces()->GetInterface(&frame_factory); 2610 GetProcess()->GetRemoteInterfaces()->GetInterface(&frame_factory);
2593 frame_factory->CreateFrame(routing_id_, GetProxy(&frame_), 2611 frame_factory->CreateFrame(routing_id_, GetProxy(&frame_),
2594 frame_host_binding_.CreateInterfacePtrAndBind()); 2612 frame_host_binding_.CreateInterfacePtrAndBind());
2595 2613
2596 service_manager::mojom::InterfaceProviderPtr remote_interfaces; 2614 service_manager::mojom::InterfaceProviderPtr remote_interfaces;
2597 service_manager::mojom::InterfaceProviderRequest remote_interfaces_request = 2615 service_manager::mojom::InterfaceProviderRequest remote_interfaces_request =
2598 GetProxy(&remote_interfaces); 2616 GetProxy(&remote_interfaces);
2599 remote_interfaces_.reset(new service_manager::InterfaceProvider); 2617 remote_interfaces_.reset(new service_manager::InterfaceProvider);
2600 remote_interfaces_->Bind(std::move(remote_interfaces)); 2618 remote_interfaces_->Bind(std::move(remote_interfaces));
2601 frame_->GetInterfaceProvider(std::move(remote_interfaces_request)); 2619 frame_->GetInterfaceProvider(std::move(remote_interfaces_request));
2602 } 2620 }
2603 2621
2604 void RenderFrameHostImpl::InvalidateMojoConnection() { 2622 void RenderFrameHostImpl::InvalidateMojoConnection() {
2605 interface_registry_.reset(); 2623 interface_registry_.reset();
2624
2625 ServiceManagerConnection* service_manager_connection =
2626 BrowserContext::GetServiceManagerConnectionFor(
2627 GetProcess()->GetBrowserContext());
2628 service_manager_connection->RemoveOnConnectHandler(on_connect_handler_id_);
2629 on_connect_handler_id_ = 0;
2630
2606 frame_.reset(); 2631 frame_.reset();
2607 frame_host_binding_.Close(); 2632 frame_host_binding_.Close();
2608 2633
2609 // Disconnect with ImageDownloader Mojo service in RenderFrame. 2634 // Disconnect with ImageDownloader Mojo service in RenderFrame.
2610 mojo_image_downloader_.reset(); 2635 mojo_image_downloader_.reset();
2611 } 2636 }
2612 2637
2613 bool RenderFrameHostImpl::IsFocused() { 2638 bool RenderFrameHostImpl::IsFocused() {
2614 return GetRenderWidgetHost()->is_focused() && 2639 return GetRenderWidgetHost()->is_focused() &&
2615 frame_tree_->GetFocusedFrame() && 2640 frame_tree_->GetFocusedFrame() &&
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
2860 file_system_context->CrackURL(file.file_system_url) 2885 file_system_context->CrackURL(file.file_system_url)
2861 .mount_filesystem_id()); 2886 .mount_filesystem_id());
2862 } 2887 }
2863 } 2888 }
2864 2889
2865 Send(new FrameMsg_RunFileChooserResponse(routing_id_, files)); 2890 Send(new FrameMsg_RunFileChooserResponse(routing_id_, files));
2866 } 2891 }
2867 2892
2868 void RenderFrameHostImpl::GetInterfaceProvider( 2893 void RenderFrameHostImpl::GetInterfaceProvider(
2869 service_manager::mojom::InterfaceProviderRequest interfaces) { 2894 service_manager::mojom::InterfaceProviderRequest interfaces) {
2895 service_manager::InterfaceProviderSpec local_spec, remote_spec;
2896 // TODO(beng): CHECK these return true.
2897 service_manager::GetInterfaceProviderSpec(
2898 mojom::kNavigation_FrameSpec, local_info_.interface_provider_specs,
2899 &local_spec);
2900 service_manager::GetInterfaceProviderSpec(
2901 mojom::kNavigation_FrameSpec, remote_info_.interface_provider_specs,
2902 &remote_spec);
2870 interface_registry_->Bind(std::move(interfaces), 2903 interface_registry_->Bind(std::move(interfaces),
2871 service_manager::Identity(), 2904 local_info_.identity, local_spec,
2872 service_manager::InterfaceProviderSpec()); 2905 remote_info_.identity, remote_spec);
2873 } 2906 }
2874 2907
2875 #if defined(USE_EXTERNAL_POPUP_MENU) 2908 #if defined(USE_EXTERNAL_POPUP_MENU)
2876 #if defined(OS_MACOSX) 2909 #if defined(OS_MACOSX)
2877 2910
2878 void RenderFrameHostImpl::DidSelectPopupMenuItem(int selected_index) { 2911 void RenderFrameHostImpl::DidSelectPopupMenuItem(int selected_index) {
2879 Send(new FrameMsg_SelectPopupMenuItem(routing_id_, selected_index)); 2912 Send(new FrameMsg_SelectPopupMenuItem(routing_id_, selected_index));
2880 } 2913 }
2881 2914
2882 void RenderFrameHostImpl::DidCancelPopupMenu() { 2915 void RenderFrameHostImpl::DidCancelPopupMenu() {
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
3143 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind( 3176 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind(
3144 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this))); 3177 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this)));
3145 return web_bluetooth_service_.get(); 3178 return web_bluetooth_service_.get();
3146 } 3179 }
3147 3180
3148 void RenderFrameHostImpl::DeleteWebBluetoothService() { 3181 void RenderFrameHostImpl::DeleteWebBluetoothService() {
3149 web_bluetooth_service_.reset(); 3182 web_bluetooth_service_.reset();
3150 } 3183 }
3151 3184
3152 } // namespace content 3185 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698