Commit 9168c16b authored by benm@chromium.org's avatar benm@chromium.org

[Android WebView] Plumb WebContentsDelegate::CloseContents to embedder.

This allows us to support the Android WebChromeClient.onCloseWindow API.

Android bots green
NOTRY=true


Review URL: https://chromiumcodereview.appspot.com/11418292

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170935 0039d316-1c4b-4281-b951-d872f2087c98
parent 3006945f
......@@ -123,7 +123,7 @@ public abstract class AwContentsClient extends ContentViewClient {
@Override
public void closeContents() {
// TODO: implement
AwContentsClient.this.onCloseWindow();
}
@Override
......@@ -137,7 +137,6 @@ public abstract class AwContentsClient extends ContentViewClient {
public boolean addNewContents(boolean isDialog, boolean isUserGesture) {
return AwContentsClient.this.onCreateWindow(isDialog, isUserGesture);
}
}
class AwWebContentsObserver extends WebContentsObserverAndroid {
......@@ -216,6 +215,8 @@ public abstract class AwContentsClient extends ContentViewClient {
protected abstract boolean onCreateWindow(boolean isDialog, boolean isUserGesture);
protected abstract void onCloseWindow();
//--------------------------------------------------------------------------------------------
// Other WebView-specific methods
//--------------------------------------------------------------------------------------------
......
......@@ -20,4 +20,7 @@ public class AwWebContentsDelegate extends WebContentsDelegateAndroid {
public boolean addNewContents(boolean isDialog, boolean isUserGesture) {
return false;
}
@CalledByNative
public void closeContents() { }
}
......@@ -95,4 +95,8 @@ class NullContentsClient extends AwContentsClient {
public boolean onCreateWindow(boolean isDialog, boolean isUserGesture) {
return false;
}
@Override
public void onCloseWindow() {
}
}
......@@ -7,6 +7,7 @@
#include "android_webview/browser/find_helper.h"
#include "android_webview/native/aw_contents.h"
#include "android_webview/native/aw_javascript_dialog_creator.h"
#include "base/android/scoped_java_ref.h"
#include "base/lazy_instance.h"
#include "base/message_loop.h"
#include "content/public/browser/android/download_controller_android.h"
......@@ -15,6 +16,7 @@
#include "net/http/http_request_headers.h"
using base::android::AttachCurrentThread;
using base::android::ScopedJavaLocalRef;
using content::WebContents;
namespace android_webview {
......@@ -76,8 +78,13 @@ void AwWebContentsDelegate::AddNewContents(content::WebContents* source,
JNIEnv* env = AttachCurrentThread();
bool is_dialog = disposition == NEW_POPUP;
bool create_popup = Java_AwWebContentsDelegate_addNewContents(env,
GetJavaDelegate(env).obj(), is_dialog, user_gesture);
ScopedJavaLocalRef<jobject> java_delegate = GetJavaDelegate(env);
bool create_popup = false;
if (java_delegate.obj()) {
create_popup = Java_AwWebContentsDelegate_addNewContents(env,
java_delegate.obj(), is_dialog, user_gesture);
}
if (create_popup) {
// The embedder would like to display the popup and we will receive
......@@ -103,6 +110,15 @@ void AwWebContentsDelegate::AddNewContents(content::WebContents* source,
}
}
void AwWebContentsDelegate::CloseContents(content::WebContents* source) {
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> java_delegate = GetJavaDelegate(env);
if (java_delegate.obj()) {
Java_AwWebContentsDelegate_closeContents(env, java_delegate.obj());
}
}
bool RegisterAwWebContentsDelegate(JNIEnv* env) {
return RegisterNativesImpl(env);
}
......
......@@ -38,6 +38,7 @@ class AwWebContentsDelegate
const gfx::Rect& initial_pos,
bool user_gesture,
bool* was_blocked) OVERRIDE;
virtual void CloseContents(content::WebContents* source) OVERRIDE;
};
bool RegisterAwWebContentsDelegate(JNIEnv* env);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment