Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java

Issue 381593002: Removing ContentView dependencies for few functions which acts as WebContents wrapper. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed review comments. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 45f6f8719ee76dd9984c0f4e0de72f83d035b204..fff1e58bcec2a459c645e044a9bd828f4c369dfe 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
@@ -15,7 +15,6 @@ import android.content.res.Configuration;
import android.database.ContentObserver;
import android.graphics.Bitmap;
import android.graphics.Canvas;
-import android.graphics.Color;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Build;
@@ -852,10 +851,8 @@ public class ContentViewCore
}
public int getBackgroundColor() {
- if (mNativeContentViewCore != 0) {
- return nativeGetBackgroundColor(mNativeContentViewCore);
- }
- return Color.WHITE;
+ assert mWebContents != null;
+ return mWebContents.getBackgroundColor();
}
@CalledByNative
@@ -923,16 +920,16 @@ public class ContentViewCore
@VisibleForTesting
public void showInterstitialPage(
String url, InterstitialPageDelegateAndroid delegate) {
- if (mNativeContentViewCore == 0) return;
- nativeShowInterstitialPage(mNativeContentViewCore, url, delegate.getNative());
+ assert mWebContents != null;
+ mWebContents.showInterstitialPage(url, delegate.getNative());
}
/**
* @return Whether the page is currently showing an interstitial, such as a bad HTTPS page.
*/
public boolean isShowingInterstitialPage() {
- return mNativeContentViewCore == 0 ?
- false : nativeIsShowingInterstitialPage(mNativeContentViewCore);
+ assert mWebContents != null;
+ return mWebContents.isShowingInterstitialPage();
}
/**
@@ -1358,7 +1355,8 @@ public class ContentViewCore
* main frame's document.
*/
void addStyleSheetByURL(String url) {
- nativeAddStyleSheetByURL(mNativeContentViewCore, url);
+ assert mWebContents != null;
+ mWebContents.addStyleSheetByURL(url);
}
/** Callback interface for evaluateJavaScript(). */
@@ -1397,8 +1395,8 @@ public class ContentViewCore
* To be called when the ContentView is shown.
*/
public void onShow() {
- assert mNativeContentViewCore != 0;
- nativeOnShow(mNativeContentViewCore);
+ assert mWebContents != null;
+ mWebContents.onShow();
setAccessibilityState(mAccessibilityManager.isEnabled());
}
@@ -1414,10 +1412,10 @@ public class ContentViewCore
* To be called when the ContentView is hidden.
*/
public void onHide() {
- assert mNativeContentViewCore != 0;
+ assert mWebContents != null;
hidePopups();
setInjectedAccessibility(false);
- nativeOnHide(mNativeContentViewCore);
+ mWebContents.onHide();
}
/**
@@ -1525,12 +1523,10 @@ public class ContentViewCore
@SuppressWarnings("javadoc")
public void onConfigurationChanged(Configuration newConfig) {
TraceEvent.begin();
-
+ assert mWebContents != null;
if (newConfig.keyboard != Configuration.KEYBOARD_NOKEYS) {
- if (mNativeContentViewCore != 0) {
- mImeAdapter.attach(nativeGetNativeImeAdapter(mNativeContentViewCore),
- ImeAdapter.getTextInputTypeNone());
- }
+ mImeAdapter.attach(mWebContents.getNativeImeAdapter(),
+ ImeAdapter.getTextInputTypeNone());
mInputMethodManagerWrapper.restartInput(mContainerView);
}
mContainerViewInternals.super_onConfigurationChanged(newConfig);
@@ -1611,11 +1607,11 @@ public class ContentViewCore
}
private void scrollFocusedEditableNodeIntoView() {
- if (mNativeContentViewCore == 0) return;
+ assert mWebContents != null;
// The native side keeps track of whether the zoom and scroll actually occurred. It is
Yaron 2014/07/15 21:23:48 This comment doesn't make sense here. Move to WebC
AKVT 2014/07/16 09:53:47 Done.
// more efficient to do it this way and sometimes fire an unnecessary message rather
// than synchronize with the renderer and always have an additional message.
- nativeScrollFocusedEditableNodeIntoView(mNativeContentViewCore);
+ mWebContents.scrollFocusedEditableNodeIntoView();
}
/**
@@ -1623,8 +1619,8 @@ public class ContentViewCore
* The caller can check if selection actually occurred by listening to OnSelectionChanged.
*/
public void selectWordAroundCaret() {
- if (mNativeContentViewCore == 0) return;
- nativeSelectWordAroundCaret(mNativeContentViewCore);
+ assert mWebContents != null;
+ mWebContents.selectWordAroundCaret();
}
/**
@@ -2187,10 +2183,8 @@ public class ContentViewCore
}
public boolean getUseDesktopUserAgent() {
- if (mNativeContentViewCore != 0) {
- return nativeGetUseDesktopUserAgent(mNativeContentViewCore);
- }
- return false;
+ assert mWebContents != null;
+ return mWebContents.getUseDesktopUserAgent();
}
/**
@@ -2199,13 +2193,13 @@ public class ContentViewCore
* @param reloadOnChange Reload the page if the UA has changed.
*/
public void setUseDesktopUserAgent(boolean override, boolean reloadOnChange) {
- if (mNativeContentViewCore != 0) {
- nativeSetUseDesktopUserAgent(mNativeContentViewCore, override, reloadOnChange);
- }
+ assert mWebContents != null;
+ mWebContents.setUseDesktopUserAgent(override, reloadOnChange);
}
public void clearSslPreferences() {
- if (mNativeContentViewCore != 0) nativeClearSslPreferences(mNativeContentViewCore);
+ assert mWebContents != null;
+ mWebContents.clearSslPreferences();
}
private boolean isSelectionHandleShowing() {
@@ -2267,7 +2261,8 @@ public class ContentViewCore
* Shows the IME if the focused widget could accept text input.
*/
public void showImeIfNeeded() {
- if (mNativeContentViewCore != 0) nativeShowImeIfNeeded(mNativeContentViewCore);
+ assert mWebContents != null;
+ mWebContents.showImeIfNeeded();
}
/**
@@ -2560,8 +2555,9 @@ public class ContentViewCore
* Attaches the native ImeAdapter object to the java ImeAdapter to allow communication via JNI.
*/
public void attachImeAdapter() {
- if (mImeAdapter != null && mNativeContentViewCore != 0) {
- mImeAdapter.attach(nativeGetNativeImeAdapter(mNativeContentViewCore));
+ assert mWebContents != null;
+ if (mImeAdapter != null) {
+ mImeAdapter.attach(mWebContents.getNativeImeAdapter());
}
}
@@ -2784,8 +2780,8 @@ public class ContentViewCore
* once the texture is actually ready.
*/
public boolean isReady() {
- if (mNativeContentViewCore == 0) return false;
- return nativeIsRenderWidgetHostViewReady(mNativeContentViewCore);
+ assert mWebContents != null;
+ return mWebContents.isReady();
}
@CalledByNative
@@ -3004,7 +3000,8 @@ public class ContentViewCore
* Inform WebKit that Fullscreen mode has been exited by the user.
*/
public void exitFullscreen() {
- if (mNativeContentViewCore != 0) nativeExitFullscreen(mNativeContentViewCore);
+ assert mWebContents != null;
+ mWebContents.exitFullscreen();
}
/**
@@ -3016,10 +3013,9 @@ public class ContentViewCore
*/
public void updateTopControlsState(boolean enableHiding, boolean enableShowing,
boolean animate) {
- if (mNativeContentViewCore != 0) {
- nativeUpdateTopControlsState(
- mNativeContentViewCore, enableHiding, enableShowing, animate);
- }
+ assert mWebContents != null;
+ mWebContents.updateTopControlsState(
+ enableHiding, enableShowing, animate);
}
/**
@@ -3060,10 +3056,8 @@ public class ContentViewCore
* current entry.
*/
public String getOriginalUrlForActiveNavigationEntry() {
- if (mNativeContentViewCore != 0) {
- return nativeGetOriginalUrlForActiveNavigationEntry(mNativeContentViewCore);
- }
- return "";
+ assert mWebContents != null;
+ return mWebContents.getOriginalUrlForActiveNavigationEntry();
}
/**
@@ -3079,9 +3073,8 @@ public class ContentViewCore
}
public void extractSmartClipData(int x, int y, int width, int height) {
- if (mNativeContentViewCore != 0) {
- nativeExtractSmartClipData(mNativeContentViewCore, x, y, width, height);
- }
+ assert mWebContents != null;
+ mWebContents.extractSmartClipData(x, y, width, height);
}
@CalledByNative
@@ -3217,10 +3210,6 @@ public class ContentViewCore
private native String nativeGetURL(long nativeContentViewCoreImpl);
- private native void nativeShowInterstitialPage(
- long nativeContentViewCoreImpl, String url, long nativeInterstitialPageDelegateAndroid);
- private native boolean nativeIsShowingInterstitialPage(long nativeContentViewCoreImpl);
-
private native boolean nativeIsIncognito(long nativeContentViewCoreImpl);
private native void nativeSetFocus(long nativeContentViewCoreImpl, boolean focused);
@@ -3289,33 +3278,13 @@ public class ContentViewCore
private native void nativeSelectPopupMenuItems(long nativeContentViewCoreImpl, int[] indices);
- private native void nativeScrollFocusedEditableNodeIntoView(long nativeContentViewCoreImpl);
-
- private native void nativeSelectWordAroundCaret(long nativeContentViewCoreImpl);
-
private native void nativeClearHistory(long nativeContentViewCoreImpl);
- private native void nativeAddStyleSheetByURL(long nativeContentViewCoreImpl,
- String stylesheetUrl);
-
private native void nativeEvaluateJavaScript(long nativeContentViewCoreImpl,
String script, JavaScriptCallback callback, boolean startRenderer);
- private native long nativeGetNativeImeAdapter(long nativeContentViewCoreImpl);
-
private native int nativeGetCurrentRenderProcessId(long nativeContentViewCoreImpl);
- private native int nativeGetBackgroundColor(long nativeContentViewCoreImpl);
-
- private native void nativeOnShow(long nativeContentViewCoreImpl);
- private native void nativeOnHide(long nativeContentViewCoreImpl);
-
- private native void nativeSetUseDesktopUserAgent(long nativeContentViewCoreImpl,
- boolean enabled, boolean reloadOnChange);
- private native boolean nativeGetUseDesktopUserAgent(long nativeContentViewCoreImpl);
-
- private native void nativeClearSslPreferences(long nativeContentViewCoreImpl);
-
private native void nativeSetAllowJavascriptInterfacesInspection(
long nativeContentViewCoreImpl, boolean allow);
@@ -3328,24 +3297,12 @@ public class ContentViewCore
private native int nativeGetNavigationHistory(long nativeContentViewCoreImpl, Object context);
private native void nativeGetDirectedNavigationHistory(long nativeContentViewCoreImpl,
Object context, boolean isForward, int maxEntries);
- private native String nativeGetOriginalUrlForActiveNavigationEntry(
- long nativeContentViewCoreImpl);
private native void nativeWasResized(long nativeContentViewCoreImpl);
- private native boolean nativeIsRenderWidgetHostViewReady(long nativeContentViewCoreImpl);
-
- private native void nativeExitFullscreen(long nativeContentViewCoreImpl);
- private native void nativeUpdateTopControlsState(long nativeContentViewCoreImpl,
- boolean enableHiding, boolean enableShowing, boolean animate);
-
- private native void nativeShowImeIfNeeded(long nativeContentViewCoreImpl);
-
private native void nativeSetAccessibilityEnabled(
long nativeContentViewCoreImpl, boolean enabled);
- private native void nativeExtractSmartClipData(long nativeContentViewCoreImpl,
- int x, int y, int w, int h);
private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl, boolean opaque);
private native void nativeResumeResponseDeferredAtStart(

Powered by Google App Engine
This is Rietveld 408576698