Chromium Code Reviews| Index: content/browser/screen_orientation/screen_orientation_provider_android.cc |
| diff --git a/content/browser/screen_orientation/screen_orientation_provider_android.cc b/content/browser/screen_orientation/screen_orientation_provider_android.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7c4166475d211be1be756576622d0a62da706b68 |
| --- /dev/null |
| +++ b/content/browser/screen_orientation/screen_orientation_provider_android.cc |
| @@ -0,0 +1,59 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/browser/screen_orientation/screen_orientation_provider_android.h" |
| + |
| +#include "content/browser/screen_orientation/screen_orientation_dispatcher_host.h" |
| +#include "jni/ScreenOrientationProvider_jni.h" |
| + |
| +using base::android::AttachCurrentThread; |
| + |
| +namespace content { |
| + |
| +ScreenOrientationProviderAndroid::ScreenOrientationProviderAndroid() { |
| + |
| +} |
| + |
| +ScreenOrientationProviderAndroid::~ScreenOrientationProviderAndroid() { |
| + |
| +} |
| + |
| +bool ScreenOrientationProviderAndroid::LockOrientation( |
| + Orientations orientations) { |
| + |
| + if ((orientations & OrientationPortrait) && |
| + (orientations & OrientationLandscape)) |
| + 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
|
| + |
| + if (j_orientation_provider_.is_null()) { |
| + j_orientation_provider_.Reset( |
| + Java_ScreenOrientationProvider_create( |
| + AttachCurrentThread(), |
| + base::android::GetApplicationContext())); |
| + } |
| + |
| + Java_ScreenOrientationProvider_lockOrientation(AttachCurrentThread(), |
| + j_orientation_provider_.obj(), orientations); |
| + return true; |
| +} |
| + |
| +void ScreenOrientationProviderAndroid::UnlockOrientation() { |
| + if (j_orientation_provider_.is_null()) |
| + return; |
| + Java_ScreenOrientationProvider_unlockOrientation(AttachCurrentThread(), |
| + j_orientation_provider_.obj()); |
| + |
| +} |
| + |
| +// static |
| +bool ScreenOrientationProviderAndroid::Register(JNIEnv* env) { |
| + return RegisterNativesImpl(env); |
| +} |
| + |
| +// static |
| +ScreenOrientationProvider* ScreenOrientationDispatcherHost::CreateProvider() { |
| + return new ScreenOrientationProviderAndroid(); |
| +} |
| + |
| +} // namespace content |