Commit de212233 authored by mlamouri@chromium.org's avatar mlamouri@chromium.org

Make ScreenOrientationProvider (Java) a bag of static methods.

BUG=162827

Review URL: https://codereview.chromium.org/410173002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285004 0039d316-1c4b-4281-b951-d872f2087c98
parent fd75b1df
......@@ -5,6 +5,7 @@
#ifndef CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_PROVIDER_H_
#define CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_PROVIDER_H_
#include "base/macros.h"
#include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h"
namespace content {
......
......@@ -69,15 +69,9 @@ void ScreenOrientationProviderAndroid::LockOrientation(
}
}
if (j_screen_orientation_provider_.is_null()) {
j_screen_orientation_provider_.Reset(Java_ScreenOrientationProvider_create(
base::android::AttachCurrentThread()));
}
lock_applied_ = true;
Java_ScreenOrientationProvider_lockOrientation(
base::android::AttachCurrentThread(),
j_screen_orientation_provider_.obj(), lock_orientation);
base::android::AttachCurrentThread(), lock_orientation);
// If two calls happen close to each other, Android will ignore the first.
if (pending_lock_) {
......@@ -99,12 +93,8 @@ void ScreenOrientationProviderAndroid::UnlockOrientation() {
if (!lock_applied_)
return;
// j_screen_orientation_provider_ was set when locking so it can't be null.
DCHECK(!j_screen_orientation_provider_.is_null());
Java_ScreenOrientationProvider_unlockOrientation(
base::android::AttachCurrentThread(),
j_screen_orientation_provider_.obj());
base::android::AttachCurrentThread());
lock_applied_ = false;
}
......
......@@ -5,7 +5,8 @@
#ifndef CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_PROVIDER_ANDROID_H_
#define CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_PROVIDER_ANDROID_H_
#include "base/android/jni_android.h"
#include <jni.h>
#include "base/compiler_specific.h"
#include "content/browser/screen_orientation/screen_orientation_provider.h"
#include "content/public/browser/web_contents_observer.h"
......@@ -46,8 +47,6 @@ class ScreenOrientationProviderAndroid : public ScreenOrientationProvider,
virtual ~ScreenOrientationProviderAndroid();
base::android::ScopedJavaGlobalRef<jobject> j_screen_orientation_provider_;
// ScreenOrientationDispatcherHost owns ScreenOrientationProvider so
// dispatcher_ should not point to an invalid memory.
ScreenOrientationDispatcherHost* dispatcher_;
......
......@@ -9,8 +9,6 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.util.Log;
import com.google.common.annotations.VisibleForTesting;
import org.chromium.base.ApplicationStatus;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
......@@ -23,7 +21,7 @@ import org.chromium.content.common.ScreenOrientationValues;
class ScreenOrientationProvider {
private static final String TAG = "ScreenOrientationProvider";
private int getOrientationFromWebScreenOrientations(byte orientations) {
private static int getOrientationFromWebScreenOrientations(byte orientations) {
switch (orientations) {
case ScreenOrientationValues.DEFAULT:
return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
......@@ -47,14 +45,8 @@ class ScreenOrientationProvider {
}
}
@VisibleForTesting
@CalledByNative
static ScreenOrientationProvider create() {
return new ScreenOrientationProvider();
}
@CalledByNative
void lockOrientation(byte orientations) {
static void lockOrientation(byte orientations) {
Activity activity = ApplicationStatus.getLastTrackedFocusedActivity();
if (activity == null) {
return;
......@@ -69,7 +61,7 @@ class ScreenOrientationProvider {
}
@CalledByNative
void unlockOrientation() {
static void unlockOrientation() {
Activity activity = ApplicationStatus.getLastTrackedFocusedActivity();
if (activity == null) {
return;
......
......@@ -29,7 +29,6 @@ public class ScreenOrientationProviderTest extends ContentShellTestBase {
UrlUtils.encodeHtmlDataUri("<html><body>foo</body></html>");
private MockOrientationObserver mObserver;
private final ScreenOrientationProvider mProvider = ScreenOrientationProvider.create();
private boolean checkOrientationForLock(int orientations) {
switch (orientations) {
......@@ -58,7 +57,7 @@ public class ScreenOrientationProviderTest extends ContentShellTestBase {
* Locks the screen orientation to |orientations| using ScreenOrientationProvider.
*/
private void lockOrientation(int orientations) {
mProvider.lockOrientation((byte)orientations);
ScreenOrientationProvider.lockOrientation((byte)orientations);
}
/**
......@@ -78,7 +77,7 @@ public class ScreenOrientationProviderTest extends ContentShellTestBase {
* Unlock the screen orientation using |ScreenOrientationProvider|.
*/
private void unlockOrientation() {
mProvider.unlockOrientation();
ScreenOrientationProvider.unlockOrientation();
}
@Override
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment