Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2888)

Unified Diff: android_webview/native/aw_contents.cc

Issue 16212007: Implement the autofill UI for chromium powered android webview. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue15097004
Patch Set: move ui files Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: android_webview/native/aw_contents.cc
diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc
index 723e04da8d8a0f9875d608c521cc5352ae8f311f..f2a8e032de8fbd162875f4bb99ae60835d347d30 100644
--- a/android_webview/native/aw_contents.cc
+++ b/android_webview/native/aw_contents.cc
@@ -4,7 +4,6 @@
#include "android_webview/native/aw_contents.h"
-#include "android_webview/browser/aw_autofill_external_delegate.h"
#include "android_webview/browser/aw_browser_context.h"
#include "android_webview/browser/aw_browser_main_parts.h"
#include "android_webview/browser/browser_view_renderer_impl.h"
@@ -12,6 +11,8 @@
#include "android_webview/browser/net_disk_cache_remover.h"
#include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.h"
#include "android_webview/common/aw_hit_test_data.h"
+#include "android_webview/native/aw_autofill_external_delegate.h"
+#include "android_webview/native/aw_autofill_manager_delegate.h"
#include "android_webview/native/aw_browser_dependency_factory.h"
#include "android_webview/native/aw_contents_client_bridge.h"
#include "android_webview/native/aw_contents_io_thread_client_impl.h"
@@ -44,6 +45,7 @@
#include "net/cert/x509_certificate.h"
#include "ui/base/l10n/l10n_util_android.h"
#include "ui/gfx/android/java_bitmap.h"
+#include "ui/gfx/rect_f.h"
struct AwDrawSWFunctionTable;
struct AwDrawGLFunctionTable;
@@ -164,6 +166,54 @@ void AwContents::SetSaveFormData(bool enabled) {
SetSaveFormData(enabled);
}
+void AwContents::ShowAutofillPopup(const gfx::RectF& element_bounds,
+ const std::vector<string16>& values,
+ const std::vector<string16>& labels,
+ const std::vector<int>& identifiers) {
+ JNIEnv* env = AttachCurrentThread();
+ ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
+ if (obj.is_null())
+ return;
+
+ // We need an array of AutofillSuggestion.
+ size_t count = values.size();
+
+ ScopedJavaLocalRef<jobjectArray> data_array =
+ Java_AwContents_createAutofillSuggestionArray(env, count);
benm (inactive) 2013/06/04 13:35:18 Do we really need a JNI hop for this? env->NewObj
+
+ for (size_t i = 0; i < count; ++i) {
+ ScopedJavaLocalRef<jstring> name =
+ base::android::ConvertUTF16ToJavaString(env, values[i]);
+ ScopedJavaLocalRef<jstring> label =
+ base::android::ConvertUTF16ToJavaString(env,
+ labels[i]);
+ Java_AwContents_addToAutofillSuggestionArray(
benm (inactive) 2013/06/04 13:35:18 ditto, can we just populate the array using native
+ env,
+ data_array.obj(),
+ i,
+ name.obj(),
+ label.obj(),
+ identifiers[i]);
+ }
+
+ Java_AwContents_showAutofillPopup(env, obj.obj(), element_bounds.x(),
+ element_bounds.y(), element_bounds.width(),
+ element_bounds.height(), data_array.obj());
+}
+
+void AwContents::HideAutofillPopup() {
+ JNIEnv* env = AttachCurrentThread();
+ ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
+ if (obj.is_null())
+ return;
+ Java_AwContents_hideAutofillPopup(env, obj.obj());
+}
+
+void AwContents::SuggestionSelected(JNIEnv* env, jobject object, int position) {
+ AwAutofillManagerDelegate::FromWebContents(web_contents_.get())->
+ SuggestionSelected(position);
+}
+
void AwContents::InitAutofillIfNecessary(bool enabled) {
// Do not initialize if the feature is not enabled.
if (!enabled)

Powered by Google App Engine
This is Rietveld 408576698