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

Unified Diff: android_webview/native/aw_web_contents_delegate.cc

Issue 11418292: [Android WebView] Plumb WebContentsDelegate::CloseContents to embedder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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
« no previous file with comments | « android_webview/native/aw_web_contents_delegate.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/native/aw_web_contents_delegate.cc
diff --git a/android_webview/native/aw_web_contents_delegate.cc b/android_webview/native/aw_web_contents_delegate.cc
index 385fb2fc8852e2a4d7642d8e41aadba582de9560..43db88f6600e1d58332b07db40d3c188f0060e3a 100644
--- a/android_webview/native/aw_web_contents_delegate.cc
+++ b/android_webview/native/aw_web_contents_delegate.cc
@@ -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);
}
« no previous file with comments | « android_webview/native/aw_web_contents_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698