| 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/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" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 #include "device/wake_lock/public/interfaces/wake_lock_context.mojom.h" | 107 #include "device/wake_lock/public/interfaces/wake_lock_context.mojom.h" |
| 108 #include "device/wake_lock/public/interfaces/wake_lock_service.mojom.h" | 108 #include "device/wake_lock/public/interfaces/wake_lock_service.mojom.h" |
| 109 #include "media/base/media_switches.h" | 109 #include "media/base/media_switches.h" |
| 110 #include "media/media_features.h" | 110 #include "media/media_features.h" |
| 111 #include "media/mojo/interfaces/media_service.mojom.h" | 111 #include "media/mojo/interfaces/media_service.mojom.h" |
| 112 #include "media/mojo/interfaces/remoting.mojom.h" | 112 #include "media/mojo/interfaces/remoting.mojom.h" |
| 113 #include "media/mojo/services/media_interface_provider.h" | 113 #include "media/mojo/services/media_interface_provider.h" |
| 114 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" | 114 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" |
| 115 #include "mojo/public/cpp/bindings/strong_binding.h" | 115 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 116 #include "mojo/public/cpp/system/data_pipe.h" | 116 #include "mojo/public/cpp/system/data_pipe.h" |
| 117 #include "services/resource_coordinator/public/cpp/resource_coordinator_interfac
e.h" |
| 117 #include "services/service_manager/public/cpp/connector.h" | 118 #include "services/service_manager/public/cpp/connector.h" |
| 118 #include "services/service_manager/public/cpp/interface_provider.h" | 119 #include "services/service_manager/public/cpp/interface_provider.h" |
| 119 #include "third_party/WebKit/public/platform/WebFeaturePolicy.h" | 120 #include "third_party/WebKit/public/platform/WebFeaturePolicy.h" |
| 120 #include "ui/accessibility/ax_tree.h" | 121 #include "ui/accessibility/ax_tree.h" |
| 121 #include "ui/accessibility/ax_tree_id_registry.h" | 122 #include "ui/accessibility/ax_tree_id_registry.h" |
| 122 #include "ui/accessibility/ax_tree_update.h" | 123 #include "ui/accessibility/ax_tree_update.h" |
| 123 #include "ui/gfx/geometry/quad_f.h" | 124 #include "ui/gfx/geometry/quad_f.h" |
| 124 #include "url/gurl.h" | 125 #include "url/gurl.h" |
| 125 #include "url/origin.h" | 126 #include "url/origin.h" |
| 126 | 127 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 } | 260 } |
| 260 } | 261 } |
| 261 | 262 |
| 262 const int process_id_; | 263 const int process_id_; |
| 263 const int routing_id_; | 264 const int routing_id_; |
| 264 | 265 |
| 265 DISALLOW_COPY_AND_ASSIGN(RemoterFactoryImpl); | 266 DISALLOW_COPY_AND_ASSIGN(RemoterFactoryImpl); |
| 266 }; | 267 }; |
| 267 #endif // BUILDFLAG(ENABLE_MEDIA_REMOTING) | 268 #endif // BUILDFLAG(ENABLE_MEDIA_REMOTING) |
| 268 | 269 |
| 270 void CreateResourceCoordinatorFrameInterface( |
| 271 RenderFrameHostImpl* render_frame_host, |
| 272 const service_manager::BindSourceInfo& source_info, |
| 273 resource_coordinator::mojom::CoordinationUnitRequest request) { |
| 274 render_frame_host->GetFrameResourceCoordinator()->service()->AddBinding( |
| 275 std::move(request)); |
| 276 } |
| 277 |
| 269 template <typename Interface> | 278 template <typename Interface> |
| 270 void IgnoreInterfaceRequest(const service_manager::BindSourceInfo& source_info, | 279 void IgnoreInterfaceRequest(const service_manager::BindSourceInfo& source_info, |
| 271 mojo::InterfaceRequest<Interface> request) { | 280 mojo::InterfaceRequest<Interface> request) { |
| 272 // Intentionally ignore the interface request. | 281 // Intentionally ignore the interface request. |
| 273 } | 282 } |
| 274 | 283 |
| 275 // The following functions simplify code paths where the UI thread notifies the | 284 // The following functions simplify code paths where the UI thread notifies the |
| 276 // ResourceDispatcherHostImpl of information pertaining to loading behavior of | 285 // ResourceDispatcherHostImpl of information pertaining to loading behavior of |
| 277 // frame hosts. | 286 // frame hosts. |
| 278 void NotifyRouteChangesOnIO( | 287 void NotifyRouteChangesOnIO( |
| (...skipping 2551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2830 GetInterfaceRegistry()->AddInterface<device::mojom::VRService>( | 2839 GetInterfaceRegistry()->AddInterface<device::mojom::VRService>( |
| 2831 base::Bind(&IgnoreInterfaceRequest<device::mojom::VRService>)); | 2840 base::Bind(&IgnoreInterfaceRequest<device::mojom::VRService>)); |
| 2832 #endif | 2841 #endif |
| 2833 | 2842 |
| 2834 if (RendererAudioOutputStreamFactoryContextImpl::UseMojoFactories()) { | 2843 if (RendererAudioOutputStreamFactoryContextImpl::UseMojoFactories()) { |
| 2835 GetInterfaceRegistry()->AddInterface(base::BindRepeating( | 2844 GetInterfaceRegistry()->AddInterface(base::BindRepeating( |
| 2836 &RenderFrameHostImpl::CreateAudioOutputStreamFactory, | 2845 &RenderFrameHostImpl::CreateAudioOutputStreamFactory, |
| 2837 base::Unretained(this))); | 2846 base::Unretained(this))); |
| 2838 } | 2847 } |
| 2839 | 2848 |
| 2849 GetInterfaceRegistry()->AddInterface(base::Bind( |
| 2850 &CreateResourceCoordinatorFrameInterface, base::Unretained(this))); |
| 2851 |
| 2840 #if BUILDFLAG(ENABLE_WEBRTC) | 2852 #if BUILDFLAG(ENABLE_WEBRTC) |
| 2841 // BrowserMainLoop::GetInstance() may be null on unit tests. | 2853 // BrowserMainLoop::GetInstance() may be null on unit tests. |
| 2842 if (BrowserMainLoop::GetInstance()) { | 2854 if (BrowserMainLoop::GetInstance()) { |
| 2843 // BrowserMainLoop, which owns MediaStreamManager, is alive for the lifetime | 2855 // BrowserMainLoop, which owns MediaStreamManager, is alive for the lifetime |
| 2844 // of Mojo communication (see BrowserMainLoop::ShutdownThreadsAndCleanUp(), | 2856 // of Mojo communication (see BrowserMainLoop::ShutdownThreadsAndCleanUp(), |
| 2845 // which shuts down Mojo). Hence, passing that MediaStreamManager instance | 2857 // which shuts down Mojo). Hence, passing that MediaStreamManager instance |
| 2846 // as a raw pointer here is safe. | 2858 // as a raw pointer here is safe. |
| 2847 MediaStreamManager* media_stream_manager = | 2859 MediaStreamManager* media_stream_manager = |
| 2848 BrowserMainLoop::GetInstance()->media_stream_manager(); | 2860 BrowserMainLoop::GetInstance()->media_stream_manager(); |
| 2849 GetInterfaceRegistry()->AddInterface( | 2861 GetInterfaceRegistry()->AddInterface( |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3254 | 3266 |
| 3255 void RenderFrameHostImpl::InvalidateMojoConnection() { | 3267 void RenderFrameHostImpl::InvalidateMojoConnection() { |
| 3256 interface_registry_.reset(); | 3268 interface_registry_.reset(); |
| 3257 | 3269 |
| 3258 frame_.reset(); | 3270 frame_.reset(); |
| 3259 frame_host_interface_broker_binding_.Close(); | 3271 frame_host_interface_broker_binding_.Close(); |
| 3260 frame_bindings_control_.reset(); | 3272 frame_bindings_control_.reset(); |
| 3261 | 3273 |
| 3262 // Disconnect with ImageDownloader Mojo service in RenderFrame. | 3274 // Disconnect with ImageDownloader Mojo service in RenderFrame. |
| 3263 mojo_image_downloader_.reset(); | 3275 mojo_image_downloader_.reset(); |
| 3276 |
| 3277 frame_resource_coordinator_.reset(); |
| 3264 } | 3278 } |
| 3265 | 3279 |
| 3266 bool RenderFrameHostImpl::IsFocused() { | 3280 bool RenderFrameHostImpl::IsFocused() { |
| 3267 return GetRenderWidgetHost()->is_focused() && | 3281 return GetRenderWidgetHost()->is_focused() && |
| 3268 frame_tree_->GetFocusedFrame() && | 3282 frame_tree_->GetFocusedFrame() && |
| 3269 (frame_tree_->GetFocusedFrame() == frame_tree_node() || | 3283 (frame_tree_->GetFocusedFrame() == frame_tree_node() || |
| 3270 frame_tree_->GetFocusedFrame()->IsDescendantOf(frame_tree_node())); | 3284 frame_tree_->GetFocusedFrame()->IsDescendantOf(frame_tree_node())); |
| 3271 } | 3285 } |
| 3272 | 3286 |
| 3273 bool RenderFrameHostImpl::UpdatePendingWebUI(const GURL& dest_url, | 3287 bool RenderFrameHostImpl::UpdatePendingWebUI(const GURL& dest_url, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3360 web_ui_.reset(); | 3374 web_ui_.reset(); |
| 3361 } | 3375 } |
| 3362 | 3376 |
| 3363 const content::mojom::ImageDownloaderPtr& | 3377 const content::mojom::ImageDownloaderPtr& |
| 3364 RenderFrameHostImpl::GetMojoImageDownloader() { | 3378 RenderFrameHostImpl::GetMojoImageDownloader() { |
| 3365 if (!mojo_image_downloader_.get() && GetRemoteInterfaces()) | 3379 if (!mojo_image_downloader_.get() && GetRemoteInterfaces()) |
| 3366 GetRemoteInterfaces()->GetInterface(&mojo_image_downloader_); | 3380 GetRemoteInterfaces()->GetInterface(&mojo_image_downloader_); |
| 3367 return mojo_image_downloader_; | 3381 return mojo_image_downloader_; |
| 3368 } | 3382 } |
| 3369 | 3383 |
| 3384 resource_coordinator::ResourceCoordinatorInterface* |
| 3385 RenderFrameHostImpl::GetFrameResourceCoordinator() { |
| 3386 if (!frame_resource_coordinator_) { |
| 3387 frame_resource_coordinator_ = |
| 3388 base::MakeUnique<resource_coordinator::ResourceCoordinatorInterface>( |
| 3389 ServiceManagerConnection::GetForProcess()->GetConnector(), |
| 3390 resource_coordinator::CoordinationUnitType::kFrame); |
| 3391 } |
| 3392 return frame_resource_coordinator_.get(); |
| 3393 } |
| 3394 |
| 3370 void RenderFrameHostImpl::ResetLoadingState() { | 3395 void RenderFrameHostImpl::ResetLoadingState() { |
| 3371 if (is_loading()) { | 3396 if (is_loading()) { |
| 3372 // When pending deletion, just set the loading state to not loading. | 3397 // When pending deletion, just set the loading state to not loading. |
| 3373 // Otherwise, OnDidStopLoading will take care of that, as well as sending | 3398 // Otherwise, OnDidStopLoading will take care of that, as well as sending |
| 3374 // notification to the FrameTreeNode about the change in loading state. | 3399 // notification to the FrameTreeNode about the change in loading state. |
| 3375 if (!is_active()) | 3400 if (!is_active()) |
| 3376 is_loading_ = false; | 3401 is_loading_ = false; |
| 3377 else | 3402 else |
| 3378 OnDidStopLoading(); | 3403 OnDidStopLoading(); |
| 3379 } | 3404 } |
| (...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4083 } | 4108 } |
| 4084 | 4109 |
| 4085 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame( | 4110 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame( |
| 4086 const std::string& interface_name, | 4111 const std::string& interface_name, |
| 4087 mojo::ScopedMessagePipeHandle pipe) { | 4112 mojo::ScopedMessagePipeHandle pipe) { |
| 4088 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe)); | 4113 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe)); |
| 4089 } | 4114 } |
| 4090 #endif | 4115 #endif |
| 4091 | 4116 |
| 4092 } // namespace content | 4117 } // namespace content |
| OLD | NEW |