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

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

Issue 196193002: Implement ScreenOrientationProvider for Chrome Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 6 years, 9 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_provider_android.cc
diff --git a/content/browser/screen_orientation/screen_orientation_provider_android.cc b/content/browser/screen_orientation/screen_orientation_provider_android.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e6eec429d1543b1df46835ae683fd5990a4b4f8d
--- /dev/null
+++ b/content/browser/screen_orientation/screen_orientation_provider_android.cc
@@ -0,0 +1,50 @@
+// 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/browser/screen_orientation/screen_orientation_provider_android.h"
Michael van Ouwerkerk 2014/03/12 14:42:55 This line should sit alone above the rest.
mlamouri (slow - plz ping) 2014/03/12 20:19:55 Done.
+#include "jni/ScreenOrientationProvider_jni.h"
+
+namespace content {
+
+ScreenOrientationProviderAndroid::ScreenOrientationProviderAndroid() {
+}
+
+ScreenOrientationProviderAndroid::~ScreenOrientationProviderAndroid() {
+}
+
+// static
+bool ScreenOrientationProviderAndroid::Register(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+void ScreenOrientationProviderAndroid::LockOrientation(
+ blink::WebScreenOrientations orientations) {
+ if (j_screen_orientation_provider_.is_null()) {
+ j_screen_orientation_provider_.Reset(Java_ScreenOrientationProvider_create(
+ base::android::AttachCurrentThread()));
+ }
+
+ Java_ScreenOrientationProvider_lockOrientation(
+ base::android::AttachCurrentThread(),
+ j_screen_orientation_provider_.obj(), orientations);
+}
+
+void ScreenOrientationProviderAndroid::UnlockOrientation() {
+ // j_screen_orientation_provider_ is set when locking. If the screen
+ // orientation was not locked, unlocking should be a no-op.
+ if (j_screen_orientation_provider_.is_null())
+ return;
+
+ Java_ScreenOrientationProvider_unlockOrientation(
+ base::android::AttachCurrentThread(),
+ j_screen_orientation_provider_.obj());
+}
+
+// static
+ScreenOrientationProvider* ScreenOrientationDispatcherHost::CreateProvider() {
+ return new ScreenOrientationProviderAndroid();
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698