Chromium Code Reviews| 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(ScreenOrientationMsg_Lock, OnLockRequest) | |
| 28 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
| |
| 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); | |
|
Cris Neckar
2014/02/24 21:02:28
remove this until you actually implement it.
You
| |
| 51 } | |
| 52 | |
| 53 void ScreenOrientationDispatcherHost::OnUnlockRequest() { | |
| 54 if (!provider_.get()) | |
| 55 return; | |
| 56 | |
| 57 provider_->UnlockOrientation(); | |
|
Cris Neckar
2014/02/24 21:02:28
ditto
| |
| 58 } | |
| 59 | |
| 60 // static | |
| 61 ScreenOrientationProvider* ScreenOrientationDispatcherHost::CreateProvider() { | |
| 62 return NULL; | |
| 63 } | |
| 64 | |
| 25 } // namespace content | 65 } // namespace content |
| OLD | NEW |