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

Unified Diff: content/browser/screen_orientation/screen_orientation_provider_android.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_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..7c4166475d211be1be756576622d0a62da706b68
--- /dev/null
+++ b/content/browser/screen_orientation/screen_orientation_provider_android.cc
@@ -0,0 +1,59 @@
+// 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_provider_android.h"
+
+#include "content/browser/screen_orientation/screen_orientation_dispatcher_host.h"
+#include "jni/ScreenOrientationProvider_jni.h"
+
+using base::android::AttachCurrentThread;
+
+namespace content {
+
+ScreenOrientationProviderAndroid::ScreenOrientationProviderAndroid() {
+
+}
+
+ScreenOrientationProviderAndroid::~ScreenOrientationProviderAndroid() {
+
+}
+
+bool ScreenOrientationProviderAndroid::LockOrientation(
+ Orientations orientations) {
+
+ if ((orientations & OrientationPortrait) &&
+ (orientations & OrientationLandscape))
+ return false;
kenneth.r.christiansen 2014/02/06 15:03:12 does the spec say that that is not allowed? I hea
ostap 2014/02/06 21:23:28 That's android specific. Current android API can l
+
+ if (j_orientation_provider_.is_null()) {
+ j_orientation_provider_.Reset(
+ Java_ScreenOrientationProvider_create(
+ AttachCurrentThread(),
+ base::android::GetApplicationContext()));
+ }
+
+ Java_ScreenOrientationProvider_lockOrientation(AttachCurrentThread(),
+ j_orientation_provider_.obj(), orientations);
+ return true;
+}
+
+void ScreenOrientationProviderAndroid::UnlockOrientation() {
+ if (j_orientation_provider_.is_null())
+ return;
+ Java_ScreenOrientationProvider_unlockOrientation(AttachCurrentThread(),
+ j_orientation_provider_.obj());
+
+}
+
+// static
+bool ScreenOrientationProviderAndroid::Register(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+// static
+ScreenOrientationProvider* ScreenOrientationDispatcherHost::CreateProvider() {
+ return new ScreenOrientationProviderAndroid();
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698