summaryrefslogtreecommitdiffstats
path: root/android_webview/native/aw_contents.cc
diff options
context:
space:
mode:
authorbenm@chromium.org <benm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-03 10:14:09 +0000
committerbenm@chromium.org <benm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-03 10:14:09 +0000
commitf0fe637ac4a36286d734c9a370b040f14ee73800 (patch)
tree0be96c3ce5e65ea20e95b5b14fd38b78674334ec /android_webview/native/aw_contents.cc
parent38fa4c690102c4474338463301dcb1a367278752 (diff)
downloadchromium_src-f0fe637ac4a36286d734c9a370b040f14ee73800.zip
chromium_src-f0fe637ac4a36286d734c9a370b040f14ee73800.tar.gz
chromium_src-f0fe637ac4a36286d734c9a370b040f14ee73800.tar.bz2
[Android WebView] AwContentsClient.shouldCreate window callback part 2.
Part 1: https://chromiumcodereview.appspot.com/11362183/ The second part of this change implements the "true" path, i.e. the user provides us with a new AwContents to host the popup window. This arrives asynchronously. While we are waiting for the reply from the user, we defer loading of the popup contents using a resource throttle. When we receive the callback we replace the ContentViewCore that is contained in the new AwContents with one that wraps the WebContents for the popup. This triggers an update to the AwIoThreadClient for that AwContents, which resumes the deferred load for the popup. Android only change and android bots green NOTRY=TRUE Review URL: https://chromiumcodereview.appspot.com/11348075 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170721 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview/native/aw_contents.cc')
-rw-r--r--android_webview/native/aw_contents.cc35
1 files changed, 33 insertions, 2 deletions
diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc
index a92c838..9a8cede 100644
--- a/android_webview/native/aw_contents.cc
+++ b/android_webview/native/aw_contents.cc
@@ -7,6 +7,7 @@
#include "android_webview/browser/aw_browser_main_parts.h"
#include "android_webview/browser/net_disk_cache_remover.h"
#include "android_webview/browser/renderer_host/aw_render_view_host_ext.h"
+#include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.h"
#include "android_webview/common/aw_hit_test_data.h"
#include "android_webview/native/aw_browser_dependency_factory.h"
#include "android_webview/native/aw_contents_io_thread_client_impl.h"
@@ -17,6 +18,7 @@
#include "base/android/jni_string.h"
#include "base/bind.h"
#include "base/callback.h"
+#include "base/message_loop.h"
#include "base/pickle.h"
#include "base/supports_user_data.h"
#include "content/components/navigation_interception/intercept_navigation_delegate.h"
@@ -24,6 +26,7 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/cert_store.h"
#include "content/public/browser/navigation_entry.h"
+#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/ssl_status.h"
#include "jni/AwContents_jni.h"
@@ -126,9 +129,14 @@ AwContents::AwContents(JNIEnv* env,
android_webview::AwBrowserDependencyFactory* dependency_factory =
android_webview::AwBrowserDependencyFactory::GetInstance();
- web_contents_.reset(dependency_factory->CreateWebContents(private_browsing));
+ // TODO(joth): rather than create and set the WebContents here, expose the
+ // factory method to java side and have that orchestrate the construction
+ // order.
+ SetWebContents(dependency_factory->CreateWebContents(private_browsing));
+}
- DCHECK(!AwContents::FromWebContents(web_contents_.get()));
+void AwContents::SetWebContents(content::WebContents* web_contents) {
+ web_contents_.reset(web_contents);
web_contents_->SetUserData(kAwContentsUserDataKey,
new AwContentsUserData(this));
@@ -142,6 +150,10 @@ AwContents::AwContents(JNIEnv* env,
}
}
+void AwContents::SetWebContents(JNIEnv* env, jobject obj, jint new_wc) {
+ SetWebContents(reinterpret_cast<content::WebContents*>(new_wc));
+}
+
AwContents::~AwContents() {
DCHECK(AwContents::FromWebContents(web_contents_.get()) == this);
web_contents_->RemoveUserData(kAwContentsUserDataKey);
@@ -302,6 +314,9 @@ void AwContents::SetIoThreadClient(JNIEnv* env, jobject obj, jobject client) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
AwContentsIoThreadClientImpl::Associate(
web_contents_.get(), ScopedJavaLocalRef<jobject>(env, client));
+ int child_id = web_contents_->GetRenderProcessHost()->GetID();
+ int route_id = web_contents_->GetRoutingID();
+ AwResourceDispatcherHostDelegate::OnIoThreadClientReady(child_id, route_id);
}
void AwContents::SetInterceptNavigationDelegate(JNIEnv* env,
@@ -512,4 +527,20 @@ jboolean AwContents::RestoreFromOpaqueState(
return RestoreFromPickle(&iterator, web_contents_.get());
}
+void AwContents::SetPendingWebContentsForPopup(
+ scoped_ptr<content::WebContents> pending) {
+ if (pending_contents_.get()) {
+ // TODO(benm): Support holding multiple pop up window requests.
+ LOG(WARNING) << "Blocking popup window creation as an outstanding "
+ << "popup window is still pending.";
+ MessageLoop::current()->DeleteSoon(FROM_HERE, pending.release());
+ return;
+ }
+ pending_contents_ = pending.Pass();
+}
+
+jint AwContents::ReleasePopupWebContents(JNIEnv* env, jobject obj) {
+ return reinterpret_cast<jint>(pending_contents_.release());
+}
+
} // namespace android_webview