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)); |
| 214 | 218 AwContentsClientBridgeBase::Associate(web_contents_.get(), |
| 219 contents_client_bridge_.get()); | |
| 215 web_contents_->SetDelegate(web_contents_delegate_.get()); | 220 web_contents_->SetDelegate(web_contents_delegate_.get()); |
| 216 render_view_host_ext_.reset(new AwRenderViewHostExt(web_contents_.get(), | 221 render_view_host_ext_.reset(new AwRenderViewHostExt(web_contents_.get(), |
| 217 this)); | 222 this)); |
| 218 ResetCompositor(); | 223 ResetCompositor(); |
| 219 } | 224 } |
| 220 | 225 |
| 221 void AwContents::SetWebContents(JNIEnv* env, jobject obj, jint new_wc) { | 226 void AwContents::SetWebContents(JNIEnv* env, jobject obj, jint new_wc) { |
| 222 SetWebContents(reinterpret_cast<content::WebContents*>(new_wc)); | 227 SetWebContents(reinterpret_cast<content::WebContents*>(new_wc)); |
| 223 } | 228 } |
| 224 | 229 |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 664 if (obj.is_null()) | 669 if (obj.is_null()) |
| 665 return; | 670 return; |
| 666 | 671 |
| 667 Java_AwContents_performLongClick(env, obj.obj()); | 672 Java_AwContents_performLongClick(env, obj.obj()); |
| 668 } | 673 } |
| 669 | 674 |
| 670 void AwContents::OnReceivedHttpAuthRequest(const JavaRef<jobject>& handler, | 675 void AwContents::OnReceivedHttpAuthRequest(const JavaRef<jobject>& handler, |
| 671 const std::string& host, | 676 const std::string& host, |
| 672 const std::string& realm) { | 677 const std::string& realm) { |
| 673 JNIEnv* env = AttachCurrentThread(); | 678 JNIEnv* env = AttachCurrentThread(); |
| 679 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | |
| 680 if (obj.is_null()) | |
| 681 return; | |
| 682 | |
| 674 ScopedJavaLocalRef<jstring> jhost = ConvertUTF8ToJavaString(env, host); | 683 ScopedJavaLocalRef<jstring> jhost = ConvertUTF8ToJavaString(env, host); |
| 675 ScopedJavaLocalRef<jstring> jrealm = ConvertUTF8ToJavaString(env, realm); | 684 ScopedJavaLocalRef<jstring> jrealm = ConvertUTF8ToJavaString(env, realm); |
| 676 Java_AwContents_onReceivedHttpAuthRequest(env, java_ref_.get(env).obj(), | 685 Java_AwContents_onReceivedHttpAuthRequest(env, obj.obj(), handler.obj(), |
| 677 handler.obj(), jhost.obj(), | 686 jhost.obj(), jrealm.obj()); |
|
joth
2013/02/23 00:30:09
nit: indent to (
| |
| 678 jrealm.obj()); | |
| 679 } | 687 } |
| 680 | 688 |
| 681 void AwContents::SetIoThreadClient(JNIEnv* env, jobject obj, jobject client) { | 689 void AwContents::SetIoThreadClient(JNIEnv* env, jobject obj, jobject client) { |
| 682 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 690 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 683 AwContentsIoThreadClientImpl::Associate( | 691 AwContentsIoThreadClientImpl::Associate( |
| 684 web_contents_.get(), ScopedJavaLocalRef<jobject>(env, client)); | 692 web_contents_.get(), ScopedJavaLocalRef<jobject>(env, client)); |
| 685 int child_id = web_contents_->GetRenderProcessHost()->GetID(); | 693 int child_id = web_contents_->GetRenderProcessHost()->GetID(); |
| 686 int route_id = web_contents_->GetRoutingID(); | 694 int route_id = web_contents_->GetRoutingID(); |
| 687 AwResourceDispatcherHostDelegate::OnIoThreadClientReady(child_id, route_id); | 695 AwResourceDispatcherHostDelegate::OnIoThreadClientReady(child_id, route_id); |
| 688 } | 696 } |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 710 ++itr) { | 718 ++itr) { |
| 711 visited_link_gurls.push_back(GURL(*itr)); | 719 visited_link_gurls.push_back(GURL(*itr)); |
| 712 } | 720 } |
| 713 | 721 |
| 714 AwBrowserContext::FromWebContents(web_contents_.get()) | 722 AwBrowserContext::FromWebContents(web_contents_.get()) |
| 715 ->AddVisitedURLs(visited_link_gurls); | 723 ->AddVisitedURLs(visited_link_gurls); |
| 716 } | 724 } |
| 717 | 725 |
| 718 static jint Init(JNIEnv* env, | 726 static jint Init(JNIEnv* env, |
| 719 jobject obj, | 727 jobject obj, |
| 720 jobject web_contents_delegate) { | 728 jobject web_contents_delegate, |
| 721 AwContents* tab = new AwContents(env, obj, web_contents_delegate); | 729 jobject contents_client_bridge) { |
| 730 AwContents* tab = new AwContents(env, obj, web_contents_delegate, | |
| 731 contents_client_bridge); | |
|
joth
2013/02/23 00:30:09
ditto.
| |
| 722 return reinterpret_cast<jint>(tab); | 732 return reinterpret_cast<jint>(tab); |
| 723 } | 733 } |
| 724 | 734 |
| 725 bool RegisterAwContents(JNIEnv* env) { | 735 bool RegisterAwContents(JNIEnv* env) { |
| 726 return RegisterNativesImpl(env) >= 0; | 736 return RegisterNativesImpl(env) >= 0; |
| 727 } | 737 } |
| 728 | 738 |
| 729 namespace { | 739 namespace { |
| 730 | 740 |
| 731 void ShowGeolocationPromptHelperTask(const JavaObjectWeakGlobalRef& java_ref, | 741 void ShowGeolocationPromptHelperTask(const JavaObjectWeakGlobalRef& java_ref, |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1162 if (!picture) { | 1172 if (!picture) { |
| 1163 render_view_host_ext_->CapturePictureSync(); | 1173 render_view_host_ext_->CapturePictureSync(); |
| 1164 picture = RendererPictureMap::GetInstance()->GetRendererPicture( | 1174 picture = RendererPictureMap::GetInstance()->GetRendererPicture( |
| 1165 web_contents_->GetRoutingID()); | 1175 web_contents_->GetRoutingID()); |
| 1166 } | 1176 } |
| 1167 | 1177 |
| 1168 return picture; | 1178 return picture; |
| 1169 } | 1179 } |
| 1170 | 1180 |
| 1171 } // namespace android_webview | 1181 } // namespace android_webview |
| OLD | NEW |