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