Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/bitmap.h> | 7 #include <android/bitmap.h> |
| 8 #include <sys/system_properties.h> | 8 #include <sys/system_properties.h> |
| 9 | 9 |
| 10 #include "android_webview/browser/aw_browser_context.h" | 10 #include "android_webview/browser/aw_browser_context.h" |
| 11 #include "android_webview/browser/aw_browser_main_parts.h" | 11 #include "android_webview/browser/aw_browser_main_parts.h" |
| 12 #include "android_webview/browser/net_disk_cache_remover.h" | 12 #include "android_webview/browser/net_disk_cache_remover.h" |
| 13 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" | 13 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" |
| 14 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h" | 14 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h" |
| 15 #include "android_webview/common/aw_hit_test_data.h" | 15 #include "android_webview/common/aw_hit_test_data.h" |
| 16 #include "android_webview/common/renderer_picture_map.h" | 16 #include "android_webview/common/renderer_picture_map.h" |
| 17 #include "android_webview/native/aw_browser_dependency_factory.h" | 17 #include "android_webview/native/aw_browser_dependency_factory.h" |
| 18 #include "android_webview/native/aw_contents_client_bridge.h" | |
| 18 #include "android_webview/native/aw_contents_io_thread_client_impl.h" | 19 #include "android_webview/native/aw_contents_io_thread_client_impl.h" |
| 19 #include "android_webview/native/aw_web_contents_delegate.h" | 20 #include "android_webview/native/aw_web_contents_delegate.h" |
| 20 #include "android_webview/native/state_serializer.h" | 21 #include "android_webview/native/state_serializer.h" |
| 21 #include "android_webview/public/browser/draw_sw.h" | 22 #include "android_webview/public/browser/draw_sw.h" |
| 22 #include "base/android/jni_android.h" | 23 #include "base/android/jni_android.h" |
| 23 #include "base/android/jni_array.h" | 24 #include "base/android/jni_array.h" |
| 24 #include "base/android/jni_string.h" | 25 #include "base/android/jni_string.h" |
| 25 #include "base/bind.h" | 26 #include "base/bind.h" |
| 26 #include "base/callback.h" | 27 #include "base/callback.h" |
| 27 #include "base/debug/trace_event.h" | 28 #include "base/debug/trace_event.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 content::RenderViewHost::FromID(render_process_id, render_view_id); | 170 content::RenderViewHost::FromID(render_process_id, render_view_id); |
| 170 if (!rvh) return NULL; | 171 if (!rvh) return NULL; |
| 171 content::WebContents* web_contents = | 172 content::WebContents* web_contents = |
| 172 content::WebContents::FromRenderViewHost(rvh); | 173 content::WebContents::FromRenderViewHost(rvh); |
| 173 if (!web_contents) return NULL; | 174 if (!web_contents) return NULL; |
| 174 return FromWebContents(web_contents); | 175 return FromWebContents(web_contents); |
| 175 } | 176 } |
| 176 | 177 |
| 177 AwContents::AwContents(JNIEnv* env, | 178 AwContents::AwContents(JNIEnv* env, |
| 178 jobject obj, | 179 jobject obj, |
| 179 jobject web_contents_delegate) | 180 jobject web_contents_delegate, |
| 181 jobject contents_client_bridge) | |
| 180 : java_ref_(env, obj), | 182 : java_ref_(env, obj), |
| 181 web_contents_delegate_( | 183 web_contents_delegate_( |
| 182 new AwWebContentsDelegate(env, web_contents_delegate)), | 184 new AwWebContentsDelegate(env, web_contents_delegate)), |
| 185 contents_client_bridge_( | |
| 186 new AwContentsClientBridge(env, contents_client_bridge)), | |
| 183 view_visible_(false), | 187 view_visible_(false), |
| 184 compositor_visible_(false), | 188 compositor_visible_(false), |
| 185 is_composite_pending_(false), | 189 is_composite_pending_(false), |
| 186 dpi_scale_(1.0f), | 190 dpi_scale_(1.0f), |
| 187 on_new_picture_mode_(kOnNewPictureDisabled), | 191 on_new_picture_mode_(kOnNewPictureDisabled), |
| 188 last_frame_context_(NULL) { | 192 last_frame_context_(NULL) { |
| 189 RendererPictureMap::CreateInstance(); | 193 RendererPictureMap::CreateInstance(); |
| 190 android_webview::AwBrowserDependencyFactory* dependency_factory = | 194 android_webview::AwBrowserDependencyFactory* dependency_factory = |
| 191 android_webview::AwBrowserDependencyFactory::GetInstance(); | 195 android_webview::AwBrowserDependencyFactory::GetInstance(); |
| 192 | 196 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 204 | 208 |
| 205 void AwContents::SetWebContents(content::WebContents* web_contents) { | 209 void AwContents::SetWebContents(content::WebContents* web_contents) { |
| 206 web_contents_.reset(web_contents); | 210 web_contents_.reset(web_contents); |
| 207 if (find_helper_.get()) { | 211 if (find_helper_.get()) { |
| 208 find_helper_->SetListener(NULL); | 212 find_helper_->SetListener(NULL); |
| 209 } | 213 } |
| 210 icon_helper_.reset(new IconHelper(web_contents_.get())); | 214 icon_helper_.reset(new IconHelper(web_contents_.get())); |
| 211 icon_helper_->SetListener(this); | 215 icon_helper_->SetListener(this); |
| 212 web_contents_->SetUserData(kAwContentsUserDataKey, | 216 web_contents_->SetUserData(kAwContentsUserDataKey, |
| 213 new AwContentsUserData(this)); | 217 new AwContentsUserData(this)); |
| 218 web_contents_->SetUserData( | |
| 219 AwCertificateErrorHandlerBase::UserData::kAwCertificateErrorHandlerBase, | |
| 220 new AwCertificateErrorHandlerBase::UserData( | |
| 221 contents_client_bridge_.get())); | |
|
joth
2013/02/22 23:12:41
yeah this will be much cleaner as:
AwCertificateEr
sgurun-gerrit only
2013/02/23 00:16:14
Done.
| |
| 214 | 222 |
| 215 web_contents_->SetDelegate(web_contents_delegate_.get()); | 223 web_contents_->SetDelegate(web_contents_delegate_.get()); |
| 216 render_view_host_ext_.reset(new AwRenderViewHostExt(web_contents_.get(), | 224 render_view_host_ext_.reset(new AwRenderViewHostExt(web_contents_.get(), |
| 217 this)); | 225 this)); |
| 218 ResetCompositor(); | 226 ResetCompositor(); |
| 219 } | 227 } |
| 220 | 228 |
| 221 void AwContents::SetWebContents(JNIEnv* env, jobject obj, jint new_wc) { | 229 void AwContents::SetWebContents(JNIEnv* env, jobject obj, jint new_wc) { |
| 222 SetWebContents(reinterpret_cast<content::WebContents*>(new_wc)); | 230 SetWebContents(reinterpret_cast<content::WebContents*>(new_wc)); |
| 223 } | 231 } |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 664 if (obj.is_null()) | 672 if (obj.is_null()) |
| 665 return; | 673 return; |
| 666 | 674 |
| 667 Java_AwContents_performLongClick(env, obj.obj()); | 675 Java_AwContents_performLongClick(env, obj.obj()); |
| 668 } | 676 } |
| 669 | 677 |
| 670 void AwContents::OnReceivedHttpAuthRequest(const JavaRef<jobject>& handler, | 678 void AwContents::OnReceivedHttpAuthRequest(const JavaRef<jobject>& handler, |
| 671 const std::string& host, | 679 const std::string& host, |
| 672 const std::string& realm) { | 680 const std::string& realm) { |
| 673 JNIEnv* env = AttachCurrentThread(); | 681 JNIEnv* env = AttachCurrentThread(); |
| 682 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | |
| 683 if (obj.is_null()) | |
| 684 return; | |
| 685 | |
| 674 ScopedJavaLocalRef<jstring> jhost = ConvertUTF8ToJavaString(env, host); | 686 ScopedJavaLocalRef<jstring> jhost = ConvertUTF8ToJavaString(env, host); |
| 675 ScopedJavaLocalRef<jstring> jrealm = ConvertUTF8ToJavaString(env, realm); | 687 ScopedJavaLocalRef<jstring> jrealm = ConvertUTF8ToJavaString(env, realm); |
| 676 Java_AwContents_onReceivedHttpAuthRequest(env, java_ref_.get(env).obj(), | 688 Java_AwContents_onReceivedHttpAuthRequest(env, obj.obj(), handler.obj(), |
| 677 handler.obj(), jhost.obj(), | 689 jhost.obj(), jrealm.obj()); |
| 678 jrealm.obj()); | |
| 679 } | 690 } |
| 680 | 691 |
| 681 void AwContents::SetIoThreadClient(JNIEnv* env, jobject obj, jobject client) { | 692 void AwContents::SetIoThreadClient(JNIEnv* env, jobject obj, jobject client) { |
| 682 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 693 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 683 AwContentsIoThreadClientImpl::Associate( | 694 AwContentsIoThreadClientImpl::Associate( |
| 684 web_contents_.get(), ScopedJavaLocalRef<jobject>(env, client)); | 695 web_contents_.get(), ScopedJavaLocalRef<jobject>(env, client)); |
| 685 int child_id = web_contents_->GetRenderProcessHost()->GetID(); | 696 int child_id = web_contents_->GetRenderProcessHost()->GetID(); |
| 686 int route_id = web_contents_->GetRoutingID(); | 697 int route_id = web_contents_->GetRoutingID(); |
| 687 AwResourceDispatcherHostDelegate::OnIoThreadClientReady(child_id, route_id); | 698 AwResourceDispatcherHostDelegate::OnIoThreadClientReady(child_id, route_id); |
| 688 } | 699 } |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 710 ++itr) { | 721 ++itr) { |
| 711 visited_link_gurls.push_back(GURL(*itr)); | 722 visited_link_gurls.push_back(GURL(*itr)); |
| 712 } | 723 } |
| 713 | 724 |
| 714 AwBrowserContext::FromWebContents(web_contents_.get()) | 725 AwBrowserContext::FromWebContents(web_contents_.get()) |
| 715 ->AddVisitedURLs(visited_link_gurls); | 726 ->AddVisitedURLs(visited_link_gurls); |
| 716 } | 727 } |
| 717 | 728 |
| 718 static jint Init(JNIEnv* env, | 729 static jint Init(JNIEnv* env, |
| 719 jobject obj, | 730 jobject obj, |
| 720 jobject web_contents_delegate) { | 731 jobject web_contents_delegate, |
| 721 AwContents* tab = new AwContents(env, obj, web_contents_delegate); | 732 jobject contents_client_bridge) { |
| 733 AwContents* tab = new AwContents(env, obj, web_contents_delegate, | |
| 734 contents_client_bridge); | |
| 722 return reinterpret_cast<jint>(tab); | 735 return reinterpret_cast<jint>(tab); |
| 723 } | 736 } |
| 724 | 737 |
| 725 bool RegisterAwContents(JNIEnv* env) { | 738 bool RegisterAwContents(JNIEnv* env) { |
| 726 return RegisterNativesImpl(env) >= 0; | 739 return RegisterNativesImpl(env) >= 0; |
| 727 } | 740 } |
| 728 | 741 |
| 729 namespace { | 742 namespace { |
| 730 | 743 |
| 731 void ShowGeolocationPromptHelperTask(const JavaObjectWeakGlobalRef& java_ref, | 744 void ShowGeolocationPromptHelperTask(const JavaObjectWeakGlobalRef& java_ref, |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1162 if (!picture) { | 1175 if (!picture) { |
| 1163 render_view_host_ext_->CapturePictureSync(); | 1176 render_view_host_ext_->CapturePictureSync(); |
| 1164 picture = RendererPictureMap::GetInstance()->GetRendererPicture( | 1177 picture = RendererPictureMap::GetInstance()->GetRendererPicture( |
| 1165 web_contents_->GetRoutingID()); | 1178 web_contents_->GetRoutingID()); |
| 1166 } | 1179 } |
| 1167 | 1180 |
| 1168 return picture; | 1181 return picture; |
| 1169 } | 1182 } |
| 1170 | 1183 |
| 1171 } // namespace android_webview | 1184 } // namespace android_webview |
| OLD | NEW |