1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/browser/screen_orientation/screen_orientation_provider_android.h"
7 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host.h"
8 #include "jni/ScreenOrientationProvider_jni.h"
12 ScreenOrientationProviderAndroid::ScreenOrientationProviderAndroid() {
15 ScreenOrientationProviderAndroid::~ScreenOrientationProviderAndroid() {
19 bool ScreenOrientationProviderAndroid::Register(JNIEnv* env) {
20 return RegisterNativesImpl(env);
23 void ScreenOrientationProviderAndroid::LockOrientation(
24 blink::WebScreenOrientationLockType orientation) {
25 if (j_screen_orientation_provider_.is_null()) {
26 j_screen_orientation_provider_.Reset(Java_ScreenOrientationProvider_create(
27 base::android::AttachCurrentThread()));
30 Java_ScreenOrientationProvider_lockOrientation(
31 base::android::AttachCurrentThread(),
32 j_screen_orientation_provider_.obj(), orientation);
35 void ScreenOrientationProviderAndroid::UnlockOrientation() {
36 // j_screen_orientation_provider_ is set when locking. If the screen
37 // orientation was not locked, unlocking should be a no-op.
38 if (j_screen_orientation_provider_.is_null())
41 Java_ScreenOrientationProvider_unlockOrientation(
42 base::android::AttachCurrentThread(),
43 j_screen_orientation_provider_.obj());
47 ScreenOrientationProvider* ScreenOrientationDispatcherHost::CreateProvider() {
48 return new ScreenOrientationProviderAndroid();
51 } // namespace content