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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 case blink::kWebTextDirectionLeftToRight: | 170 case blink::kWebTextDirectionLeftToRight: |
171 return base::i18n::LEFT_TO_RIGHT; | 171 return base::i18n::LEFT_TO_RIGHT; |
172 case blink::kWebTextDirectionRightToLeft: | 172 case blink::kWebTextDirectionRightToLeft: |
173 return base::i18n::RIGHT_TO_LEFT; | 173 return base::i18n::RIGHT_TO_LEFT; |
174 default: | 174 default: |
175 NOTREACHED(); | 175 NOTREACHED(); |
176 return base::i18n::UNKNOWN_DIRECTION; | 176 return base::i18n::UNKNOWN_DIRECTION; |
177 } | 177 } |
178 } | 178 } |
179 | 179 |
| 180 // Wrap the virtual function ConnectToBlinkWakeLock(). |
| 181 void ConnectToBlinkWakeLockWrapper( |
| 182 RenderFrameHostDelegate* delegate, |
| 183 device::mojom::WakeLockServiceRequest request) { |
| 184 if (delegate) { |
| 185 delegate->ConnectToBlinkWakeLock(std::move(request)); |
| 186 } |
| 187 return; |
| 188 } |
| 189 |
180 // Ensure that we reset nav_entry_id_ in OnDidCommitProvisionalLoad if any of | 190 // Ensure that we reset nav_entry_id_ in OnDidCommitProvisionalLoad if any of |
181 // the validations fail and lead to an early return. Call disable() once we | 191 // the validations fail and lead to an early return. Call disable() once we |
182 // know the commit will be successful. Resetting nav_entry_id_ avoids acting on | 192 // know the commit will be successful. Resetting nav_entry_id_ avoids acting on |
183 // any UpdateState or UpdateTitle messages after an ignored commit. | 193 // any UpdateState or UpdateTitle messages after an ignored commit. |
184 class ScopedCommitStateResetter { | 194 class ScopedCommitStateResetter { |
185 public: | 195 public: |
186 explicit ScopedCommitStateResetter(RenderFrameHostImpl* render_frame_host) | 196 explicit ScopedCommitStateResetter(RenderFrameHostImpl* render_frame_host) |
187 : render_frame_host_(render_frame_host), disabled_(false) {} | 197 : render_frame_host_(render_frame_host), disabled_(false) {} |
188 | 198 |
189 ~ScopedCommitStateResetter() { | 199 ~ScopedCommitStateResetter() { |
(...skipping 2385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2575 // this object and destruction of any GeolocationServicesImpls created via | 2585 // this object and destruction of any GeolocationServicesImpls created via |
2576 // the below service registry, the reason being that the destruction of the | 2586 // the below service registry, the reason being that the destruction of the |
2577 // latter is triggered by receiving a message that the pipe was closed from | 2587 // latter is triggered by receiving a message that the pipe was closed from |
2578 // the renderer side. Hence, supply the reference to this object as a weak | 2588 // the renderer side. Hence, supply the reference to this object as a weak |
2579 // pointer. | 2589 // pointer. |
2580 GetInterfaceRegistry()->AddInterface( | 2590 GetInterfaceRegistry()->AddInterface( |
2581 base::Bind(&device::GeolocationServiceContext::CreateService, | 2591 base::Bind(&device::GeolocationServiceContext::CreateService, |
2582 base::Unretained(geolocation_service_context))); | 2592 base::Unretained(geolocation_service_context))); |
2583 } | 2593 } |
2584 | 2594 |
2585 device::mojom::WakeLockContext* wake_lock_service_context = | 2595 if (delegate_) { |
2586 delegate_ ? delegate_->GetWakeLockServiceContext() : nullptr; | 2596 // Uses WebContentsImpl::ConnectToBlinkWakeLock() as a factory function |
2587 if (wake_lock_service_context) { | 2597 // for the WakeLockService mojo interface. Base::Bind the wrapper function |
2588 // WakeLockServiceContext is owned by WebContentsImpl so it will outlive | 2598 // so the ConnectToBlinkWakeLock can still run as a virtual function. |
2589 // this RenderFrameHostImpl, hence a raw pointer can be bound to service | |
2590 // factory callback. | |
2591 GetInterfaceRegistry()->AddInterface<device::mojom::WakeLockService>( | 2599 GetInterfaceRegistry()->AddInterface<device::mojom::WakeLockService>( |
2592 base::Bind(&device::mojom::WakeLockContext::GetWakeLock, | 2600 base::Bind(&ConnectToBlinkWakeLockWrapper, delegate_)); |
2593 base::Unretained(wake_lock_service_context))); | |
2594 } | 2601 } |
2595 | 2602 |
2596 if (!permission_service_context_) | 2603 if (!permission_service_context_) |
2597 permission_service_context_.reset(new PermissionServiceContext(this)); | 2604 permission_service_context_.reset(new PermissionServiceContext(this)); |
2598 | 2605 |
2599 GetInterfaceRegistry()->AddInterface( | 2606 GetInterfaceRegistry()->AddInterface( |
2600 base::Bind(&PermissionServiceContext::CreateService, | 2607 base::Bind(&PermissionServiceContext::CreateService, |
2601 base::Unretained(permission_service_context_.get()))); | 2608 base::Unretained(permission_service_context_.get()))); |
2602 | 2609 |
2603 GetInterfaceRegistry()->AddInterface(base::Bind( | 2610 GetInterfaceRegistry()->AddInterface(base::Bind( |
(...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3792 } | 3799 } |
3793 | 3800 |
3794 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame( | 3801 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame( |
3795 const std::string& interface_name, | 3802 const std::string& interface_name, |
3796 mojo::ScopedMessagePipeHandle pipe) { | 3803 mojo::ScopedMessagePipeHandle pipe) { |
3797 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe)); | 3804 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe)); |
3798 } | 3805 } |
3799 #endif | 3806 #endif |
3800 | 3807 |
3801 } // namespace content | 3808 } // namespace content |
OLD | NEW |