OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <limits> | 7 #include <limits> |
8 | 8 |
9 #include "android_webview/browser/aw_browser_context.h" | 9 #include "android_webview/browser/aw_browser_context.h" |
10 #include "android_webview/browser/aw_browser_main_parts.h" | 10 #include "android_webview/browser/aw_browser_main_parts.h" |
11 #include "android_webview/browser/aw_resource_context.h" | 11 #include "android_webview/browser/aw_resource_context.h" |
12 #include "android_webview/browser/browser_view_renderer.h" | 12 #include "android_webview/browser/browser_view_renderer.h" |
13 #include "android_webview/browser/gpu_memory_buffer_factory_impl.h" | 13 #include "android_webview/browser/gpu_memory_buffer_factory_impl.h" |
14 #include "android_webview/browser/hardware_renderer.h" | 14 #include "android_webview/browser/hardware_renderer.h" |
15 #include "android_webview/browser/net_disk_cache_remover.h" | 15 #include "android_webview/browser/net_disk_cache_remover.h" |
16 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele
gate.h" | 16 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele
gate.h" |
17 #include "android_webview/common/aw_hit_test_data.h" | 17 #include "android_webview/common/aw_hit_test_data.h" |
18 #include "android_webview/common/devtools_instrumentation.h" | 18 #include "android_webview/common/devtools_instrumentation.h" |
19 #include "android_webview/native/aw_autofill_manager_delegate.h" | 19 #include "android_webview/native/aw_autofill_manager_delegate.h" |
20 #include "android_webview/native/aw_browser_dependency_factory.h" | 20 #include "android_webview/native/aw_browser_dependency_factory.h" |
21 #include "android_webview/native/aw_contents_client_bridge.h" | 21 #include "android_webview/native/aw_contents_client_bridge.h" |
22 #include "android_webview/native/aw_contents_io_thread_client_impl.h" | 22 #include "android_webview/native/aw_contents_io_thread_client_impl.h" |
23 #include "android_webview/native/aw_pdf_exporter.h" | 23 #include "android_webview/native/aw_pdf_exporter.h" |
24 #include "android_webview/native/aw_picture.h" | 24 #include "android_webview/native/aw_picture.h" |
25 #include "android_webview/native/aw_web_contents_delegate.h" | 25 #include "android_webview/native/aw_web_contents_delegate.h" |
26 #include "android_webview/native/java_browser_view_renderer_helper.h" | 26 #include "android_webview/native/java_browser_view_renderer_helper.h" |
27 #include "android_webview/native/permission/aw_permission_request.h" | |
28 #include "android_webview/native/permission/permission_request_handler.h" | |
29 #include "android_webview/native/state_serializer.h" | 27 #include "android_webview/native/state_serializer.h" |
30 #include "android_webview/public/browser/draw_gl.h" | 28 #include "android_webview/public/browser/draw_gl.h" |
31 #include "base/android/jni_android.h" | 29 #include "base/android/jni_android.h" |
32 #include "base/android/jni_array.h" | 30 #include "base/android/jni_array.h" |
33 #include "base/android/jni_string.h" | 31 #include "base/android/jni_string.h" |
34 #include "base/android/scoped_java_ref.h" | 32 #include "base/android/scoped_java_ref.h" |
35 #include "base/atomicops.h" | 33 #include "base/atomicops.h" |
36 #include "base/bind.h" | 34 #include "base/bind.h" |
37 #include "base/callback.h" | 35 #include "base/callback.h" |
38 #include "base/memory/memory_pressure_listener.h" | 36 #include "base/memory/memory_pressure_listener.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 web_contents_.get(), | 162 web_contents_.get(), |
165 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)) { | 163 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)) { |
166 base::subtle::NoBarrier_AtomicIncrement(&g_instance_count, 1); | 164 base::subtle::NoBarrier_AtomicIncrement(&g_instance_count, 1); |
167 icon_helper_.reset(new IconHelper(web_contents_.get())); | 165 icon_helper_.reset(new IconHelper(web_contents_.get())); |
168 icon_helper_->SetListener(this); | 166 icon_helper_->SetListener(this); |
169 web_contents_->SetUserData(kAwContentsUserDataKey, | 167 web_contents_->SetUserData(kAwContentsUserDataKey, |
170 new AwContentsUserData(this)); | 168 new AwContentsUserData(this)); |
171 render_view_host_ext_.reset( | 169 render_view_host_ext_.reset( |
172 new AwRenderViewHostExt(this, web_contents_.get())); | 170 new AwRenderViewHostExt(this, web_contents_.get())); |
173 | 171 |
174 permission_request_handler_.reset(new PermissionRequestHandler(this)); | |
175 | |
176 AwAutofillManagerDelegate* autofill_manager_delegate = | 172 AwAutofillManagerDelegate* autofill_manager_delegate = |
177 AwAutofillManagerDelegate::FromWebContents(web_contents_.get()); | 173 AwAutofillManagerDelegate::FromWebContents(web_contents_.get()); |
178 if (autofill_manager_delegate) | 174 if (autofill_manager_delegate) |
179 InitAutofillIfNecessary(autofill_manager_delegate->GetSaveFormData()); | 175 InitAutofillIfNecessary(autofill_manager_delegate->GetSaveFormData()); |
180 } | 176 } |
181 | 177 |
182 void AwContents::SetJavaPeers(JNIEnv* env, | 178 void AwContents::SetJavaPeers(JNIEnv* env, |
183 jobject obj, | 179 jobject obj, |
184 jobject aw_contents, | 180 jobject aw_contents, |
185 jobject web_contents_delegate, | 181 jobject web_contents_delegate, |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 "onGeolocationPermissionsHidePrompt"); | 512 "onGeolocationPermissionsHidePrompt"); |
517 Java_AwContents_onGeolocationPermissionsHidePrompt(env, j_ref.obj()); | 513 Java_AwContents_onGeolocationPermissionsHidePrompt(env, j_ref.obj()); |
518 } | 514 } |
519 if (!pending_geolocation_prompts_.empty()) { | 515 if (!pending_geolocation_prompts_.empty()) { |
520 ShowGeolocationPromptHelper(java_ref_, | 516 ShowGeolocationPromptHelper(java_ref_, |
521 pending_geolocation_prompts_.front().first); | 517 pending_geolocation_prompts_.front().first); |
522 } | 518 } |
523 } | 519 } |
524 } | 520 } |
525 | 521 |
526 void AwContents::OnPermissionRequest(AwPermissionRequest* request) { | |
527 JNIEnv* env = AttachCurrentThread(); | |
528 ScopedJavaLocalRef<jobject> j_request = request->CreateJavaPeer(); | |
529 ScopedJavaLocalRef<jobject> j_ref = java_ref_.get(env); | |
530 if (j_request.is_null() || j_ref.is_null()) { | |
531 permission_request_handler_->CancelRequest( | |
532 request->GetOrigin(), request->GetResources()); | |
533 return; | |
534 } | |
535 | |
536 Java_AwContents_onPermissionRequest(env, j_ref.obj(), j_request.obj()); | |
537 } | |
538 | |
539 void AwContents::OnPermissionRequestCanceled(AwPermissionRequest* request) { | |
540 JNIEnv* env = AttachCurrentThread(); | |
541 ScopedJavaLocalRef<jobject> j_request = request->GetJavaObject(); | |
542 if (j_request.is_null()) | |
543 return; | |
544 | |
545 ScopedJavaLocalRef<jobject> j_ref = java_ref_.get(env); | |
546 Java_AwContents_onPermissionRequestCanceled( | |
547 env, j_ref.obj(), j_request.obj()); | |
548 } | |
549 | |
550 void AwContents::FindAllAsync(JNIEnv* env, jobject obj, jstring search_string) { | 522 void AwContents::FindAllAsync(JNIEnv* env, jobject obj, jstring search_string) { |
551 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 523 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
552 GetFindHelper()->FindAllAsync(ConvertJavaStringToUTF16(env, search_string)); | 524 GetFindHelper()->FindAllAsync(ConvertJavaStringToUTF16(env, search_string)); |
553 } | 525 } |
554 | 526 |
555 void AwContents::FindNext(JNIEnv* env, jobject obj, jboolean forward) { | 527 void AwContents::FindNext(JNIEnv* env, jobject obj, jboolean forward) { |
556 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 528 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
557 GetFindHelper()->FindNext(forward); | 529 GetFindHelper()->FindNext(forward); |
558 } | 530 } |
559 | 531 |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 | 1010 |
1039 void AwContents::ForceFakeComposite() { | 1011 void AwContents::ForceFakeComposite() { |
1040 browser_view_renderer_.ForceFakeCompositeSW(); | 1012 browser_view_renderer_.ForceFakeCompositeSW(); |
1041 } | 1013 } |
1042 | 1014 |
1043 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { | 1015 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { |
1044 g_should_download_favicons = true; | 1016 g_should_download_favicons = true; |
1045 } | 1017 } |
1046 | 1018 |
1047 } // namespace android_webview | 1019 } // namespace android_webview |
OLD | NEW |