Chromium Code Reviews| Index: content/browser/screen_orientation/screen_orientation_dispatcher_host.cc |
| diff --git a/content/browser/screen_orientation/screen_orientation_dispatcher_host.cc b/content/browser/screen_orientation/screen_orientation_dispatcher_host.cc |
| index c868beba44f03262c4b3b94bd9a627009aa1f8d2..5e5e35babbdec9cd1ee70b4d6ef747a03e5010eb 100644 |
| --- a/content/browser/screen_orientation/screen_orientation_dispatcher_host.cc |
| +++ b/content/browser/screen_orientation/screen_orientation_dispatcher_host.cc |
| @@ -4,17 +4,32 @@ |
| #include "content/browser/screen_orientation/screen_orientation_dispatcher_host.h" |
| +#include "content/browser/screen_orientation/screen_orientation_provider.h" |
| #include "content/common/screen_orientation_messages.h" |
| namespace content { |
| ScreenOrientationDispatcherHost::ScreenOrientationDispatcherHost() { |
| + if (!provider_.get()) |
| + provider_.reset(CreateProvider()); |
| +} |
| + |
| +ScreenOrientationDispatcherHost::~ScreenOrientationDispatcherHost() { |
| } |
| bool ScreenOrientationDispatcherHost::OnMessageReceived( |
| const IPC::Message& message, bool* message_was_ok) { |
| - // TODO(mlamouri): we will handle lock and unlock requests here. |
| - return false; |
| + bool handled = true; |
| + |
| + IPC_BEGIN_MESSAGE_MAP_EX(ScreenOrientationDispatcherHost, |
| + message, |
| + *message_was_ok) |
| + IPC_MESSAGE_HANDLER(ScreenOrientationMsg_Lock, OnLockRequest) |
| + IPC_MESSAGE_HANDLER(ScreenOrientationMsg_Unlock, OnUnlockRequest) |
|
Cris Neckar
2014/02/24 21:02:28
Currently sending these messages will result in a
mlamouri (slow - plz ping)
2014/02/24 21:47:50
I'm not sure I understand wyh that would crash. Be
Cris Neckar
2014/02/24 22:00:04
oh my mistake I was reading too quickly. Saw the c
|
| + IPC_MESSAGE_UNHANDLED(handled = false) |
| + IPC_END_MESSAGE_MAP_EX() |
| + |
| + return handled; |
| } |
| void ScreenOrientationDispatcherHost::OnOrientationChange( |
| @@ -22,4 +37,29 @@ void ScreenOrientationDispatcherHost::OnOrientationChange( |
| Send(new ScreenOrientationMsg_OrientationChange(orientation)); |
| } |
| +void ScreenOrientationDispatcherHost::SetProviderForTests( |
| + ScreenOrientationProvider* provider) { |
| + provider_.reset(provider); |
| +} |
| + |
| +void ScreenOrientationDispatcherHost::OnLockRequest( |
| + blink::WebScreenOrientations orientations) { |
| + if (!provider_.get()) |
| + return; |
| + |
| + provider_->LockOrientation(orientations); |
|
Cris Neckar
2014/02/24 21:02:28
remove this until you actually implement it.
You
|
| +} |
| + |
| +void ScreenOrientationDispatcherHost::OnUnlockRequest() { |
| + if (!provider_.get()) |
| + return; |
| + |
| + provider_->UnlockOrientation(); |
|
Cris Neckar
2014/02/24 21:02:28
ditto
|
| +} |
| + |
| +// static |
| +ScreenOrientationProvider* ScreenOrientationDispatcherHost::CreateProvider() { |
| + return NULL; |
| +} |
| + |
| } // namespace content |