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 |
new file mode 100644 |
index 0000000000000000000000000000000000000000..dbf0070b1cd973f82dd9108ff234e1c83a424d9e |
--- /dev/null |
+++ b/content/browser/screen_orientation/screen_orientation_dispatcher_host.cc |
@@ -0,0 +1,70 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "content/browser/screen_orientation/screen_orientation_dispatcher_host.h" |
+ |
+#include "content/common/view_messages.h" |
+#include "content/port/browser/screen_orientation_provider.h" |
+#include "content/public/browser/content_browser_client.h" |
+#include "content/public/common/content_client.h" |
+ |
+namespace content { |
+ |
+ScreenOrientationDispatcherHost::ScreenOrientationDispatcherHost() |
+ : orientation_lock_(0) { |
+ provider_.reset( |
+ GetContentClient()->browser()->OverrideScreenOrientationProvider()); |
+ if (!provider_.get()) |
+ provider_.reset(CreateProvider()); |
+} |
+ |
+ScreenOrientationDispatcherHost::~ScreenOrientationDispatcherHost() { |
+} |
+ |
+bool ScreenOrientationDispatcherHost::OnMessageReceived( |
+ const IPC::Message& message, |
+ bool* message_was_ok) { |
+ bool handled = true; |
+ IPC_BEGIN_MESSAGE_MAP_EX(ScreenOrientationDispatcherHost, |
+ message, |
+ *message_was_ok) |
+ IPC_MESSAGE_HANDLER(ViewHostMsg_LockScreenOrientation, OnLockOrientation) |
+ IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockScreenOrientation, |
+ OnUnlockOrientation) |
+ IPC_MESSAGE_UNHANDLED(handled = false) |
+ IPC_END_MESSAGE_MAP_EX() |
+ return handled; |
+} |
+ |
+void ScreenOrientationDispatcherHost::OnLockOrientation(unsigned char lock, |
kenneth.r.christiansen
2014/02/06 15:03:12
why not wrap the argument like in the method above
ostap
2014/02/06 21:23:28
Done.
|
+ bool* result) { |
+ if (!provider_.get()) |
+ return; |
+ |
+ orientation_lock_ = |
+ static_cast<ScreenOrientationProvider::Orientations>(lock); |
+ |
+ assert((orientation_lock_ & ScreenOrientationProvider::OrientationAny) == 0); |
+ |
+ // Is it legal to provide empty lock? |
+ assert(orientation_lock_); |
kenneth.r.christiansen
2014/02/06 15:03:12
I would say no, so the Blink implementation needs
ostap
2014/02/06 21:23:28
Ok. Added to TODO list ;)
|
+ |
+ *result = provider_->LockOrientation(orientation_lock_); |
+} |
+ |
+void ScreenOrientationDispatcherHost::OnUnlockOrientation() { |
+ if (!provider_.get()) |
+ return; |
+ |
+ provider_->UnlockOrientation(); |
+ orientation_lock_ = 0; |
+} |
+ |
+#if !defined(OS_ANDROID) |
+// static |
+ScreenOrientationProvider* ScreenOrientationDispatcherHost::CreateProvider() { |
+ return NULL; |
+} |
+#endif |
+} // namespace content |