Chromium Code Reviews| 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()->Duplicate( | |
|
nasko
2017/06/02 23:29:16
This code looks strange as it is written. Creating
oystein (OOO til 10th of July)
2017/06/05 20:02:39
Renamed to AddBinding and added a comment to bette
| |
| 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 2544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2823 routing_id_)); | 2832 routing_id_)); |
| 2824 | 2833 |
| 2825 #if BUILDFLAG(ENABLE_VR) | 2834 #if BUILDFLAG(ENABLE_VR) |
| 2826 GetInterfaceRegistry()->AddInterface<device::mojom::VRService>( | 2835 GetInterfaceRegistry()->AddInterface<device::mojom::VRService>( |
| 2827 base::Bind(&device::VRServiceImpl::Create)); | 2836 base::Bind(&device::VRServiceImpl::Create)); |
| 2828 #else | 2837 #else |
| 2829 GetInterfaceRegistry()->AddInterface<device::mojom::VRService>( | 2838 GetInterfaceRegistry()->AddInterface<device::mojom::VRService>( |
| 2830 base::Bind(&IgnoreInterfaceRequest<device::mojom::VRService>)); | 2839 base::Bind(&IgnoreInterfaceRequest<device::mojom::VRService>)); |
| 2831 #endif | 2840 #endif |
| 2832 | 2841 |
| 2842 GetInterfaceRegistry()->AddInterface(base::Bind( | |
| 2843 &CreateResourceCoordinatorFrameInterface, base::Unretained(this))); | |
| 2844 | |
| 2833 #if BUILDFLAG(ENABLE_WEBRTC) | 2845 #if BUILDFLAG(ENABLE_WEBRTC) |
| 2834 // BrowserMainLoop::GetInstance() may be null on unit tests. | 2846 // BrowserMainLoop::GetInstance() may be null on unit tests. |
| 2835 if (BrowserMainLoop::GetInstance()) { | 2847 if (BrowserMainLoop::GetInstance()) { |
| 2836 // BrowserMainLoop, which owns MediaStreamManager, is alive for the lifetime | 2848 // BrowserMainLoop, which owns MediaStreamManager, is alive for the lifetime |
| 2837 // of Mojo communication (see BrowserMainLoop::ShutdownThreadsAndCleanUp(), | 2849 // of Mojo communication (see BrowserMainLoop::ShutdownThreadsAndCleanUp(), |
| 2838 // which shuts down Mojo). Hence, passing that MediaStreamManager instance | 2850 // which shuts down Mojo). Hence, passing that MediaStreamManager instance |
| 2839 // as a raw pointer here is safe. | 2851 // as a raw pointer here is safe. |
| 2840 MediaStreamManager* media_stream_manager = | 2852 MediaStreamManager* media_stream_manager = |
| 2841 BrowserMainLoop::GetInstance()->media_stream_manager(); | 2853 BrowserMainLoop::GetInstance()->media_stream_manager(); |
| 2842 GetInterfaceRegistry()->AddInterface( | 2854 GetInterfaceRegistry()->AddInterface( |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3247 | 3259 |
| 3248 void RenderFrameHostImpl::InvalidateMojoConnection() { | 3260 void RenderFrameHostImpl::InvalidateMojoConnection() { |
| 3249 interface_registry_.reset(); | 3261 interface_registry_.reset(); |
| 3250 | 3262 |
| 3251 frame_.reset(); | 3263 frame_.reset(); |
| 3252 frame_host_interface_broker_binding_.Close(); | 3264 frame_host_interface_broker_binding_.Close(); |
| 3253 frame_bindings_control_.reset(); | 3265 frame_bindings_control_.reset(); |
| 3254 | 3266 |
| 3255 // Disconnect with ImageDownloader Mojo service in RenderFrame. | 3267 // Disconnect with ImageDownloader Mojo service in RenderFrame. |
| 3256 mojo_image_downloader_.reset(); | 3268 mojo_image_downloader_.reset(); |
| 3269 | |
| 3270 frame_resource_coordinator_.reset(); | |
| 3257 } | 3271 } |
| 3258 | 3272 |
| 3259 bool RenderFrameHostImpl::IsFocused() { | 3273 bool RenderFrameHostImpl::IsFocused() { |
| 3260 return GetRenderWidgetHost()->is_focused() && | 3274 return GetRenderWidgetHost()->is_focused() && |
| 3261 frame_tree_->GetFocusedFrame() && | 3275 frame_tree_->GetFocusedFrame() && |
| 3262 (frame_tree_->GetFocusedFrame() == frame_tree_node() || | 3276 (frame_tree_->GetFocusedFrame() == frame_tree_node() || |
| 3263 frame_tree_->GetFocusedFrame()->IsDescendantOf(frame_tree_node())); | 3277 frame_tree_->GetFocusedFrame()->IsDescendantOf(frame_tree_node())); |
| 3264 } | 3278 } |
| 3265 | 3279 |
| 3266 bool RenderFrameHostImpl::UpdatePendingWebUI(const GURL& dest_url, | 3280 bool RenderFrameHostImpl::UpdatePendingWebUI(const GURL& dest_url, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3353 web_ui_.reset(); | 3367 web_ui_.reset(); |
| 3354 } | 3368 } |
| 3355 | 3369 |
| 3356 const content::mojom::ImageDownloaderPtr& | 3370 const content::mojom::ImageDownloaderPtr& |
| 3357 RenderFrameHostImpl::GetMojoImageDownloader() { | 3371 RenderFrameHostImpl::GetMojoImageDownloader() { |
| 3358 if (!mojo_image_downloader_.get() && GetRemoteInterfaces()) | 3372 if (!mojo_image_downloader_.get() && GetRemoteInterfaces()) |
| 3359 GetRemoteInterfaces()->GetInterface(&mojo_image_downloader_); | 3373 GetRemoteInterfaces()->GetInterface(&mojo_image_downloader_); |
| 3360 return mojo_image_downloader_; | 3374 return mojo_image_downloader_; |
| 3361 } | 3375 } |
| 3362 | 3376 |
| 3377 resource_coordinator::ResourceCoordinatorInterface* | |
| 3378 RenderFrameHostImpl::GetFrameResourceCoordinator() { | |
| 3379 if (!frame_resource_coordinator_) { | |
| 3380 frame_resource_coordinator_ = | |
| 3381 base::MakeUnique<resource_coordinator::ResourceCoordinatorInterface>( | |
| 3382 ServiceManagerConnection::GetForProcess()->GetConnector(), | |
| 3383 resource_coordinator::CoordinationUnitType::kFrame); | |
| 3384 } | |
| 3385 return frame_resource_coordinator_.get(); | |
| 3386 } | |
| 3387 | |
| 3363 void RenderFrameHostImpl::ResetLoadingState() { | 3388 void RenderFrameHostImpl::ResetLoadingState() { |
| 3364 if (is_loading()) { | 3389 if (is_loading()) { |
| 3365 // When pending deletion, just set the loading state to not loading. | 3390 // When pending deletion, just set the loading state to not loading. |
| 3366 // Otherwise, OnDidStopLoading will take care of that, as well as sending | 3391 // Otherwise, OnDidStopLoading will take care of that, as well as sending |
| 3367 // notification to the FrameTreeNode about the change in loading state. | 3392 // notification to the FrameTreeNode about the change in loading state. |
| 3368 if (!is_active()) | 3393 if (!is_active()) |
| 3369 is_loading_ = false; | 3394 is_loading_ = false; |
| 3370 else | 3395 else |
| 3371 OnDidStopLoading(); | 3396 OnDidStopLoading(); |
| 3372 } | 3397 } |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4065 } | 4090 } |
| 4066 | 4091 |
| 4067 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame( | 4092 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame( |
| 4068 const std::string& interface_name, | 4093 const std::string& interface_name, |
| 4069 mojo::ScopedMessagePipeHandle pipe) { | 4094 mojo::ScopedMessagePipeHandle pipe) { |
| 4070 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe)); | 4095 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe)); |
| 4071 } | 4096 } |
| 4072 #endif | 4097 #endif |
| 4073 | 4098 |
| 4074 } // namespace content | 4099 } // namespace content |
| OLD | NEW |