Chromium Code Reviews| 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 "android_webview/browser/aw_autofill_external_delegate.h" | |
| 8 #include "android_webview/browser/aw_browser_context.h" | 7 #include "android_webview/browser/aw_browser_context.h" |
| 9 #include "android_webview/browser/aw_browser_main_parts.h" | 8 #include "android_webview/browser/aw_browser_main_parts.h" |
| 10 #include "android_webview/browser/browser_view_renderer_impl.h" | 9 #include "android_webview/browser/browser_view_renderer_impl.h" |
| 11 #include "android_webview/browser/gpu_memory_buffer_impl.h" | 10 #include "android_webview/browser/gpu_memory_buffer_impl.h" |
| 12 #include "android_webview/browser/net_disk_cache_remover.h" | 11 #include "android_webview/browser/net_disk_cache_remover.h" |
| 13 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h" | 12 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h" |
| 14 #include "android_webview/common/aw_hit_test_data.h" | 13 #include "android_webview/common/aw_hit_test_data.h" |
| 14 #include "android_webview/native/aw_autofill_external_delegate.h" | |
| 15 #include "android_webview/native/aw_autofill_manager_delegate.h" | |
| 15 #include "android_webview/native/aw_browser_dependency_factory.h" | 16 #include "android_webview/native/aw_browser_dependency_factory.h" |
| 16 #include "android_webview/native/aw_contents_client_bridge.h" | 17 #include "android_webview/native/aw_contents_client_bridge.h" |
| 17 #include "android_webview/native/aw_contents_io_thread_client_impl.h" | 18 #include "android_webview/native/aw_contents_io_thread_client_impl.h" |
| 18 #include "android_webview/native/aw_web_contents_delegate.h" | 19 #include "android_webview/native/aw_web_contents_delegate.h" |
| 19 #include "android_webview/native/java_browser_view_renderer_helper.h" | 20 #include "android_webview/native/java_browser_view_renderer_helper.h" |
| 20 #include "android_webview/native/state_serializer.h" | 21 #include "android_webview/native/state_serializer.h" |
| 21 #include "android_webview/public/browser/draw_gl.h" | 22 #include "android_webview/public/browser/draw_gl.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" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 37 #include "content/public/browser/cert_store.h" | 38 #include "content/public/browser/cert_store.h" |
| 38 #include "content/public/browser/navigation_entry.h" | 39 #include "content/public/browser/navigation_entry.h" |
| 39 #include "content/public/browser/render_process_host.h" | 40 #include "content/public/browser/render_process_host.h" |
| 40 #include "content/public/browser/render_view_host.h" | 41 #include "content/public/browser/render_view_host.h" |
| 41 #include "content/public/browser/web_contents.h" | 42 #include "content/public/browser/web_contents.h" |
| 42 #include "content/public/common/ssl_status.h" | 43 #include "content/public/common/ssl_status.h" |
| 43 #include "jni/AwContents_jni.h" | 44 #include "jni/AwContents_jni.h" |
| 44 #include "net/cert/x509_certificate.h" | 45 #include "net/cert/x509_certificate.h" |
| 45 #include "ui/base/l10n/l10n_util_android.h" | 46 #include "ui/base/l10n/l10n_util_android.h" |
| 46 #include "ui/gfx/android/java_bitmap.h" | 47 #include "ui/gfx/android/java_bitmap.h" |
| 48 #include "ui/gfx/rect_f.h" | |
| 47 | 49 |
| 48 struct AwDrawSWFunctionTable; | 50 struct AwDrawSWFunctionTable; |
| 49 struct AwDrawGLFunctionTable; | 51 struct AwDrawGLFunctionTable; |
| 50 | 52 |
| 51 using autofill::AutofillManager; | 53 using autofill::AutofillManager; |
| 52 using base::android::AttachCurrentThread; | 54 using base::android::AttachCurrentThread; |
| 53 using base::android::ConvertJavaStringToUTF16; | 55 using base::android::ConvertJavaStringToUTF16; |
| 54 using base::android::ConvertJavaStringToUTF8; | 56 using base::android::ConvertJavaStringToUTF8; |
| 55 using base::android::ConvertUTF16ToJavaString; | 57 using base::android::ConvertUTF16ToJavaString; |
| 56 using base::android::ConvertUTF8ToJavaString; | 58 using base::android::ConvertUTF8ToJavaString; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 if (autofill_manager_delegate) | 159 if (autofill_manager_delegate) |
| 158 InitAutofillIfNecessary(autofill_manager_delegate->GetSaveFormData()); | 160 InitAutofillIfNecessary(autofill_manager_delegate->GetSaveFormData()); |
| 159 } | 161 } |
| 160 | 162 |
| 161 void AwContents::SetSaveFormData(bool enabled) { | 163 void AwContents::SetSaveFormData(bool enabled) { |
| 162 InitAutofillIfNecessary(enabled); | 164 InitAutofillIfNecessary(enabled); |
| 163 AwAutofillManagerDelegate::FromWebContents(web_contents_.get())-> | 165 AwAutofillManagerDelegate::FromWebContents(web_contents_.get())-> |
| 164 SetSaveFormData(enabled); | 166 SetSaveFormData(enabled); |
| 165 } | 167 } |
| 166 | 168 |
| 169 void AwContents::ShowAutofillPopup(const gfx::RectF& element_bounds, | |
| 170 const std::vector<string16>& values, | |
| 171 const std::vector<string16>& labels, | |
| 172 const std::vector<int>& identifiers) { | |
| 173 JNIEnv* env = AttachCurrentThread(); | |
| 174 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | |
| 175 if (obj.is_null()) | |
| 176 return; | |
| 177 | |
| 178 // We need an array of AutofillSuggestion. | |
| 179 size_t count = values.size(); | |
| 180 | |
| 181 ScopedJavaLocalRef<jobjectArray> data_array = | |
| 182 Java_AwContents_createAutofillSuggestionArray(env, count); | |
|
benm (inactive)
2013/06/04 13:35:18
Do we really need a JNI hop for this?
env->NewObj
| |
| 183 | |
| 184 for (size_t i = 0; i < count; ++i) { | |
| 185 ScopedJavaLocalRef<jstring> name = | |
| 186 base::android::ConvertUTF16ToJavaString(env, values[i]); | |
| 187 ScopedJavaLocalRef<jstring> label = | |
| 188 base::android::ConvertUTF16ToJavaString(env, | |
| 189 labels[i]); | |
| 190 Java_AwContents_addToAutofillSuggestionArray( | |
|
benm (inactive)
2013/06/04 13:35:18
ditto, can we just populate the array using native
| |
| 191 env, | |
| 192 data_array.obj(), | |
| 193 i, | |
| 194 name.obj(), | |
| 195 label.obj(), | |
| 196 identifiers[i]); | |
| 197 } | |
| 198 | |
| 199 Java_AwContents_showAutofillPopup(env, obj.obj(), element_bounds.x(), | |
| 200 element_bounds.y(), element_bounds.width(), | |
| 201 element_bounds.height(), data_array.obj()); | |
| 202 } | |
| 203 | |
| 204 void AwContents::HideAutofillPopup() { | |
| 205 JNIEnv* env = AttachCurrentThread(); | |
| 206 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | |
| 207 if (obj.is_null()) | |
| 208 return; | |
| 209 Java_AwContents_hideAutofillPopup(env, obj.obj()); | |
| 210 } | |
| 211 | |
| 212 void AwContents::SuggestionSelected(JNIEnv* env, jobject object, int position) { | |
| 213 AwAutofillManagerDelegate::FromWebContents(web_contents_.get())-> | |
| 214 SuggestionSelected(position); | |
| 215 } | |
| 216 | |
| 167 void AwContents::InitAutofillIfNecessary(bool enabled) { | 217 void AwContents::InitAutofillIfNecessary(bool enabled) { |
| 168 // Do not initialize if the feature is not enabled. | 218 // Do not initialize if the feature is not enabled. |
| 169 if (!enabled) | 219 if (!enabled) |
| 170 return; | 220 return; |
| 171 | 221 |
| 172 content::WebContents* web_contents = web_contents_.get(); | 222 content::WebContents* web_contents = web_contents_.get(); |
| 173 if (AutofillManager::FromWebContents(web_contents)) | 223 if (AutofillManager::FromWebContents(web_contents)) |
| 174 return; | 224 return; |
| 175 | 225 |
| 176 AwBrowserContext::FromWebContents(web_contents)-> | 226 AwBrowserContext::FromWebContents(web_contents)-> |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 702 return browser_view_renderer_->CapturePicture(); | 752 return browser_view_renderer_->CapturePicture(); |
| 703 } | 753 } |
| 704 | 754 |
| 705 void AwContents::EnableOnNewPicture(JNIEnv* env, | 755 void AwContents::EnableOnNewPicture(JNIEnv* env, |
| 706 jobject obj, | 756 jobject obj, |
| 707 jboolean enabled) { | 757 jboolean enabled) { |
| 708 browser_view_renderer_->EnableOnNewPicture(enabled); | 758 browser_view_renderer_->EnableOnNewPicture(enabled); |
| 709 } | 759 } |
| 710 | 760 |
| 711 } // namespace android_webview | 761 } // namespace android_webview |
| OLD | NEW |