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

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwContents.java

Issue 2630473004: Implement Crash Handle API (Closed)
Patch Set: use LOG(FATAL) Created 3 years, 11 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: android_webview/java/src/org/chromium/android_webview/AwContents.java
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 abebba74d0243ed09f218e36d21cdf6229ec8205..db6cc79e415db0b923c3c7db383f80fb99dfc8c4 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -359,6 +359,10 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
// Do not use directly, call isDestroyed() instead.
private boolean mIsDestroyed;
+ // True if this AwContents is in no operation state.
+ // Do not use directly, call isNoOperation() instead.
+ private boolean mIsNoOperation;
+
private static String sCurrentLocales = "";
private static final class AwContentsDestroyRunnable implements Runnable {
@@ -580,13 +584,14 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
@Override
public void scrollNativeTo(int x, int y) {
- if (!isDestroyed(NO_WARN)) nativeScrollTo(mNativeAwContents, x, y);
+ if (!isDestroyedOrNoOperation(NO_WARN)) nativeScrollTo(mNativeAwContents, x, y);
}
@Override
public void smoothScroll(int targetX, int targetY, long durationMs) {
- if (!isDestroyed(NO_WARN)) nativeSmoothScroll(
- mNativeAwContents, targetX, targetY, durationMs);
+ if (!isDestroyedOrNoOperation(NO_WARN)) {
+ nativeSmoothScroll(mNativeAwContents, targetX, targetY, durationMs);
+ }
}
@Override
@@ -659,7 +664,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
- if (isDestroyed(NO_WARN)) return;
+ if (isDestroyedOrNoOperation(NO_WARN)) return;
if (level >= TRIM_MEMORY_MODERATE) {
mInitialFunctor.deleteHardwareRenderer();
if (mFullScreenFunctor != null) {
@@ -750,7 +755,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
new AwContentsClientCallbackHelper.CancelCallbackPoller() {
@Override
public boolean cancelAllCallbacks() {
- return AwContents.this.isDestroyed(NO_WARN);
+ return AwContents.this.isDestroyedOrNoOperation(NO_WARN);
}
});
mAwViewMethods = new AwViewMethodsImpl();
@@ -781,7 +786,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
@Override
public void onGestureZoomSupportChanged(
boolean supportsDoubleTapZoom, boolean supportsMultiTouchZoom) {
- if (isDestroyed(NO_WARN)) return;
+ if (isDestroyedOrNoOperation(NO_WARN)) return;
mContentViewCore.updateDoubleTapSupport(supportsDoubleTapZoom);
mContentViewCore.updateMultiTouchZoomSupport(supportsMultiTouchZoom);
}
@@ -827,7 +832,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
View enterFullScreen() {
assert !isFullScreen();
- if (isDestroyed(NO_WARN)) return null;
+ if (isDestroyedOrNoOperation(NO_WARN)) return null;
// Detach to tear down the GL functor if this is still associated with the old
// container view. It will be recreated during the next call to onDraw attached to
@@ -858,7 +863,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
* Called when the app has requested to exit fullscreen.
*/
void requestExitFullscreen() {
- if (!isDestroyed(NO_WARN)) mContentViewCore.getWebContents().exitFullscreen();
+ if (!isDestroyedOrNoOperation(NO_WARN)) mContentViewCore.getWebContents().exitFullscreen();
}
/**
@@ -866,7 +871,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
* in the WebView.
*/
void exitFullScreen() {
- if (!isFullScreen() || isDestroyed(NO_WARN)) {
+ if (!isFullScreen() || isDestroyedOrNoOperation(NO_WARN)) {
// exitFullScreen() can be called without a prior call to enterFullScreen() if a
// "misbehave" app overrides onShowCustomView but does not add the custom view to
// the window. Exiting avoids a crash.
@@ -1084,7 +1089,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
* provide the AwContents to host the pop up content.
*/
public void supplyContentsForPopup(AwContents newContents) {
- if (isDestroyed(WARN)) return;
+ if (isDestroyedOrNoOperation(WARN)) return;
long popupNativeAwContents = nativeReleasePopupAwContents(mNativeAwContents);
if (popupNativeAwContents == 0) {
Log.w(TAG, "Popup WebView bind failed: no pending content.");
@@ -1102,7 +1107,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
// Recap: supplyContentsForPopup() is called on the parent window's content, this method is
// called on the popup window's content.
private void receivePopupContents(long popupNativeAwContents) {
- if (isDestroyed(WARN)) return;
+ if (isDestroyedOrNoOperation(WARN)) return;
mDeferredShouldOverrideUrlLoadingIsPendingForPopup = true;
// Save existing view state.
final boolean wasAttached = mIsAttachedToWindow;
@@ -1157,6 +1162,30 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
}
}
+ @CalledByNative
+ private void onRenderProcessGone(int childProcessID) {
+ // This is the first callback we got for render process gone, we can't destroy the WebView
+ // now because we need to get next callback onRenderProcessGoneWithDetail() to know whether
+ // render process crashed or was killed.
+ // However, we should make WebView no operation to avoid being in weird states.
+ // TODO: We might be able to combine destroyed and no operation states.
+ mIsNoOperation = true;
+ }
+
+ @CalledByNative
+ private boolean onRenderProcessGoneDetail(int childProcessID, boolean crashed) {
+ if (isDestroyed(NO_WARN)) return false;
+ return mContentsClient.onRenderProcessGone(new AwRenderProcessGoneDetail(crashed));
+ }
+
+ private boolean isNoOperation() {
+ return mIsNoOperation;
+ }
+
+ private boolean isDestroyedOrNoOperation(int warnIfDestroyed) {
+ return isDestroyed(warnIfDestroyed) || isNoOperation();
+ }
+
/**
* Destroys this object and deletes its native counterpart.
*/
@@ -1177,6 +1206,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
// Need to call detach to avoid leaks because the real detach later will be ignored.
onDetachedFromWindow();
}
+ mIsNoOperation = true;
mIsDestroyed = true;
mHandler.post(new Runnable() {
@Override
@@ -1255,7 +1285,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
}
public AwPdfExporter getPdfExporter() {
- if (isDestroyed(WARN)) return null;
+ if (isDestroyedOrNoOperation(WARN)) return null;
if (mAwPdfExporter == null) {
mAwPdfExporter = new AwPdfExporter(mContainerView);
nativeCreatePdfExporter(mNativeAwContents, mAwPdfExporter);
@@ -1291,7 +1321,9 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
* to ensure backwards compatible behavior.
*/
public void disableJavascriptInterfacesInspection() {
- if (!isDestroyed(WARN)) mContentViewCore.setAllowJavascriptInterfacesInspection(false);
+ if (!isDestroyedOrNoOperation(WARN)) {
+ mContentViewCore.setAllowJavascriptInterfacesInspection(false);
+ }
}
/**
@@ -1336,18 +1368,18 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
}
public int getContentHeightCss() {
- if (isDestroyed(WARN)) return 0;
+ if (isDestroyedOrNoOperation(WARN)) return 0;
return (int) Math.ceil(mContentHeightDip);
}
public int getContentWidthCss() {
- if (isDestroyed(WARN)) return 0;
+ if (isDestroyedOrNoOperation(WARN)) return 0;
return (int) Math.ceil(mContentWidthDip);
}
public Picture capturePicture() {
if (TRACE) Log.i(TAG, "%s capturePicture", this);
- if (isDestroyed(WARN)) return null;
+ if (isDestroyedOrNoOperation(WARN)) return null;
return new AwPicture(nativeCapturePicture(mNativeAwContents,
mScrollOffsetManager.computeHorizontalScrollRange(),
mScrollOffsetManager.computeVerticalScrollRange()));
@@ -1355,7 +1387,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
public void clearView() {
if (TRACE) Log.i(TAG, "%s clearView", this);
- if (!isDestroyed(WARN)) nativeClearView(mNativeAwContents);
+ if (!isDestroyedOrNoOperation(WARN)) nativeClearView(mNativeAwContents);
}
/**
@@ -1365,7 +1397,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public void enableOnNewPicture(boolean enabled, boolean invalidationOnly) {
if (TRACE) Log.i(TAG, "%s enableOnNewPicture=%s", this, enabled);
- if (isDestroyed(WARN)) return;
+ if (isDestroyedOrNoOperation(WARN)) return;
if (invalidationOnly) {
mPictureListenerContentProvider = null;
} else if (enabled && mPictureListenerContentProvider == null) {
@@ -1381,30 +1413,30 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
public void findAllAsync(String searchString) {
if (TRACE) Log.i(TAG, "%s findAllAsync", this);
- if (!isDestroyed(WARN)) nativeFindAllAsync(mNativeAwContents, searchString);
+ if (!isDestroyedOrNoOperation(WARN)) nativeFindAllAsync(mNativeAwContents, searchString);
}
public void findNext(boolean forward) {
if (TRACE) Log.i(TAG, "%s findNext", this);
- if (!isDestroyed(WARN)) nativeFindNext(mNativeAwContents, forward);
+ if (!isDestroyedOrNoOperation(WARN)) nativeFindNext(mNativeAwContents, forward);
}
public void clearMatches() {
if (TRACE) Log.i(TAG, "%s clearMatches", this);
- if (!isDestroyed(WARN)) nativeClearMatches(mNativeAwContents);
+ if (!isDestroyedOrNoOperation(WARN)) nativeClearMatches(mNativeAwContents);
}
/**
* @return load progress of the WebContents.
*/
public int getMostRecentProgress() {
- if (isDestroyed(WARN)) return 0;
+ if (isDestroyedOrNoOperation(WARN)) return 0;
// WebContentsDelegateAndroid conveniently caches the most recent notified value for us.
return mWebContentsDelegate.getMostRecentProgress();
}
public Bitmap getFavicon() {
- if (isDestroyed(WARN)) return null;
+ if (isDestroyedOrNoOperation(WARN)) return null;
return mFavicon;
}
@@ -1423,7 +1455,9 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
- if (!isDestroyed(NO_WARN)) nativeAddVisitedLinks(mNativeAwContents, value);
+ if (!isDestroyedOrNoOperation(NO_WARN)) {
+ nativeAddVisitedLinks(mNativeAwContents, value);
+ }
}
});
}
@@ -1436,7 +1470,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public void loadUrl(String url, Map<String, String> additionalHttpHeaders) {
if (TRACE) Log.i(TAG, "%s loadUrl(extra headers)=%s", this, url);
- if (isDestroyed(WARN)) return;
+ if (isDestroyedOrNoOperation(WARN)) return;
// TODO: We may actually want to do some sanity checks here (like filter about://chrome).
// For backwards compatibility, apps targeting less than K will have JS URLs evaluated
@@ -1462,7 +1496,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public void loadUrl(String url) {
if (TRACE) Log.i(TAG, "%s loadUrl=%s", this, url);
- if (isDestroyed(WARN)) return;
+ if (isDestroyedOrNoOperation(WARN)) return;
// Early out to match old WebView implementation
if (url == null) {
return;
@@ -1475,7 +1509,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public void postUrl(String url, byte[] postData) {
if (TRACE) Log.i(TAG, "%s postUrl=%s", this, url);
- if (isDestroyed(WARN)) return;
+ if (isDestroyedOrNoOperation(WARN)) return;
LoadUrlParams params = LoadUrlParams.createLoadHttpPostParams(url, postData);
Map<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/x-www-form-urlencoded");
@@ -1508,7 +1542,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public void loadData(String data, String mimeType, String encoding) {
if (TRACE) Log.i(TAG, "%s loadData", this);
- if (isDestroyed(WARN)) return;
+ if (isDestroyedOrNoOperation(WARN)) return;
loadUrl(LoadUrlParams.createLoadDataParams(
fixupData(data), fixupMimeType(mimeType), isBase64Encoded(encoding)));
}
@@ -1519,7 +1553,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
public void loadDataWithBaseURL(
String baseUrl, String data, String mimeType, String encoding, String historyUrl) {
if (TRACE) Log.i(TAG, "%s loadDataWithBaseURL=%s", this, baseUrl);
- if (isDestroyed(WARN)) return;
+ if (isDestroyedOrNoOperation(WARN)) return;
data = fixupData(data);
mimeType = fixupMimeType(mimeType);
@@ -1625,7 +1659,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
* @return The URL of the current page or null if it's empty.
*/
public String getUrl() {
- if (isDestroyed(WARN)) return null;
+ if (isDestroyedOrNoOperation(WARN)) return null;
String url = mWebContents.getUrl();
if (url == null || url.trim().isEmpty()) return null;
return url;
@@ -1638,7 +1672,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
* @return The URL of the current page or null if it's empty.
*/
public String getLastCommittedUrl() {
- if (isDestroyed(NO_WARN)) return null;
+ if (isDestroyedOrNoOperation(NO_WARN)) return null;
String url = mWebContents.getLastCommittedUrl();
if (url == null || url.trim().isEmpty()) return null;
return url;
@@ -1650,7 +1684,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
public void setBackgroundColor(int color) {
mBaseBackgroundColor = color;
- if (!isDestroyed(WARN)) nativeSetBackgroundColor(mNativeAwContents, color);
+ if (!isDestroyedOrNoOperation(WARN)) nativeSetBackgroundColor(mNativeAwContents, color);
}
/**
@@ -1664,7 +1698,8 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
// Do not ask the ContentViewCore for the background color, as it will always
// report white prior to initial navigation or post destruction, whereas we want
// to use the client supplied base value in those cases.
- if (isDestroyed(NO_WARN) || !mContentsClient.isCachedRendererBackgroundColorValid()) {
+ if (isDestroyedOrNoOperation(NO_WARN)
+ || !mContentsClient.isCachedRendererBackgroundColorValid()) {
return mBaseBackgroundColor;
}
return mContentsClient.getCachedRendererBackgroundColor();
@@ -1760,7 +1795,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
* @see android.webkit.WebView#requestChildRectangleOnScreen(View, Rect, boolean)
*/
public boolean requestChildRectangleOnScreen(View child, Rect rect, boolean immediate) {
- if (isDestroyed(WARN)) return false;
+ if (isDestroyedOrNoOperation(WARN)) return false;
return mScrollOffsetManager.requestChildRectangleOnScreen(
child.getLeft() - child.getScrollX(), child.getTop() - child.getScrollY(),
rect, immediate);
@@ -1813,7 +1848,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public void stopLoading() {
if (TRACE) Log.i(TAG, "%s stopLoading", this);
- if (!isDestroyed(WARN)) mWebContents.stop();
+ if (!isDestroyedOrNoOperation(WARN)) mWebContents.stop();
}
/**
@@ -1821,14 +1856,14 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public void reload() {
if (TRACE) Log.i(TAG, "%s reload", this);
- if (!isDestroyed(WARN)) mNavigationController.reload(true);
+ if (!isDestroyedOrNoOperation(WARN)) mNavigationController.reload(true);
}
/**
* @see android.webkit.WebView#canGoBack()
*/
public boolean canGoBack() {
- return isDestroyed(WARN) ? false : mNavigationController.canGoBack();
+ return isDestroyedOrNoOperation(WARN) ? false : mNavigationController.canGoBack();
}
/**
@@ -1836,14 +1871,14 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public void goBack() {
if (TRACE) Log.i(TAG, "%s goBack", this);
- if (!isDestroyed(WARN)) mNavigationController.goBack();
+ if (!isDestroyedOrNoOperation(WARN)) mNavigationController.goBack();
}
/**
* @see android.webkit.WebView#canGoForward()
*/
public boolean canGoForward() {
- return isDestroyed(WARN) ? false : mNavigationController.canGoForward();
+ return isDestroyedOrNoOperation(WARN) ? false : mNavigationController.canGoForward();
}
/**
@@ -1851,14 +1886,14 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public void goForward() {
if (TRACE) Log.i(TAG, "%s goForward", this);
- if (!isDestroyed(WARN)) mNavigationController.goForward();
+ if (!isDestroyedOrNoOperation(WARN)) mNavigationController.goForward();
}
/**
* @see android.webkit.WebView#canGoBackOrForward(int)
*/
public boolean canGoBackOrForward(int steps) {
- return isDestroyed(WARN) ? false : mNavigationController.canGoToOffset(steps);
+ return isDestroyedOrNoOperation(WARN) ? false : mNavigationController.canGoToOffset(steps);
}
/**
@@ -1866,7 +1901,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public void goBackOrForward(int steps) {
if (TRACE) Log.i(TAG, "%s goBackOrForwad=%d", this, steps);
- if (!isDestroyed(WARN)) mNavigationController.goToOffset(steps);
+ if (!isDestroyedOrNoOperation(WARN)) mNavigationController.goToOffset(steps);
}
/**
@@ -1874,7 +1909,9 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public void pauseTimers() {
if (TRACE) Log.i(TAG, "%s pauseTimers", this);
- if (!isDestroyed(WARN)) ContentViewStatics.setWebKitSharedTimersSuspended(true);
+ if (!isDestroyedOrNoOperation(WARN)) {
+ ContentViewStatics.setWebKitSharedTimersSuspended(true);
+ }
}
/**
@@ -1882,7 +1919,9 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public void resumeTimers() {
if (TRACE) Log.i(TAG, "%s resumeTimers", this);
- if (!isDestroyed(WARN)) ContentViewStatics.setWebKitSharedTimersSuspended(false);
+ if (!isDestroyedOrNoOperation(WARN)) {
+ ContentViewStatics.setWebKitSharedTimersSuspended(false);
+ }
}
/**
@@ -1890,7 +1929,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public void onPause() {
if (TRACE) Log.i(TAG, "%s onPause", this);
- if (mIsPaused || isDestroyed(NO_WARN)) return;
+ if (mIsPaused || isDestroyedOrNoOperation(NO_WARN)) return;
mIsPaused = true;
nativeSetIsPaused(mNativeAwContents, mIsPaused);
@@ -1903,7 +1942,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public void onResume() {
if (TRACE) Log.i(TAG, "%s onResume", this);
- if (!mIsPaused || isDestroyed(NO_WARN)) return;
+ if (!mIsPaused || isDestroyedOrNoOperation(NO_WARN)) return;
mIsPaused = false;
nativeSetIsPaused(mNativeAwContents, mIsPaused);
updateContentViewCoreVisibility();
@@ -1913,7 +1952,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
* @see android.webkit.WebView#isPaused()
*/
public boolean isPaused() {
- return isDestroyed(WARN) ? false : mIsPaused;
+ return isDestroyedOrNoOperation(WARN) ? false : mIsPaused;
}
/**
@@ -1952,11 +1991,11 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public void clearCache(boolean includeDiskFiles) {
if (TRACE) Log.i(TAG, "%s clearCache", this);
- if (!isDestroyed(WARN)) nativeClearCache(mNativeAwContents, includeDiskFiles);
+ if (!isDestroyedOrNoOperation(WARN)) nativeClearCache(mNativeAwContents, includeDiskFiles);
}
public void documentHasImages(Message message) {
- if (!isDestroyed(WARN)) nativeDocumentHasImages(mNativeAwContents, message);
+ if (!isDestroyedOrNoOperation(WARN)) nativeDocumentHasImages(mNativeAwContents, message);
}
public void saveWebArchive(
@@ -1982,7 +2021,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
}
public String getOriginalUrl() {
- if (isDestroyed(WARN)) return null;
+ if (isDestroyedOrNoOperation(WARN)) return null;
NavigationHistory history = mNavigationController.getNavigationHistory();
int currentIndex = history.getCurrentEntryIndex();
if (currentIndex >= 0 && currentIndex < history.getEntryCount()) {
@@ -1995,14 +2034,14 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
* @see ContentViewCore#getNavigationHistory()
*/
public NavigationHistory getNavigationHistory() {
- return isDestroyed(WARN) ? null : mNavigationController.getNavigationHistory();
+ return isDestroyedOrNoOperation(WARN) ? null : mNavigationController.getNavigationHistory();
}
/**
* @see android.webkit.WebView#getTitle()
*/
public String getTitle() {
- return isDestroyed(WARN) ? null : mWebContents.getTitle();
+ return isDestroyedOrNoOperation(WARN) ? null : mWebContents.getTitle();
}
/**
@@ -2010,14 +2049,14 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public void clearHistory() {
if (TRACE) Log.i(TAG, "%s clearHistory", this);
- if (!isDestroyed(WARN)) mNavigationController.clearHistory();
+ if (!isDestroyedOrNoOperation(WARN)) mNavigationController.clearHistory();
}
/**
* @see android.webkit.WebView#getCertificate()
*/
public SslCertificate getCertificate() {
- return isDestroyed(WARN) ? null
+ return isDestroyedOrNoOperation(WARN) ? null
: SslUtil.getCertificateFromDerBytes(nativeGetCertificate(mNativeAwContents));
}
@@ -2026,7 +2065,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public void clearSslPreferences() {
if (TRACE) Log.i(TAG, "%s clearSslPreferences", this);
- if (!isDestroyed(WARN)) mNavigationController.clearSslPreferences();
+ if (!isDestroyedOrNoOperation(WARN)) mNavigationController.clearSslPreferences();
}
/**
@@ -2037,7 +2076,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public HitTestData getLastHitTestResult() {
if (TRACE) Log.i(TAG, "%s getLastHitTestResult", this);
- if (isDestroyed(WARN)) return null;
+ if (isDestroyedOrNoOperation(WARN)) return null;
nativeUpdateLastHitTestData(mNativeAwContents);
return mPossiblyStaleHitTestData;
}
@@ -2047,7 +2086,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public void requestFocusNodeHref(Message msg) {
if (TRACE) Log.i(TAG, "%s requestFocusNodeHref", this);
- if (msg == null || isDestroyed(WARN)) return;
+ if (msg == null || isDestroyedOrNoOperation(WARN)) return;
nativeUpdateLastHitTestData(mNativeAwContents);
Bundle data = msg.getData();
@@ -2067,7 +2106,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public void requestImageRef(Message msg) {
if (TRACE) Log.i(TAG, "%s requestImageRef", this);
- if (msg == null || isDestroyed(WARN)) return;
+ if (msg == null || isDestroyedOrNoOperation(WARN)) return;
nativeUpdateLastHitTestData(mNativeAwContents);
Bundle data = msg.getData();
@@ -2088,7 +2127,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
* the screen density factor. See CTS WebViewTest.testSetInitialScale.
*/
public float getScale() {
- if (isDestroyed(WARN)) return 1;
+ if (isDestroyedOrNoOperation(WARN)) return 1;
return mPageScaleFactor * mContentViewCore.getDeviceScaleFactor();
}
@@ -2097,7 +2136,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public void flingScroll(int velocityX, int velocityY) {
if (TRACE) Log.i(TAG, "%s flingScroll", this);
- if (isDestroyed(WARN)) return;
+ if (isDestroyedOrNoOperation(WARN)) return;
mContentViewCore.flingViewport(SystemClock.uptimeMillis(), -velocityX, -velocityY);
}
@@ -2106,7 +2145,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public boolean pageUp(boolean top) {
if (TRACE) Log.i(TAG, "%s pageUp", this);
- if (isDestroyed(WARN)) return false;
+ if (isDestroyedOrNoOperation(WARN)) return false;
return mScrollOffsetManager.pageUp(top);
}
@@ -2115,7 +2154,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public boolean pageDown(boolean bottom) {
if (TRACE) Log.i(TAG, "%s pageDown", this);
- if (isDestroyed(WARN)) return false;
+ if (isDestroyedOrNoOperation(WARN)) return false;
return mScrollOffsetManager.pageDown(bottom);
}
@@ -2125,7 +2164,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
// This method uses the term 'zoom' for legacy reasons, but relates
// to what chrome calls the 'page scale factor'.
public boolean canZoomIn() {
- if (isDestroyed(WARN)) return false;
+ if (isDestroyedOrNoOperation(WARN)) return false;
final float zoomInExtent = mMaxPageScaleFactor - mPageScaleFactor;
return zoomInExtent > ZOOM_CONTROLS_EPSILON;
}
@@ -2136,7 +2175,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
// This method uses the term 'zoom' for legacy reasons, but relates
// to what chrome calls the 'page scale factor'.
public boolean canZoomOut() {
- if (isDestroyed(WARN)) return false;
+ if (isDestroyedOrNoOperation(WARN)) return false;
final float zoomOutExtent = mPageScaleFactor - mMinPageScaleFactor;
return zoomOutExtent > ZOOM_CONTROLS_EPSILON;
}
@@ -2173,7 +2212,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
// This method uses the term 'zoom' for legacy reasons, but relates
// to what chrome calls the 'page scale factor'.
public void zoomBy(float delta) {
- if (isDestroyed(WARN)) return;
+ if (isDestroyedOrNoOperation(WARN)) return;
if (delta < 0.01f || delta > 100.0f) {
throw new IllegalStateException("zoom delta value outside [0.01, 100] range.");
}
@@ -2185,14 +2224,14 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public void invokeZoomPicker() {
if (TRACE) Log.i(TAG, "%s invokeZoomPicker", this);
- if (!isDestroyed(WARN)) mZoomControls.invokeZoomPicker();
+ if (!isDestroyedOrNoOperation(WARN)) mZoomControls.invokeZoomPicker();
}
/**
* @see android.webkit.WebView#preauthorizePermission(Uri, long)
*/
public void preauthorizePermission(Uri origin, long resources) {
- if (isDestroyed(NO_WARN)) return;
+ if (isDestroyedOrNoOperation(NO_WARN)) return;
nativePreauthorizePermission(mNativeAwContents, origin.toString(), resources);
}
@@ -2201,7 +2240,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public void evaluateJavaScript(String script, final ValueCallback<String> callback) {
if (TRACE) Log.i(TAG, "%s evaluateJavascript=%s", this, script);
- if (isDestroyed(WARN)) return;
+ if (isDestroyedOrNoOperation(WARN)) return;
JavaScriptCallback jsCallback = null;
if (callback != null) {
jsCallback = new JavaScriptCallback() {
@@ -2217,7 +2256,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
public void evaluateJavaScriptForTests(String script, final ValueCallback<String> callback) {
if (TRACE) Log.i(TAG, "%s evaluateJavascriptForTests=%s", this, script);
- if (isDestroyed(NO_WARN)) return;
+ if (isDestroyedOrNoOperation(NO_WARN)) return;
JavaScriptCallback jsCallback = null;
if (callback != null) {
jsCallback = new JavaScriptCallback() {
@@ -2243,7 +2282,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public void postMessageToFrame(
String frameName, String message, String targetOrigin, MessagePort[] sentPorts) {
- if (isDestroyed(WARN)) return;
+ if (isDestroyedOrNoOperation(WARN)) return;
if (mPostMessageSender == null) {
AppWebMessagePortService service = mBrowserContext.getMessagePortService();
mPostMessageSender = new PostMessageSender(this, service);
@@ -2268,7 +2307,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
public void postMessageToWeb(String frameName, String message, String targetOrigin,
int[] sentPortIds) {
if (TRACE) Log.i(TAG, "%s postMessageToWeb. TargetOrigin=%s", this, targetOrigin);
- if (isDestroyed(NO_WARN)) return;
+ if (isDestroyedOrNoOperation(NO_WARN)) return;
nativePostMessageToFrame(mNativeAwContents, frameName, message, targetOrigin,
sentPortIds);
}
@@ -2278,20 +2317,20 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public AppWebMessagePort[] createMessageChannel() {
if (TRACE) Log.i(TAG, "%s createMessageChannel", this);
- if (isDestroyed(WARN)) return null;
+ if (isDestroyedOrNoOperation(WARN)) return null;
AppWebMessagePort[] ports = mBrowserContext.getMessagePortService().createMessageChannel();
nativeCreateMessageChannel(mNativeAwContents, ports);
return ports;
}
public boolean hasAccessedInitialDocument() {
- if (isDestroyed(NO_WARN)) return false;
+ if (isDestroyedOrNoOperation(NO_WARN)) return false;
return mWebContents.hasAccessedInitialDocument();
}
@TargetApi(Build.VERSION_CODES.M)
public void onProvideVirtualStructure(ViewStructure structure) {
- if (isDestroyed(WARN)) return;
+ if (isDestroyedOrNoOperation(WARN)) return;
if (!mWebContentsObserver.didEverCommitNavigation()) {
// TODO(sgurun) write a test case for this condition crbug/605251
structure.setChildCount(0);
@@ -2365,7 +2404,8 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
* @see android.view.View#onGenericMotionEvent()
*/
public boolean onGenericMotionEvent(MotionEvent event) {
- return isDestroyed(NO_WARN) ? false : mContentViewCore.onGenericMotionEvent(event);
+ return isDestroyedOrNoOperation(NO_WARN) ? false :
+ mContentViewCore.onGenericMotionEvent(event);
}
/**
@@ -2448,7 +2488,9 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
private void setViewVisibilityInternal(boolean visible) {
mIsViewVisible = visible;
- if (!isDestroyed(NO_WARN)) nativeSetViewVisibility(mNativeAwContents, mIsViewVisible);
+ if (!isDestroyedOrNoOperation(NO_WARN)) {
+ nativeSetViewVisibility(mNativeAwContents, mIsViewVisible);
+ }
updateContentViewCoreVisibility();
}
@@ -2456,7 +2498,9 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
mInvalidateRootViewOnNextDraw |= Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP
&& visible && !mIsWindowVisible;
mIsWindowVisible = visible;
- if (!isDestroyed(NO_WARN)) nativeSetWindowVisibility(mNativeAwContents, mIsWindowVisible);
+ if (!isDestroyedOrNoOperation(NO_WARN)) {
+ nativeSetWindowVisibility(mNativeAwContents, mIsWindowVisible);
+ }
postUpdateContentViewCoreVisibility();
}
@@ -2478,7 +2522,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
private void updateContentViewCoreVisibility() {
mIsUpdateVisibilityTaskPending = false;
- if (isDestroyed(NO_WARN)) return;
+ if (isDestroyedOrNoOperation(NO_WARN)) return;
boolean contentViewCoreVisible = nativeIsVisible(mNativeAwContents);
if (contentViewCoreVisible && !mIsContentViewCoreVisible) {
@@ -2497,7 +2541,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
@VisibleForTesting
public boolean isPageVisible() {
- if (isDestroyed(NO_WARN)) return mIsContentViewCoreVisible;
+ if (isDestroyedOrNoOperation(NO_WARN)) return mIsContentViewCoreVisible;
return nativeIsVisible(mNativeAwContents);
}
@@ -2512,7 +2556,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public boolean saveState(Bundle outState) {
if (TRACE) Log.i(TAG, "%s saveState", this);
- if (isDestroyed(WARN) || outState == null) return false;
+ if (isDestroyedOrNoOperation(WARN) || outState == null) return false;
byte[] state = nativeGetOpaqueState(mNativeAwContents);
if (state == null) return false;
@@ -2528,7 +2572,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public boolean restoreState(Bundle inState) {
if (TRACE) Log.i(TAG, "%s restoreState", this);
- if (isDestroyed(WARN) || inState == null) return false;
+ if (isDestroyedOrNoOperation(WARN) || inState == null) return false;
byte[] state = inState.getByteArray(SAVE_RESTORE_STATE_KEY);
if (state == null) return false;
@@ -2550,7 +2594,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
@SuppressLint("NewApi") // JavascriptInterface requires API level 17.
public void addJavascriptInterface(Object object, String name) {
if (TRACE) Log.i(TAG, "%s addJavascriptInterface=%s", this, name);
- if (isDestroyed(WARN)) return;
+ if (isDestroyedOrNoOperation(WARN)) return;
Class<? extends Annotation> requiredAnnotation = null;
if (mAppTargetSdkVersion >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
requiredAnnotation = JavascriptInterface.class;
@@ -2563,7 +2607,9 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
*/
public void removeJavascriptInterface(String interfaceName) {
if (TRACE) Log.i(TAG, "%s removeJavascriptInterface=%s", this, interfaceName);
- if (!isDestroyed(WARN)) mContentViewCore.removeJavascriptInterface(interfaceName);
+ if (!isDestroyedOrNoOperation(WARN)) {
+ mContentViewCore.removeJavascriptInterface(interfaceName);
+ }
}
/**
@@ -2573,7 +2619,8 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
* @return The AccessibilityNodeProvider, if available, or null otherwise.
*/
public AccessibilityNodeProvider getAccessibilityNodeProvider() {
- return isDestroyed(WARN) ? null : mContentViewCore.getAccessibilityNodeProvider();
+ return isDestroyedOrNoOperation(WARN) ? null
+ : mContentViewCore.getAccessibilityNodeProvider();
}
/**
@@ -2591,14 +2638,15 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
}
public boolean supportsAccessibilityAction(int action) {
- return isDestroyed(WARN) ? false : mContentViewCore.supportsAccessibilityAction(action);
+ return isDestroyedOrNoOperation(WARN) ? false
+ : mContentViewCore.supportsAccessibilityAction(action);
}
/**
* @see android.webkit.WebView#performAccessibilityAction(int, Bundle)
*/
public boolean performAccessibilityAction(int action, Bundle arguments) {
- return isDestroyed(WARN) ? false
+ return isDestroyedOrNoOperation(WARN) ? false
: mContentViewCore.performAccessibilityAction(action, arguments);
}
@@ -2614,7 +2662,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
public void setNetworkAvailable(boolean networkUp) {
if (TRACE) Log.i(TAG, "%s setNetworkAvailable=%s", this, networkUp);
- if (!isDestroyed(WARN)) {
+ if (!isDestroyedOrNoOperation(WARN)) {
// For backward compatibility when an app uses this API disable the
// Network Information API to prevent inconsistencies,
// see crbug.com/520088.
@@ -2697,13 +2745,13 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
}
public void invokeGeolocationCallback(boolean value, String requestingFrame) {
- if (isDestroyed(NO_WARN)) return;
+ if (isDestroyedOrNoOperation(NO_WARN)) return;
nativeInvokeGeolocationCallback(mNativeAwContents, value, requestingFrame);
}
@CalledByNative
private void onGeolocationPermissionsShowPrompt(String origin) {
- if (isDestroyed(NO_WARN)) return;
+ if (isDestroyedOrNoOperation(NO_WARN)) return;
AwGeolocationPermissions permissions = mBrowserContext.getGeolocationPermissions();
// Reject if geoloaction is disabled, or the origin has a retained deny
if (!mSettings.getGeolocationEnabled()) {
@@ -2876,7 +2924,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
}
private void saveWebArchiveInternal(String path, final ValueCallback<String> callback) {
- if (path == null || isDestroyed(WARN)) {
+ if (path == null || isDestroyedOrNoOperation(WARN)) {
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
@@ -2924,12 +2972,14 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
@Override
public void extractSmartClipData(int x, int y, int width, int height) {
- if (!isDestroyed(WARN)) mContentViewCore.extractSmartClipData(x, y, width, height);
+ if (!isDestroyedOrNoOperation(WARN)) {
+ mContentViewCore.extractSmartClipData(x, y, width, height);
+ }
}
@Override
public void setSmartClipResultHandler(final Handler resultHandler) {
- if (isDestroyed(WARN)) return;
+ if (isDestroyedOrNoOperation(WARN)) return;
if (resultHandler == null) {
mContentViewCore.setSmartClipDataListener(null);
@@ -2958,7 +3008,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
protected void insertVisualStateCallbackIfNotDestroyed(
long requestId, VisualStateCallback callback) {
if (TRACE) Log.i(TAG, "%s insertVisualStateCallbackIfNotDestroyed", this);
- if (isDestroyed(NO_WARN)) return;
+ if (isDestroyedOrNoOperation(NO_WARN)) return;
nativeInsertVisualStateCallback(mNativeAwContents, requestId, callback);
}
@@ -2975,7 +3025,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
@Override
public void onDraw(Canvas canvas) {
- if (isDestroyed(NO_WARN)) {
+ if (isDestroyedOrNoOperation(NO_WARN)) {
TraceEvent.instant("EarlyOut_destroyed");
canvas.drawColor(getEffectiveBackgroundColor());
return;
@@ -3026,7 +3076,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
@Override
public void requestFocus() {
- if (isDestroyed(NO_WARN)) return;
+ if (isDestroyedOrNoOperation(NO_WARN)) return;
if (!mContainerView.isInTouchMode() && mSettings.shouldFocusFirstNode()) {
nativeFocusFirstNode(mNativeAwContents);
}
@@ -3047,7 +3097,8 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
- return isDestroyed(NO_WARN) ? null : mContentViewCore.onCreateInputConnection(outAttrs);
+ return isDestroyedOrNoOperation(NO_WARN) ? null
+ : mContentViewCore.onCreateInputConnection(outAttrs);
}
@Override
@@ -3057,12 +3108,13 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
- return isDestroyed(NO_WARN) ? false : mContentViewCore.onKeyUp(keyCode, event);
+ return isDestroyedOrNoOperation(NO_WARN) ? false
+ : mContentViewCore.onKeyUp(keyCode, event);
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
- if (isDestroyed(NO_WARN)) return false;
+ if (isDestroyedOrNoOperation(NO_WARN)) return false;
if (isDpadEvent(event)) {
mSettings.setSpatialNavigationEnabled(true);
}
@@ -3085,7 +3137,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
@Override
public boolean onTouchEvent(MotionEvent event) {
- if (isDestroyed(NO_WARN)) return false;
+ if (isDestroyedOrNoOperation(NO_WARN)) return false;
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
mSettings.setSpatialNavigationEnabled(false);
}
@@ -3118,22 +3170,25 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
@Override
public boolean onHoverEvent(MotionEvent event) {
- return isDestroyed(NO_WARN) ? false : mContentViewCore.onHoverEvent(event);
+ return isDestroyedOrNoOperation(NO_WARN) ? false : mContentViewCore.onHoverEvent(event);
}
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
- return isDestroyed(NO_WARN) ? false : mContentViewCore.onGenericMotionEvent(event);
+ return isDestroyedOrNoOperation(NO_WARN) ? false
+ : mContentViewCore.onGenericMotionEvent(event);
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
- if (!isDestroyed(NO_WARN)) mContentViewCore.onConfigurationChanged(newConfig);
+ if (!isDestroyedOrNoOperation(NO_WARN)) {
+ mContentViewCore.onConfigurationChanged(newConfig);
+ }
}
@Override
public void onAttachedToWindow() {
- if (isDestroyed(NO_WARN)) return;
+ if (isDestroyedOrNoOperation(NO_WARN)) return;
if (mIsAttachedToWindow) {
Log.w(TAG, "onAttachedToWindow called when already attached. Ignoring");
return;
@@ -3157,7 +3212,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
@Override
public void onDetachedFromWindow() {
- if (isDestroyed(NO_WARN)) return;
+ if (isDestroyedOrNoOperation(NO_WARN)) return;
if (!mIsAttachedToWindow) {
Log.w(TAG, "onDetachedFromWindow called when already detached. Ignoring");
return;
@@ -3182,21 +3237,21 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
- if (isDestroyed(NO_WARN)) return;
+ if (isDestroyedOrNoOperation(NO_WARN)) return;
mWindowFocused = hasWindowFocus;
mContentViewCore.onWindowFocusChanged(hasWindowFocus);
}
@Override
public void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
- if (isDestroyed(NO_WARN)) return;
+ if (isDestroyedOrNoOperation(NO_WARN)) return;
mContainerViewFocused = focused;
mContentViewCore.onFocusChanged(focused);
}
@Override
public void onSizeChanged(int w, int h, int ow, int oh) {
- if (isDestroyed(NO_WARN)) return;
+ if (isDestroyedOrNoOperation(NO_WARN)) return;
mScrollOffsetManager.setContainerViewSize(w, h);
// The AwLayoutSizer needs to go first so that if we're in
// fixedLayoutSize mode the update
@@ -3274,7 +3329,7 @@ public class AwContents implements SmartClipProvider, PostMessageSender.PostMess
@Override
public void computeScroll() {
- if (isDestroyed(NO_WARN)) return;
+ if (isDestroyedOrNoOperation(NO_WARN)) return;
nativeOnComputeScroll(mNativeAwContents, AnimationUtils.currentAnimationTimeMillis());
}
}

Powered by Google App Engine
This is Rietveld 408576698