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..305a57029949d3cabe86fb141916499bd3f23983 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,26 @@ 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) { |
+ if (keepScreenOn) { |
+ mKeepScreenOnCount++; |
+ if (mKeepScreenOnCount == 1) { |
+ mKeepScreenOnView = mViewAndroidDelegate.acquireAnchorView(); |
+ mKeepScreenOnView.setKeepScreenOn(true); |
+ } |
+ } else { |
joth
2013/08/08 21:48:57
suggest: assert mKeepScreenOnCount > 0
michaelbai
2013/08/09 17:46:51
Done.
|
+ mKeepScreenOnCount--; |
+ if (mKeepScreenOnCount == 0) { |
+ mViewAndroidDelegate.releaseAnchorView(mKeepScreenOnView); |
+ mKeepScreenOnView = null; |
+ } |
+ } |
+ } |
+ |
private native int nativeInit(int windowPtr); |
private native void nativeDestroy(int nativeViewAndroid); |
} |