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

Side by Side 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 unified diff | Download patch
OLDNEW
(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;
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698