Chromium Code Reviews| Index: android_webview/java/src/org/chromium/android_webview/AwContentsClient.java |
| diff --git a/android_webview/java/src/org/chromium/android_webview/AwContentsClient.java b/android_webview/java/src/org/chromium/android_webview/AwContentsClient.java |
| index f64604027c7b16c37ff37dfa6e424eac2d3899d5..141aa6f3b278297cb88fb85efa64d82391da5099 100644 |
| --- a/android_webview/java/src/org/chromium/android_webview/AwContentsClient.java |
| +++ b/android_webview/java/src/org/chromium/android_webview/AwContentsClient.java |
| @@ -6,6 +6,8 @@ package org.chromium.android_webview; |
| import android.graphics.Rect; |
| import android.graphics.RectF; |
| +import android.os.Handler; |
| +import android.os.Message; |
| import android.util.Log; |
| import android.view.KeyEvent; |
| import android.webkit.ConsoleMessage; |
| @@ -31,12 +33,44 @@ public abstract class AwContentsClient extends ContentViewClient { |
| new WebContentsDelegateAdapter(); |
| private AwWebContentsObserver mWebContentsObserver; |
| + // The content core. |
| + private ContentViewCore mContentViewCore; |
| //-------------------------------------------------------------------------------------------- |
| // Adapter for WebContentsDelegate methods. |
| //-------------------------------------------------------------------------------------------- |
| class WebContentsDelegateAdapter extends AwWebContentsDelegate { |
| + |
| + // The message ids. |
| + public final static int CONTINUE_PENDING_RELOAD = 1; |
| + public final static int CANCEL_PENDING_RELOAD = 2; |
| + |
| + // Handler associated with this adapter. |
| + private final EventHandler mHandler = new EventHandler(); |
|
joth
2012/10/17 20:35:53
as the class is not static , it's also OK to make
sgurun-gerrit only
2012/10/17 22:08:18
Done.
|
| + |
| + /** |
| + * Handle messages posted to this adapter. |
| + */ |
| + private final class EventHandler extends Handler { |
|
joth
2012/10/17 20:35:53
could be as well to pass Looper.getMainlooper() to
sgurun-gerrit only
2012/10/17 22:08:18
good idea. makes sense.
|
| + |
| + @Override |
| + public void handleMessage(Message msg) { |
| + switch (msg.what) { |
| + case CONTINUE_PENDING_RELOAD: |
| + if (mContentViewCore != null) { |
| + mContentViewCore.continuePendingReload(); |
| + } |
| + break; |
| + case CANCEL_PENDING_RELOAD: |
| + if (mContentViewCore != null) { |
| + mContentViewCore.cancelPendingReload(); |
| + } |
| + break; |
| + } |
| + } |
| + } |
| + |
| @Override |
| public void onLoadProgressChanged(int progress) { |
| AwContentsClient.this.onProgressChanged(progress); |
| @@ -99,6 +133,13 @@ public abstract class AwContentsClient extends ContentViewClient { |
| public void onUrlStarredChanged(boolean starred) { |
| // TODO: implement |
| } |
| + |
| + @Override |
| + public void showRepostFormWarningDialog() { |
| + Message dontResend = mHandler.obtainMessage(CANCEL_PENDING_RELOAD); |
| + Message resend = mHandler.obtainMessage(CONTINUE_PENDING_RELOAD); |
| + AwContentsClient.this.onFormResubmission(dontResend, resend); |
| + } |
| } |
| class AwWebContentsObserver extends WebContentsObserverAndroid { |
| @@ -124,9 +165,10 @@ public abstract class AwContentsClient extends ContentViewClient { |
| } |
| } |
| - void installWebContentsObserver(ContentViewCore contentViewCore) { |
| + void setContentViewCore(ContentViewCore contentViewCore) { |
| assert mWebContentsObserver == null; |
| mWebContentsObserver = new AwWebContentsObserver(contentViewCore); |
| + mContentViewCore = contentViewCore; |
| } |
| final AwWebContentsDelegate getWebContentsDelegate() { |
| @@ -151,6 +193,8 @@ public abstract class AwContentsClient extends ContentViewClient { |
| public abstract void onReceivedHttpAuthRequest(AwHttpAuthHandler handler, |
| String host, String realm); |
| + public abstract void onFormResubmission(Message dontResend, Message resend); |
| + |
| protected abstract void handleJsAlert(String url, String message, JsResultReceiver receiver); |
| protected abstract void handleJsBeforeUnload(String url, String message, |