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

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

Issue 150153004: [WIP] Add Chromium-side support for the Screen Orientation API (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: 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
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

Powered by Google App Engine
This is Rietveld 408576698