| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/renderer/screen_orientation/screen_orientation_observer.h" | 5 #include "content/renderer/screen_orientation/screen_orientation_observer.h" |
| 6 | 6 |
| 7 #include "content/public/common/service_manager_connection.h" |
| 7 #include "content/renderer/render_thread_impl.h" | 8 #include "content/renderer/render_thread_impl.h" |
| 9 #include "services/device/public/interfaces/constants.mojom.h" |
| 10 #include "services/service_manager/public/cpp/connector.h" |
| 8 | 11 |
| 9 namespace content { | 12 namespace content { |
| 10 | 13 |
| 11 ScreenOrientationObserver::ScreenOrientationObserver() { | 14 ScreenOrientationObserver::ScreenOrientationObserver() { |
| 12 } | 15 } |
| 13 | 16 |
| 14 ScreenOrientationObserver::~ScreenOrientationObserver() { | 17 ScreenOrientationObserver::~ScreenOrientationObserver() { |
| 15 StopIfObserving(); | 18 StopIfObserving(); |
| 16 } | 19 } |
| 17 | 20 |
| 18 void ScreenOrientationObserver::Start( | 21 void ScreenOrientationObserver::Start( |
| 19 blink::WebPlatformEventListener* listener) { | 22 blink::WebPlatformEventListener* listener) { |
| 20 // This should never be called with a proper listener. | 23 // This should never be called with a proper listener. |
| 21 CHECK(listener == 0); | 24 CHECK(listener == 0); |
| 22 PlatformEventObserver<blink::WebPlatformEventListener>::Start(0); | 25 PlatformEventObserver<blink::WebPlatformEventListener>::Start(0); |
| 23 } | 26 } |
| 24 | 27 |
| 25 void ScreenOrientationObserver::SendStartMessage() { | 28 void ScreenOrientationObserver::SendStartMessage() { |
| 26 GetScreenOrientationListener()->Start(); | 29 GetScreenOrientationListener()->Start(); |
| 27 } | 30 } |
| 28 | 31 |
| 29 void ScreenOrientationObserver::SendStopMessage() { | 32 void ScreenOrientationObserver::SendStopMessage() { |
| 30 GetScreenOrientationListener()->Stop(); | 33 GetScreenOrientationListener()->Stop(); |
| 31 } | 34 } |
| 32 | 35 |
| 33 device::mojom::ScreenOrientationListener* | 36 device::mojom::ScreenOrientationListener* |
| 34 ScreenOrientationObserver::GetScreenOrientationListener() { | 37 ScreenOrientationObserver::GetScreenOrientationListener() { |
| 35 if (!listener_) { | 38 if (!listener_) { |
| 36 RenderThreadImpl::current()->GetChannel()->GetRemoteAssociatedInterface( | 39 RenderThreadImpl::current() |
| 37 &listener_); | 40 ->GetServiceManagerConnection() |
| 41 ->GetConnector() |
| 42 ->BindInterface(device::mojom::kServiceName, &listener_); |
| 38 } | 43 } |
| 39 return listener_.get(); | 44 return listener_.get(); |
| 40 } | 45 } |
| 41 | 46 |
| 42 } // namespace content | 47 } // namespace content |
| OLD | NEW |