| 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..2c61558163c3c5756a01bf8ec4495689df03f786
|
| --- /dev/null
|
| +++ b/content/browser/screen_orientation/screen_orientation_provider_android.cc
|
| @@ -0,0 +1,44 @@
|
| +// 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"
|
| +#include "jni/ScreenOrientationProvider_jni.h"
|
| +
|
| +namespace content {
|
| +
|
| +// 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
|
|
|