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..e6eec429d1543b1df46835ae683fd5990a4b4f8d |
| --- /dev/null |
| +++ b/content/browser/screen_orientation/screen_orientation_provider_android.cc |
| @@ -0,0 +1,50 @@ |
| +// 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_dispatcher_host.h" |
| +#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.
|
| +#include "jni/ScreenOrientationProvider_jni.h" |
| + |
| +namespace content { |
| + |
| +ScreenOrientationProviderAndroid::ScreenOrientationProviderAndroid() { |
| +} |
| + |
| +ScreenOrientationProviderAndroid::~ScreenOrientationProviderAndroid() { |
| +} |
| + |
| +// static |
| +bool ScreenOrientationProviderAndroid::Register(JNIEnv* env) { |
| + return RegisterNativesImpl(env); |
| +} |
| + |
| +void ScreenOrientationProviderAndroid::LockOrientation( |
| + blink::WebScreenOrientations orientations) { |
| + if (j_screen_orientation_provider_.is_null()) { |
| + j_screen_orientation_provider_.Reset(Java_ScreenOrientationProvider_create( |
| + base::android::AttachCurrentThread())); |
| + } |
| + |
| + Java_ScreenOrientationProvider_lockOrientation( |
| + base::android::AttachCurrentThread(), |
| + j_screen_orientation_provider_.obj(), orientations); |
| +} |
| + |
| +void ScreenOrientationProviderAndroid::UnlockOrientation() { |
| + // j_screen_orientation_provider_ is set when locking. If the screen |
| + // orientation was not locked, unlocking should be a no-op. |
| + if (j_screen_orientation_provider_.is_null()) |
| + return; |
| + |
| + Java_ScreenOrientationProvider_unlockOrientation( |
| + base::android::AttachCurrentThread(), |
| + j_screen_orientation_provider_.obj()); |
| +} |
| + |
| +// static |
| +ScreenOrientationProvider* ScreenOrientationDispatcherHost::CreateProvider() { |
| + return new ScreenOrientationProviderAndroid(); |
| +} |
| + |
| +} // namespace content |