OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host.
h" |
| 6 #include "content/browser/screen_orientation/screen_orientation_provider_android
.h" |
| 7 #include "jni/ScreenOrientationProvider_jni.h" |
| 8 |
| 9 namespace content { |
| 10 |
| 11 // static |
| 12 bool ScreenOrientationProviderAndroid::Register(JNIEnv* env) { |
| 13 return RegisterNativesImpl(env); |
| 14 } |
| 15 |
| 16 void ScreenOrientationProviderAndroid::LockOrientation( |
| 17 blink::WebScreenOrientations orientations) { |
| 18 if (j_screen_orientation_provider_.is_null()) { |
| 19 j_screen_orientation_provider_.Reset(Java_ScreenOrientationProvider_create( |
| 20 base::android::AttachCurrentThread())); |
| 21 } |
| 22 |
| 23 Java_ScreenOrientationProvider_lockOrientation( |
| 24 base::android::AttachCurrentThread(), |
| 25 j_screen_orientation_provider_.obj(), orientations); |
| 26 } |
| 27 |
| 28 void ScreenOrientationProviderAndroid::UnlockOrientation() { |
| 29 // j_screen_orientation_provider_ is set when locking. If the screen |
| 30 // orientation was not locked, unlocking should be a no-op. |
| 31 if (j_screen_orientation_provider_.is_null()) |
| 32 return; |
| 33 |
| 34 Java_ScreenOrientationProvider_unlockOrientation( |
| 35 base::android::AttachCurrentThread(), |
| 36 j_screen_orientation_provider_.obj()); |
| 37 } |
| 38 |
| 39 // static |
| 40 ScreenOrientationProvider* ScreenOrientationDispatcherHost::CreateProvider() { |
| 41 return new ScreenOrientationProviderAndroid(); |
| 42 } |
| 43 |
| 44 } // namespace content |
OLD | NEW |