Chromium Code Reviews| Index: ui/android/java/src/org/chromium/ui/ViewAndroid.java |
| diff --git a/ui/android/java/src/org/chromium/ui/ViewAndroid.java b/ui/android/java/src/org/chromium/ui/ViewAndroid.java |
| index 0f0ca116a79c753f2058de2842c15b91ae4ebc2c..e167237250b868f372fe4aae57c497faec21e94a 100644 |
| --- a/ui/android/java/src/org/chromium/ui/ViewAndroid.java |
| +++ b/ui/android/java/src/org/chromium/ui/ViewAndroid.java |
| @@ -4,6 +4,8 @@ |
| package org.chromium.ui; |
| +import android.view.View; |
| + |
| import org.chromium.base.JNINamespace; |
| import org.chromium.ui.ViewAndroidDelegate; |
| import org.chromium.ui.WindowAndroid; |
| @@ -23,6 +25,8 @@ public class ViewAndroid { |
| private int mNativeViewAndroid = 0; |
| private final ViewAndroidDelegate mViewAndroidDelegate; |
| private final WindowAndroid mWindowAndroid; |
| + private int mKeepScreenOnCount; |
| + private View mKeepScreenOnView; |
| /** |
| * Constructs a View object. |
| @@ -55,6 +59,27 @@ public class ViewAndroid { |
| return mNativeViewAndroid; |
| } |
| + /** |
| + * Set whether to keep screen on when this view is in foreground. |
| + * @param keepScreenOn true if the screen needs to keep on. |
| + */ |
| + public void setKeepScreenOn(boolean keepScreenOn) { |
|
newt (away)
2013/08/09 20:57:21
I think it should be more clear that this method i
michaelbai
2013/08/09 23:06:50
It was named by Android's convention, but yes, the
|
| + if (keepScreenOn) { |
| + mKeepScreenOnCount++; |
| + if (mKeepScreenOnCount == 1) { |
| + mKeepScreenOnView = mViewAndroidDelegate.acquireAnchorView(); |
| + mKeepScreenOnView.setKeepScreenOn(true); |
| + } |
| + } else { |
| + assert mKeepScreenOnCount > 0; |
| + mKeepScreenOnCount--; |
| + if (mKeepScreenOnCount == 0) { |
| + mViewAndroidDelegate.releaseAnchorView(mKeepScreenOnView); |
| + mKeepScreenOnView = null; |
| + } |
| + } |
| + } |
| + |
| private native int nativeInit(int windowPtr); |
| private native void nativeDestroy(int nativeViewAndroid); |
| } |