| 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/browser/screen_orientation/screen_orientation_dispatcher_host.
h" | 5 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host.
h" |
| 6 | 6 |
| 7 #include "content/browser/screen_orientation/screen_orientation_provider.h" |
| 7 #include "content/common/screen_orientation_messages.h" | 8 #include "content/common/screen_orientation_messages.h" |
| 8 | 9 |
| 9 namespace content { | 10 namespace content { |
| 10 | 11 |
| 11 ScreenOrientationDispatcherHost::ScreenOrientationDispatcherHost() { | 12 ScreenOrientationDispatcherHost::ScreenOrientationDispatcherHost() { |
| 13 if (!provider_.get()) |
| 14 provider_.reset(CreateProvider()); |
| 15 } |
| 16 |
| 17 ScreenOrientationDispatcherHost::~ScreenOrientationDispatcherHost() { |
| 12 } | 18 } |
| 13 | 19 |
| 14 bool ScreenOrientationDispatcherHost::OnMessageReceived( | 20 bool ScreenOrientationDispatcherHost::OnMessageReceived( |
| 15 const IPC::Message& message, bool* message_was_ok) { | 21 const IPC::Message& message, bool* message_was_ok) { |
| 16 // TODO(mlamouri): we will handle lock and unlock requests here. | 22 bool handled = true; |
| 17 return false; | 23 |
| 24 IPC_BEGIN_MESSAGE_MAP_EX(ScreenOrientationDispatcherHost, |
| 25 message, |
| 26 *message_was_ok) |
| 27 IPC_MESSAGE_HANDLER(ScreenOrientationHostMsg_Lock, OnLockRequest) |
| 28 IPC_MESSAGE_HANDLER(ScreenOrientationHostMsg_Unlock, OnUnlockRequest) |
| 29 IPC_MESSAGE_UNHANDLED(handled = false) |
| 30 IPC_END_MESSAGE_MAP_EX() |
| 31 |
| 32 return handled; |
| 18 } | 33 } |
| 19 | 34 |
| 20 void ScreenOrientationDispatcherHost::OnOrientationChange( | 35 void ScreenOrientationDispatcherHost::OnOrientationChange( |
| 21 blink::WebScreenOrientation orientation) { | 36 blink::WebScreenOrientation orientation) { |
| 22 Send(new ScreenOrientationMsg_OrientationChange(orientation)); | 37 Send(new ScreenOrientationMsg_OrientationChange(orientation)); |
| 23 } | 38 } |
| 24 | 39 |
| 40 void ScreenOrientationDispatcherHost::SetProviderForTests( |
| 41 ScreenOrientationProvider* provider) { |
| 42 provider_.reset(provider); |
| 43 } |
| 44 |
| 45 void ScreenOrientationDispatcherHost::OnLockRequest( |
| 46 blink::WebScreenOrientations orientations) { |
| 47 if (!provider_.get()) |
| 48 return; |
| 49 |
| 50 provider_->LockOrientation(orientations); |
| 51 } |
| 52 |
| 53 void ScreenOrientationDispatcherHost::OnUnlockRequest() { |
| 54 if (!provider_.get()) |
| 55 return; |
| 56 |
| 57 provider_->UnlockOrientation(); |
| 58 } |
| 59 |
| 60 // static |
| 61 ScreenOrientationProvider* ScreenOrientationDispatcherHost::CreateProvider() { |
| 62 return NULL; |
| 63 } |
| 64 |
| 25 } // namespace content | 65 } // namespace content |
| OLD | NEW |