| 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 05396a395cfd3c590e703e7eda454e9977b6bd7f..7472000f61be1ff103888ee8d348a2380a46bdce 100644
|
| --- a/content/browser/screen_orientation/screen_orientation_dispatcher_host.cc
|
| +++ b/content/browser/screen_orientation/screen_orientation_dispatcher_host.cc
|
| @@ -4,18 +4,33 @@
|
|
|
| #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()
|
| : BrowserMessageFilter(ScreenOrientationMsgStart) {
|
| + 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(ScreenOrientationHostMsg_Lock, OnLockRequest)
|
| + IPC_MESSAGE_HANDLER(ScreenOrientationHostMsg_Unlock, OnUnlockRequest)
|
| + IPC_MESSAGE_UNHANDLED(handled = false)
|
| + IPC_END_MESSAGE_MAP_EX()
|
| +
|
| + return handled;
|
| }
|
|
|
| void ScreenOrientationDispatcherHost::OnOrientationChange(
|
| @@ -23,4 +38,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);
|
| +}
|
| +
|
| +void ScreenOrientationDispatcherHost::OnUnlockRequest() {
|
| + if (!provider_.get())
|
| + return;
|
| +
|
| + provider_->UnlockOrientation();
|
| +}
|
| +
|
| +// static
|
| +ScreenOrientationProvider* ScreenOrientationDispatcherHost::CreateProvider() {
|
| + return NULL;
|
| +}
|
| +
|
| } // namespace content
|
|
|