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

Unified Diff: android_webview/native/aw_web_contents_delegate.cc

Issue 11348075: [Android WebView] AwContentsClient.shouldCreate window callback part 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix spurious includes. Created 8 years, 1 month 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_contents.cc ('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 761061226aebf5018e4c487d122106b1a09add4b..385fb2fc8852e2a4d7642d8e41aadba582de9560 100644
--- a/android_webview/native/aw_web_contents_delegate.cc
+++ b/android_webview/native/aw_web_contents_delegate.cc
@@ -4,10 +4,11 @@
#include "android_webview/native/aw_web_contents_delegate.h"
-#include "base/lazy_instance.h"
#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/lazy_instance.h"
+#include "base/message_loop.h"
#include "content/public/browser/android/download_controller_android.h"
#include "content/public/browser/web_contents.h"
#include "jni/AwWebContentsDelegate_jni.h"
@@ -79,13 +80,22 @@ void AwWebContentsDelegate::AddNewContents(content::WebContents* source,
GetJavaDelegate(env).obj(), is_dialog, user_gesture);
if (create_popup) {
- // TODO(benm): Implement, taking ownership of new_contents.
- NOTIMPLEMENTED() << "Popup windows are currently not supported for "
- << "the chromium powered Android WebView.";
+ // The embedder would like to display the popup and we will receive
+ // a callback from them later with an AwContents to use to display
+ // it. The source AwContents takes ownership of the new WebContents
+ // until then, and when the callback is made we will swap the WebContents
+ // out into the new AwContents.
+ AwContents::FromWebContents(source)->SetPendingWebContentsForPopup(
+ make_scoped_ptr(new_contents));
+ // Hide the WebContents for the pop up now, we will show it again
+ // when the user calls us back with an AwContents to use to show it.
+ new_contents->WasHidden();
} else {
// The embedder has forgone their chance to display this popup
- // window, so we're done with the WebContents now.
- delete new_contents;
+ // window, so we're done with the WebContents now. We use
+ // DeleteSoon as WebContentsImpl may call methods on |new_contents|
+ // after this method returns.
+ MessageLoop::current()->DeleteSoon(FROM_HERE, new_contents);
}
if (was_blocked) {
« no previous file with comments | « android_webview/native/aw_contents.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698