OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "content/renderer/screen_orientation/screen_orientation_observer.h" | |
6 | |
7 #include "content/public/common/service_manager_connection.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" | |
11 | |
12 namespace content { | |
13 | |
14 ScreenOrientationObserver::ScreenOrientationObserver() { | |
15 } | |
16 | |
17 ScreenOrientationObserver::~ScreenOrientationObserver() { | |
18 StopIfObserving(); | |
19 } | |
20 | |
21 void ScreenOrientationObserver::Start( | |
22 blink::WebPlatformEventListener* listener) { | |
23 // This should never be called with a proper listener. | |
24 CHECK(listener == 0); | |
25 PlatformEventObserver<blink::WebPlatformEventListener>::Start(0); | |
26 } | |
27 | |
28 void ScreenOrientationObserver::SendStartMessage() { | |
29 GetScreenOrientationListener()->Start(); | |
30 } | |
31 | |
32 void ScreenOrientationObserver::SendStopMessage() { | |
33 GetScreenOrientationListener()->Stop(); | |
34 } | |
35 | |
36 device::mojom::ScreenOrientationListener* | |
37 ScreenOrientationObserver::GetScreenOrientationListener() { | |
38 if (!listener_) { | |
39 RenderThreadImpl::current() | |
40 ->GetServiceManagerConnection() | |
41 ->GetConnector() | |
42 ->BindInterface(device::mojom::kServiceName, &listener_); | |
43 } | |
44 return listener_.get(); | |
45 } | |
46 | |
47 } // namespace content | |
OLD | NEW |