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" |
27 #include "android_webview/native/state_serializer.h" | 29 #include "android_webview/native/state_serializer.h" |
28 #include "android_webview/public/browser/draw_gl.h" | 30 #include "android_webview/public/browser/draw_gl.h" |
29 #include "base/android/jni_android.h" | 31 #include "base/android/jni_android.h" |
30 #include "base/android/jni_array.h" | 32 #include "base/android/jni_array.h" |
31 #include "base/android/jni_string.h" | 33 #include "base/android/jni_string.h" |
32 #include "base/android/scoped_java_ref.h" | 34 #include "base/android/scoped_java_ref.h" |
33 #include "base/atomicops.h" | 35 #include "base/atomicops.h" |
34 #include "base/bind.h" | 36 #include "base/bind.h" |
35 #include "base/callback.h" | 37 #include "base/callback.h" |
36 #include "base/memory/memory_pressure_listener.h" | 38 #include "base/memory/memory_pressure_listener.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 web_contents_.get(), | 164 web_contents_.get(), |
163 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)) { | 165 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)) { |
164 base::subtle::NoBarrier_AtomicIncrement(&g_instance_count, 1); | 166 base::subtle::NoBarrier_AtomicIncrement(&g_instance_count, 1); |
165 icon_helper_.reset(new IconHelper(web_contents_.get())); | 167 icon_helper_.reset(new IconHelper(web_contents_.get())); |
166 icon_helper_->SetListener(this); | 168 icon_helper_->SetListener(this); |
167 web_contents_->SetUserData(kAwContentsUserDataKey, | 169 web_contents_->SetUserData(kAwContentsUserDataKey, |
168 new AwContentsUserData(this)); | 170 new AwContentsUserData(this)); |
169 render_view_host_ext_.reset( | 171 render_view_host_ext_.reset( |
170 new AwRenderViewHostExt(this, web_contents_.get())); | 172 new AwRenderViewHostExt(this, web_contents_.get())); |
171 | 173 |
| 174 permission_request_handler_.reset(new PermissionRequestHandler(this)); |
| 175 |
172 AwAutofillManagerDelegate* autofill_manager_delegate = | 176 AwAutofillManagerDelegate* autofill_manager_delegate = |
173 AwAutofillManagerDelegate::FromWebContents(web_contents_.get()); | 177 AwAutofillManagerDelegate::FromWebContents(web_contents_.get()); |
174 if (autofill_manager_delegate) | 178 if (autofill_manager_delegate) |
175 InitAutofillIfNecessary(autofill_manager_delegate->GetSaveFormData()); | 179 InitAutofillIfNecessary(autofill_manager_delegate->GetSaveFormData()); |
176 } | 180 } |
177 | 181 |
178 void AwContents::SetJavaPeers(JNIEnv* env, | 182 void AwContents::SetJavaPeers(JNIEnv* env, |
179 jobject obj, | 183 jobject obj, |
180 jobject aw_contents, | 184 jobject aw_contents, |
181 jobject web_contents_delegate, | 185 jobject web_contents_delegate, |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 "onGeolocationPermissionsHidePrompt"); | 515 "onGeolocationPermissionsHidePrompt"); |
512 Java_AwContents_onGeolocationPermissionsHidePrompt(env, j_ref.obj()); | 516 Java_AwContents_onGeolocationPermissionsHidePrompt(env, j_ref.obj()); |
513 } | 517 } |
514 if (!pending_geolocation_prompts_.empty()) { | 518 if (!pending_geolocation_prompts_.empty()) { |
515 ShowGeolocationPromptHelper(java_ref_, | 519 ShowGeolocationPromptHelper(java_ref_, |
516 pending_geolocation_prompts_.front().first); | 520 pending_geolocation_prompts_.front().first); |
517 } | 521 } |
518 } | 522 } |
519 } | 523 } |
520 | 524 |
| 525 void AwContents::OnPermissionRequest(AwPermissionRequest* request) { |
| 526 JNIEnv* env = AttachCurrentThread(); |
| 527 ScopedJavaLocalRef<jobject> j_request = request->CreateJavaPeer(); |
| 528 ScopedJavaLocalRef<jobject> j_ref = java_ref_.get(env); |
| 529 if (j_request.is_null() || j_ref.is_null()) { |
| 530 permission_request_handler_->CancelRequest( |
| 531 request->GetOrigin(), request->GetResources()); |
| 532 return; |
| 533 } |
| 534 |
| 535 Java_AwContents_onPermissionRequest(env, j_ref.obj(), j_request.obj()); |
| 536 } |
| 537 |
| 538 void AwContents::OnPermissionRequestCanceled(AwPermissionRequest* request) { |
| 539 JNIEnv* env = AttachCurrentThread(); |
| 540 ScopedJavaLocalRef<jobject> j_request = request->GetJavaObject(); |
| 541 if (j_request.is_null()) |
| 542 return; |
| 543 |
| 544 ScopedJavaLocalRef<jobject> j_ref = java_ref_.get(env); |
| 545 Java_AwContents_onPermissionRequestCanceled( |
| 546 env, j_ref.obj(), j_request.obj()); |
| 547 } |
| 548 |
521 void AwContents::FindAllAsync(JNIEnv* env, jobject obj, jstring search_string) { | 549 void AwContents::FindAllAsync(JNIEnv* env, jobject obj, jstring search_string) { |
522 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 550 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
523 GetFindHelper()->FindAllAsync(ConvertJavaStringToUTF16(env, search_string)); | 551 GetFindHelper()->FindAllAsync(ConvertJavaStringToUTF16(env, search_string)); |
524 } | 552 } |
525 | 553 |
526 void AwContents::FindNext(JNIEnv* env, jobject obj, jboolean forward) { | 554 void AwContents::FindNext(JNIEnv* env, jobject obj, jboolean forward) { |
527 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 555 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
528 GetFindHelper()->FindNext(forward); | 556 GetFindHelper()->FindNext(forward); |
529 } | 557 } |
530 | 558 |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 | 1080 |
1053 void AwContents::ForceFakeComposite() { | 1081 void AwContents::ForceFakeComposite() { |
1054 browser_view_renderer_.ForceFakeCompositeSW(); | 1082 browser_view_renderer_.ForceFakeCompositeSW(); |
1055 } | 1083 } |
1056 | 1084 |
1057 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { | 1085 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { |
1058 g_should_download_favicons = true; | 1086 g_should_download_favicons = true; |
1059 } | 1087 } |
1060 | 1088 |
1061 } // namespace android_webview | 1089 } // namespace android_webview |
OLD | NEW |