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_provider_android
.h" |
| 6 |
| 7 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host.
h" |
| 8 #include "jni/ScreenOrientationProvider_jni.h" |
| 9 |
| 10 using base::android::AttachCurrentThread; |
| 11 |
| 12 namespace content { |
| 13 |
| 14 ScreenOrientationProviderAndroid::ScreenOrientationProviderAndroid() { |
| 15 |
| 16 } |
| 17 |
| 18 ScreenOrientationProviderAndroid::~ScreenOrientationProviderAndroid() { |
| 19 |
| 20 } |
| 21 |
| 22 bool ScreenOrientationProviderAndroid::LockOrientation( |
| 23 Orientations orientations) { |
| 24 |
| 25 if ((orientations & OrientationPortrait) && |
| 26 (orientations & OrientationLandscape)) |
| 27 return false; |
| 28 |
| 29 if (j_orientation_provider_.is_null()) { |
| 30 j_orientation_provider_.Reset( |
| 31 Java_ScreenOrientationProvider_create( |
| 32 AttachCurrentThread(), |
| 33 base::android::GetApplicationContext())); |
| 34 } |
| 35 |
| 36 Java_ScreenOrientationProvider_lockOrientation(AttachCurrentThread(), |
| 37 j_orientation_provider_.obj(), orientations); |
| 38 return true; |
| 39 } |
| 40 |
| 41 void ScreenOrientationProviderAndroid::UnlockOrientation() { |
| 42 if (j_orientation_provider_.is_null()) |
| 43 return; |
| 44 Java_ScreenOrientationProvider_unlockOrientation(AttachCurrentThread(), |
| 45 j_orientation_provider_.obj()); |
| 46 |
| 47 } |
| 48 |
| 49 // static |
| 50 bool ScreenOrientationProviderAndroid::Register(JNIEnv* env) { |
| 51 return RegisterNativesImpl(env); |
| 52 } |
| 53 |
| 54 // static |
| 55 ScreenOrientationProvider* ScreenOrientationDispatcherHost::CreateProvider() { |
| 56 return new ScreenOrientationProviderAndroid(); |
| 57 } |
| 58 |
| 59 } // namespace content |
OLD | NEW |