Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1689)

Unified Diff: content/browser/screen_orientation/screen_orientation_dispatcher_host.cc

Issue 177793003: Chromium plumbing for Screen Orientation API lock/unlock. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chromium_plumbing_screen_orientation
Patch Set: fix compilation issue Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698