Index: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
index df0b303d607693f341c0dbb642d36be7a17bf401..51c4061b569303e23b535e5829f91f126fc0886c 100644 |
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
@@ -79,7 +79,6 @@ import org.chromium.content_public.browser.GestureStateListener; |
import org.chromium.content_public.browser.WebContents; |
import org.chromium.content_public.browser.WebContentsObserver; |
import org.chromium.ui.base.DeviceFormFactor; |
-import org.chromium.ui.base.ViewAndroid; |
import org.chromium.ui.base.ViewAndroidDelegate; |
import org.chromium.ui.base.WindowAndroid; |
import org.chromium.ui.base.ime.TextInputType; |
@@ -303,6 +302,35 @@ public class ContentViewCore |
} |
} |
+ private int mKeepScreenOnCount; |
+ private View mKeepScreenOnView; |
+ |
+ /** |
+ * Set KeepScreenOn flag. If the flag already set, increase mKeepScreenOnCount. |
+ */ |
+ @CalledByNative |
+ private void incrementKeepScreenOnCount() { |
+ mKeepScreenOnCount++; |
+ if (mKeepScreenOnCount == 1) { |
+ mKeepScreenOnView = mViewAndroidDelegate.acquireAnchorView(); |
+ mViewAndroidDelegate.setAnchorViewPosition(mKeepScreenOnView, 0, 0, 0, 0); |
+ mKeepScreenOnView.setKeepScreenOn(true); |
+ } |
+ } |
+ |
+ /** |
+ * Decrease mKeepScreenOnCount, if it is decreased to 0, remove the flag. |
+ */ |
+ @CalledByNative |
+ private void decrementKeepScreenOnCount() { |
+ assert mKeepScreenOnCount > 0; |
+ mKeepScreenOnCount--; |
+ if (mKeepScreenOnCount == 0) { |
+ mViewAndroidDelegate.releaseAnchorView(mKeepScreenOnView); |
+ mKeepScreenOnView = null; |
+ } |
+ } |
+ |
/** |
* A {@link WebContentsObserver} that listens to frame navigation events. |
*/ |
@@ -581,8 +609,6 @@ public class ContentViewCore |
// onNativeFlingStopped() is called asynchronously. |
private int mPotentiallyActiveFlingCount; |
- private ViewAndroid mViewAndroid; |
- |
private SmartClipDataListener mSmartClipDataListener = null; |
private ObserverList<ContainerViewObserver> mContainerViewObservers; |
@@ -741,11 +767,6 @@ public class ContentViewCore |
return mInputConnection; |
} |
- @VisibleForTesting |
- ViewAndroid getViewAndroid() { |
- return mViewAndroid; |
- } |
- |
private ImeAdapter createImeAdapter() { |
return new ImeAdapter(mInputMethodManagerWrapper, |
new ImeAdapter.ImeAdapterDelegate() { |
@@ -824,12 +845,11 @@ public class ContentViewCore |
setContainerView(containerView); |
long windowNativePointer = windowAndroid.getNativePointer(); |
assert windowNativePointer != 0; |
- createViewAndroid(windowAndroid); |
mZoomControlsDelegate = NO_OP_ZOOM_CONTROLS_DELEGATE; |
mNativeContentViewCore = nativeInit( |
- webContents, mViewAndroid, windowNativePointer, mRetainedJavaScriptObjects); |
+ webContents, mViewAndroidDelegate, windowNativePointer, mRetainedJavaScriptObjects); |
mWebContents = nativeGetWebContentsAndroid(mNativeContentViewCore); |
setContainerViewInternals(internalDispatcher); |
@@ -849,11 +869,6 @@ public class ContentViewCore |
new ContentViewAndroidDelegate(mContext, mContainerView, mRenderCoordinates); |
} |
- @VisibleForTesting |
- void createViewAndroid(WindowAndroid windowAndroid) { |
- mViewAndroid = new ViewAndroid(mViewAndroidDelegate); |
- } |
- |
/** |
* Sets a new container view for this {@link ContentViewCore}. |
* |
@@ -3089,7 +3104,7 @@ public class ContentViewCore |
if (potentiallyActiveFlingCount > 0) updateGestureStateListener(GestureEventType.FLING_END); |
} |
- private native long nativeInit(WebContents webContents, ViewAndroid viewAndroid, |
+ private native long nativeInit(WebContents webContents, ViewAndroidDelegate viewAndroidDelegate, |
long windowAndroidPtr, HashSet<Object> retainedObjectSet); |
private static native ContentViewCore nativeFromWebContentsAndroid(WebContents webContents); |
ContentVideoViewClient getContentVideoViewClient() { |