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

Side by Side Diff: android_webview/native/aw_contents.cc

Issue 11348075: [Android WebView] AwContentsClient.shouldCreate window callback part 2. (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "android_webview/native/aw_contents.h" 5 #include "android_webview/native/aw_contents.h"
6 6
7 #include "android_webview/browser/aw_browser_main_parts.h" 7 #include "android_webview/browser/aw_browser_main_parts.h"
8 #include "android_webview/browser/net_disk_cache_remover.h" 8 #include "android_webview/browser/net_disk_cache_remover.h"
9 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" 9 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h"
10 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h"
10 #include "android_webview/common/aw_hit_test_data.h" 11 #include "android_webview/common/aw_hit_test_data.h"
11 #include "android_webview/native/aw_browser_dependency_factory.h" 12 #include "android_webview/native/aw_browser_dependency_factory.h"
12 #include "android_webview/native/aw_contents_io_thread_client_impl.h" 13 #include "android_webview/native/aw_contents_io_thread_client_impl.h"
13 #include "android_webview/native/aw_web_contents_delegate.h" 14 #include "android_webview/native/aw_web_contents_delegate.h"
14 #include "android_webview/native/state_serializer.h" 15 #include "android_webview/native/state_serializer.h"
15 #include "base/android/jni_android.h" 16 #include "base/android/jni_android.h"
16 #include "base/android/jni_array.h" 17 #include "base/android/jni_array.h"
17 #include "base/android/jni_string.h" 18 #include "base/android/jni_string.h"
18 #include "base/bind.h" 19 #include "base/bind.h"
19 #include "base/callback.h" 20 #include "base/callback.h"
20 #include "base/pickle.h" 21 #include "base/pickle.h"
21 #include "base/supports_user_data.h" 22 #include "base/supports_user_data.h"
22 #include "content/components/navigation_interception/intercept_navigation_delega te.h" 23 #include "content/components/navigation_interception/intercept_navigation_delega te.h"
23 #include "content/public/browser/android/content_view_core.h" 24 #include "content/public/browser/android/content_view_core.h"
24 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
25 #include "content/public/browser/cert_store.h" 26 #include "content/public/browser/cert_store.h"
26 #include "content/public/browser/navigation_entry.h" 27 #include "content/public/browser/navigation_entry.h"
28 #include "content/public/browser/render_process_host.h"
27 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
28 #include "content/public/common/ssl_status.h" 30 #include "content/public/common/ssl_status.h"
29 #include "jni/AwContents_jni.h" 31 #include "jni/AwContents_jni.h"
30 #include "net/base/x509_certificate.h" 32 #include "net/base/x509_certificate.h"
31 33
32 using base::android::AttachCurrentThread; 34 using base::android::AttachCurrentThread;
33 using base::android::ConvertJavaStringToUTF16; 35 using base::android::ConvertJavaStringToUTF16;
34 using base::android::ConvertJavaStringToUTF8; 36 using base::android::ConvertJavaStringToUTF8;
35 using base::android::ConvertUTF16ToJavaString; 37 using base::android::ConvertUTF16ToJavaString;
36 using base::android::ConvertUTF8ToJavaString; 38 using base::android::ConvertUTF8ToJavaString;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 bool private_browsing) 121 bool private_browsing)
120 : java_ref_(env, obj), 122 : java_ref_(env, obj),
121 web_contents_delegate_( 123 web_contents_delegate_(
122 new AwWebContentsDelegate(env, web_contents_delegate)), 124 new AwWebContentsDelegate(env, web_contents_delegate)),
123 view_visible_(false), 125 view_visible_(false),
124 compositor_visible_(false), 126 compositor_visible_(false),
125 is_composite_pending_(false) { 127 is_composite_pending_(false) {
126 android_webview::AwBrowserDependencyFactory* dependency_factory = 128 android_webview::AwBrowserDependencyFactory* dependency_factory =
127 android_webview::AwBrowserDependencyFactory::GetInstance(); 129 android_webview::AwBrowserDependencyFactory::GetInstance();
128 130
129 web_contents_.reset(dependency_factory->CreateWebContents(private_browsing)); 131 SetWebContents(dependency_factory->CreateWebContents(private_browsing));
joth 2012/11/29 21:02:33 I think it will be clearer to move all this to jav
benm (inactive) 2012/11/30 12:54:18 Done.
132 }
130 133
131 DCHECK(!AwContents::FromWebContents(web_contents_.get())); 134 void AwContents::SetWebContents(content::WebContents* web_contents) {
135 web_contents_.reset(web_contents);
132 web_contents_->SetUserData(kAwContentsUserDataKey, 136 web_contents_->SetUserData(kAwContentsUserDataKey,
133 new AwContentsUserData(this)); 137 new AwContentsUserData(this));
134 138
135 web_contents_->SetDelegate(web_contents_delegate_.get()); 139 web_contents_->SetDelegate(web_contents_delegate_.get());
136 render_view_host_ext_.reset(new AwRenderViewHostExt(web_contents_.get())); 140 render_view_host_ext_.reset(new AwRenderViewHostExt(web_contents_.get()));
137 if (UseCompositorDirectDraw()) { 141 if (UseCompositorDirectDraw()) {
138 compositor_.reset(content::Compositor::Create(this)); 142 compositor_.reset(content::Compositor::Create(this));
139 } else { 143 } else {
140 LOG(WARNING) << "Running on unsupported device: using null Compositor"; 144 LOG(WARNING) << "Running on unsupported device: using null Compositor";
141 compositor_.reset(new NullCompositor); 145 compositor_.reset(new NullCompositor);
142 } 146 }
143 } 147 }
144 148
149 void AwContents::SetWebContents(JNIEnv* env, jobject obj, jint new_wc) {
150 SetWebContents(reinterpret_cast<content::WebContents*>(new_wc));
151 }
152
145 AwContents::~AwContents() { 153 AwContents::~AwContents() {
146 DCHECK(AwContents::FromWebContents(web_contents_.get()) == this); 154 DCHECK(AwContents::FromWebContents(web_contents_.get()) == this);
147 web_contents_->RemoveUserData(kAwContentsUserDataKey); 155 web_contents_->RemoveUserData(kAwContentsUserDataKey);
148 if (find_helper_.get()) 156 if (find_helper_.get())
149 find_helper_->SetListener(NULL); 157 find_helper_->SetListener(NULL);
150 } 158 }
151 159
152 void AwContents::DrawGL(AwDrawGLInfo* draw_info) { 160 void AwContents::DrawGL(AwDrawGLInfo* draw_info) {
153 // TODO(joth): Use the |draw_info| parameters. 161 // TODO(joth): Use the |draw_info| parameters.
154 DLOG(INFO) << "Unimplemented AwContents::DrawGL params" 162 DLOG(INFO) << "Unimplemented AwContents::DrawGL params"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 ScopedJavaLocalRef<jstring> jrealm = ConvertUTF8ToJavaString(env, realm); 303 ScopedJavaLocalRef<jstring> jrealm = ConvertUTF8ToJavaString(env, realm);
296 Java_AwContents_onReceivedHttpAuthRequest(env, java_ref_.get(env).obj(), 304 Java_AwContents_onReceivedHttpAuthRequest(env, java_ref_.get(env).obj(),
297 handler.obj(), jhost.obj(), 305 handler.obj(), jhost.obj(),
298 jrealm.obj()); 306 jrealm.obj());
299 } 307 }
300 308
301 void AwContents::SetIoThreadClient(JNIEnv* env, jobject obj, jobject client) { 309 void AwContents::SetIoThreadClient(JNIEnv* env, jobject obj, jobject client) {
302 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 310 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
303 AwContentsIoThreadClientImpl::Associate( 311 AwContentsIoThreadClientImpl::Associate(
304 web_contents_.get(), ScopedJavaLocalRef<jobject>(env, client)); 312 web_contents_.get(), ScopedJavaLocalRef<jobject>(env, client));
313 int child_id = web_contents_->GetRenderProcessHost()->GetID();
314 int route_id = web_contents_->GetRoutingID();
315 AwResourceDispatcherHostDelegate::OnIoThreadClientReady(child_id, route_id);
305 } 316 }
306 317
307 void AwContents::SetInterceptNavigationDelegate(JNIEnv* env, 318 void AwContents::SetInterceptNavigationDelegate(JNIEnv* env,
308 jobject obj, 319 jobject obj,
309 jobject delegate) { 320 jobject delegate) {
310 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 321 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
311 InterceptNavigationDelegate::Associate( 322 InterceptNavigationDelegate::Associate(
312 web_contents_.get(), 323 web_contents_.get(),
313 make_scoped_ptr(new InterceptNavigationDelegate(env, delegate))); 324 make_scoped_ptr(new InterceptNavigationDelegate(env, delegate)));
314 } 325 }
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 std::vector<uint8> state_vector; 516 std::vector<uint8> state_vector;
506 base::android::JavaByteArrayToByteVector(env, state, &state_vector); 517 base::android::JavaByteArrayToByteVector(env, state, &state_vector);
507 518
508 Pickle pickle(reinterpret_cast<const char*>(state_vector.begin()), 519 Pickle pickle(reinterpret_cast<const char*>(state_vector.begin()),
509 state_vector.size()); 520 state_vector.size());
510 PickleIterator iterator(pickle); 521 PickleIterator iterator(pickle);
511 522
512 return RestoreFromPickle(&iterator, web_contents_.get()); 523 return RestoreFromPickle(&iterator, web_contents_.get());
513 } 524 }
514 525
526 void AwContents::SetPendingWebContentsForPopup(
527 scoped_ptr<content::WebContents> pending) {
528 if (pending_contents_.get()) {
529 // TODO(benm): Support holding multiple pop up window requests.
530 LOG(WARNING) << "Blocking popup window creation as an outstanding "
531 << "popup window is still pending.";
532 return;
joth 2012/11/29 21:02:33 This will delete |pending|. Snag is both AwWebCont
benm (inactive) 2012/11/30 12:54:18 Good point.
533 }
534 pending_contents_ = pending.Pass();
535 }
536
537 jint AwContents::ReleasePopupWebContents(JNIEnv* env, jobject obj) {
538 return reinterpret_cast<jint>(pending_contents_.release());
539 }
540
515 } // namespace android_webview 541 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698