summaryrefslogtreecommitdiffstats
path: root/android_webview/java
diff options
context:
space:
mode:
authorboliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-18 19:46:06 +0000
committerboliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-18 19:46:06 +0000
commit68fe93fbd2d0e61f9f4dd7fd6eedf1ebc3892a86 (patch)
treeb115890d0afa1c3d83f1d2c1c5d78dcd47c253b7 /android_webview/java
parentdd5f30594f088496a7db81d05c6cd17dff6e4611 (diff)
downloadchromium_src-68fe93fbd2d0e61f9f4dd7fd6eedf1ebc3892a86.zip
chromium_src-68fe93fbd2d0e61f9f4dd7fd6eedf1ebc3892a86.tar.gz
chromium_src-68fe93fbd2d0e61f9f4dd7fd6eedf1ebc3892a86.tar.bz2
[Android WebView] Check all usage of mNativeAwContents
mNativeAwContents will be 0 after destroy is called. Also mNativeAwContents being 0 does not imply _native_ AwContents is destroyed, ie @CalledByNative methods can still be called. So check and early out on all usage of mNativeAwContents. Java only Android WebView change. BUG=275195 NOTRY=true Review URL: https://chromiumcodereview.appspot.com/22807010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@218204 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview/java')
-rw-r--r--android_webview/java/src/org/chromium/android_webview/AwContents.java17
1 files changed, 15 insertions, 2 deletions
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java
index 1e7f88d..3cff1b8 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -351,6 +351,7 @@ public class AwContents {
implements ContentViewCore.UpdateFrameInfoListener {
@Override
public void onFrameInfoUpdated(float widthCss, float heightCss, float pageScaleFactor) {
+ if (mNativeAwContents == 0) return;
int widthPix = (int) Math.floor(widthCss * mDIPScale * pageScaleFactor);
int heightPix = (int) Math.floor(heightCss * mDIPScale * pageScaleFactor);
mScrollOffsetManager.setContentSize(widthPix, heightPix);
@@ -375,6 +376,7 @@ public class AwContents {
@Override
public void scrollNativeTo(int x, int y) {
+ if (mNativeAwContents == 0) return;
nativeScrollTo(mNativeAwContents, x, y);
}
@@ -660,6 +662,10 @@ public class AwContents {
}
public int getAwDrawGLViewContext() {
+ // Only called during early construction, so client should not have had a chance to
+ // call destroy yet.
+ assert mNativeAwContents != 0;
+
// Using the native pointer as the returned viewContext. This is matched by the
// reinterpret_cast back to BrowserViewRenderer pointer in the native DrawGLFunction.
return nativeGetAwDrawGLViewContext(mNativeAwContents);
@@ -671,6 +677,7 @@ public class AwContents {
@CalledByNative
private void updateGlobalVisibleRect() {
+ if (mNativeAwContents == 0) return;
if (!mContainerView.getGlobalVisibleRect(sLocalGlobalVisibleRect)) {
sLocalGlobalVisibleRect.setEmpty();
}
@@ -724,6 +731,7 @@ public class AwContents {
}
public Picture capturePicture() {
+ if (mNativeAwContents == 0) return null;
return new AwPicture(nativeCapturePicture(mNativeAwContents,
mScrollOffsetManager.computeHorizontalScrollRange(),
mScrollOffsetManager.computeVerticalScrollRange()));
@@ -735,6 +743,7 @@ public class AwContents {
* @param invalidationOnly Flag to call back only on invalidation without providing a picture.
*/
public void enableOnNewPicture(boolean enabled, boolean invalidationOnly) {
+ if (mNativeAwContents == 0) return;
if (invalidationOnly) {
mPictureListenerContentProvider = null;
} else if (enabled && mPictureListenerContentProvider == null) {
@@ -853,6 +862,7 @@ public class AwContents {
}
public void requestFocus() {
+ if (mNativeAwContents == 0) return;
if (!mContainerView.isInTouchMode() && mSettings.shouldFocusFirstNode()) {
nativeFocusFirstNode(mNativeAwContents);
}
@@ -1409,6 +1419,7 @@ public class AwContents {
* Note that this is also called from receivePopupContents.
*/
public void onAttachedToWindow() {
+ if (mNativeAwContents == 0) return;
mIsAttachedToWindow = true;
mContentViewCore.onAttachedToWindow();
@@ -1511,7 +1522,7 @@ public class AwContents {
* @return False if saving state failed.
*/
public boolean saveState(Bundle outState) {
- if (outState == null) return false;
+ if (mNativeAwContents == 0 || outState == null) return false;
byte[] state = nativeGetOpaqueState(mNativeAwContents);
if (state == null) return false;
@@ -1526,7 +1537,7 @@ public class AwContents {
* @return False if restoring state failed.
*/
public boolean restoreState(Bundle inState) {
- if (inState == null) return false;
+ if (mNativeAwContents == 0 || inState == null) return false;
byte[] state = inState.getByteArray(SAVE_RESTORE_STATE_KEY);
if (state == null) return false;
@@ -1648,6 +1659,7 @@ public class AwContents {
mBrowserContext.getGeolocationPermissions().deny(origin);
}
}
+ if (mNativeAwContents == 0) return;
nativeInvokeGeolocationCallback(mNativeAwContents, allow, origin);
}
});
@@ -1656,6 +1668,7 @@ public class AwContents {
@CalledByNative
private void onGeolocationPermissionsShowPrompt(String origin) {
+ if (mNativeAwContents == 0) return;
AwGeolocationPermissions permissions = mBrowserContext.getGeolocationPermissions();
// Reject if geoloaction is disabled, or the origin has a retained deny
if (!mSettings.getGeolocationEnabled()) {