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

Unified Diff: android_webview/native/aw_autofill_client.cc

Issue 772253003: Create an autofill Suggestion class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 6 years 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_autofill_client.cc
diff --git a/android_webview/native/aw_autofill_client.cc b/android_webview/native/aw_autofill_client.cc
index afe08ec5db622351f6bfc781dde52dad478f48d1..bc056e33b0ab64274bdafbe75e282fb59cc130d8 100644
--- a/android_webview/native/aw_autofill_client.cc
+++ b/android_webview/native/aw_autofill_client.cc
@@ -17,6 +17,7 @@
#include "base/prefs/pref_service.h"
#include "base/prefs/pref_service_factory.h"
#include "components/autofill/core/browser/autofill_popup_delegate.h"
+#include "components/autofill/core/browser/suggestion.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/autofill/core/common/autofill_pref_names.h"
#include "components/user_prefs/user_prefs.h"
@@ -80,13 +81,9 @@ AwAutofillClient::GetDatabase() {
void AwAutofillClient::ShowAutofillPopup(
const gfx::RectF& element_bounds,
base::i18n::TextDirection text_direction,
- const std::vector<base::string16>& values,
- const std::vector<base::string16>& labels,
- const std::vector<base::string16>& icons,
- const std::vector<int>& identifiers,
+ const std::vector<autofill::Suggestion>& suggestions,
base::WeakPtr<autofill::AutofillPopupDelegate> delegate) {
- values_ = values;
- identifiers_ = identifiers;
+ suggestions_ = suggestions;
delegate_ = delegate;
// Convert element_bounds to be in screen space.
@@ -96,34 +93,32 @@ void AwAutofillClient::ShowAutofillPopup(
ShowAutofillPopupImpl(element_bounds_in_screen_space,
text_direction == base::i18n::RIGHT_TO_LEFT,
- values,
- labels,
- identifiers);
+ suggestions);
}
void AwAutofillClient::ShowAutofillPopupImpl(
const gfx::RectF& element_bounds,
bool is_rtl,
- const std::vector<base::string16>& values,
- const std::vector<base::string16>& labels,
- const std::vector<int>& identifiers) {
+ const std::vector<autofill::Suggestion>& suggestions) {
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();
+ size_t count = suggestions.size();
ScopedJavaLocalRef<jobjectArray> data_array =
Java_AwAutofillClient_createAutofillSuggestionArray(env, count);
for (size_t i = 0; i < count; ++i) {
- ScopedJavaLocalRef<jstring> name = ConvertUTF16ToJavaString(env, values[i]);
+ ScopedJavaLocalRef<jstring> name =
+ ConvertUTF16ToJavaString(env, suggestions[i].value);
ScopedJavaLocalRef<jstring> label =
- ConvertUTF16ToJavaString(env, labels[i]);
+ ConvertUTF16ToJavaString(env, suggestions[i].label);
Java_AwAutofillClient_addToAutofillSuggestionArray(
- env, data_array.obj(), i, name.obj(), label.obj(), identifiers[i]);
+ env, data_array.obj(), i, name.obj(), label.obj(),
+ suggestions[i].frontend_id);
}
Java_AwAutofillClient_showAutofillPopup(env,
@@ -175,8 +170,10 @@ void AwAutofillClient::OnFirstUserGestureObserved() {
void AwAutofillClient::SuggestionSelected(JNIEnv* env,
jobject object,
jint position) {
- if (delegate_)
- delegate_->DidAcceptSuggestion(values_[position], identifiers_[position]);
+ if (delegate_) {
+ delegate_->DidAcceptSuggestion(suggestions_[position].value,
+ suggestions_[position].frontend_id);
+ }
}
void AwAutofillClient::HideRequestAutocompleteDialog() {
« no previous file with comments | « android_webview/native/aw_autofill_client.h ('k') | chrome/browser/autofill/content_autofill_driver_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698