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