OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_autofill_client.h" | 5 #include "android_webview/native/aw_autofill_client.h" |
6 | 6 |
7 #include "android_webview/browser/aw_browser_context.h" | 7 #include "android_webview/browser/aw_browser_context.h" |
8 #include "android_webview/browser/aw_content_browser_client.h" | 8 #include "android_webview/browser/aw_content_browser_client.h" |
9 #include "android_webview/browser/aw_form_database_service.h" | 9 #include "android_webview/browser/aw_form_database_service.h" |
10 #include "android_webview/native/aw_contents.h" | 10 #include "android_webview/native/aw_contents.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 ScopedJavaLocalRef<jobjectArray> data_array = | 128 ScopedJavaLocalRef<jobjectArray> data_array = |
129 Java_AwAutofillClient_createAutofillSuggestionArray(env, count); | 129 Java_AwAutofillClient_createAutofillSuggestionArray(env, count); |
130 | 130 |
131 for (size_t i = 0; i < count; ++i) { | 131 for (size_t i = 0; i < count; ++i) { |
132 ScopedJavaLocalRef<jstring> name = | 132 ScopedJavaLocalRef<jstring> name = |
133 ConvertUTF16ToJavaString(env, suggestions[i].value); | 133 ConvertUTF16ToJavaString(env, suggestions[i].value); |
134 ScopedJavaLocalRef<jstring> label = | 134 ScopedJavaLocalRef<jstring> label = |
135 ConvertUTF16ToJavaString(env, suggestions[i].label); | 135 ConvertUTF16ToJavaString(env, suggestions[i].label); |
136 Java_AwAutofillClient_addToAutofillSuggestionArray( | 136 Java_AwAutofillClient_addToAutofillSuggestionArray( |
137 env, data_array.obj(), i, name.obj(), label.obj(), | 137 env, data_array, i, name, label, suggestions[i].frontend_id); |
138 suggestions[i].frontend_id); | |
139 } | 138 } |
140 ui::ViewAndroid* view_android = web_contents_->GetNativeView(); | 139 ui::ViewAndroid* view_android = web_contents_->GetNativeView(); |
141 if (!view_android) | 140 if (!view_android) |
142 return; | 141 return; |
143 | 142 |
144 const ScopedJavaLocalRef<jobject> current_view = anchor_view_.view(); | 143 const ScopedJavaLocalRef<jobject> current_view = anchor_view_.view(); |
145 if (current_view.is_null()) | 144 if (current_view.is_null()) |
146 anchor_view_ = view_android->AcquireAnchorView(); | 145 anchor_view_ = view_android->AcquireAnchorView(); |
147 | 146 |
148 const ScopedJavaLocalRef<jobject> view = anchor_view_.view(); | 147 const ScopedJavaLocalRef<jobject> view = anchor_view_.view(); |
149 if (view.is_null()) | 148 if (view.is_null()) |
150 return; | 149 return; |
151 | 150 |
152 view_android->SetAnchorRect(view, element_bounds); | 151 view_android->SetAnchorRect(view, element_bounds); |
153 Java_AwAutofillClient_showAutofillPopup(env, | 152 Java_AwAutofillClient_showAutofillPopup(env, obj, view, is_rtl, data_array); |
154 obj.obj(), | |
155 view.obj(), | |
156 is_rtl, | |
157 data_array.obj()); | |
158 } | 153 } |
159 | 154 |
160 void AwAutofillClient::UpdateAutofillPopupDataListValues( | 155 void AwAutofillClient::UpdateAutofillPopupDataListValues( |
161 const std::vector<base::string16>& values, | 156 const std::vector<base::string16>& values, |
162 const std::vector<base::string16>& labels) { | 157 const std::vector<base::string16>& labels) { |
163 // Leaving as an empty method since updating autofill popup window | 158 // Leaving as an empty method since updating autofill popup window |
164 // dynamically does not seem to be a useful feature for android webview. | 159 // dynamically does not seem to be a useful feature for android webview. |
165 // See crrev.com/18102002 if need to implement. | 160 // See crrev.com/18102002 if need to implement. |
166 } | 161 } |
167 | 162 |
168 void AwAutofillClient::HideAutofillPopup() { | 163 void AwAutofillClient::HideAutofillPopup() { |
169 JNIEnv* env = AttachCurrentThread(); | 164 JNIEnv* env = AttachCurrentThread(); |
170 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 165 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
171 if (obj.is_null()) | 166 if (obj.is_null()) |
172 return; | 167 return; |
173 delegate_.reset(); | 168 delegate_.reset(); |
174 Java_AwAutofillClient_hideAutofillPopup(env, obj.obj()); | 169 Java_AwAutofillClient_hideAutofillPopup(env, obj); |
175 } | 170 } |
176 | 171 |
177 bool AwAutofillClient::IsAutocompleteEnabled() { | 172 bool AwAutofillClient::IsAutocompleteEnabled() { |
178 return GetSaveFormData(); | 173 return GetSaveFormData(); |
179 } | 174 } |
180 | 175 |
181 void AwAutofillClient::PropagateAutofillPredictions( | 176 void AwAutofillClient::PropagateAutofillPredictions( |
182 content::RenderFrameHost* rfh, | 177 content::RenderFrameHost* rfh, |
183 const std::vector<autofill::FormStructure*>& forms) { | 178 const std::vector<autofill::FormStructure*>& forms) { |
184 | 179 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 | 270 |
276 void AwAutofillClient::ScanCreditCard(const CreditCardScanCallback& callback) { | 271 void AwAutofillClient::ScanCreditCard(const CreditCardScanCallback& callback) { |
277 NOTIMPLEMENTED(); | 272 NOTIMPLEMENTED(); |
278 } | 273 } |
279 | 274 |
280 bool RegisterAwAutofillClient(JNIEnv* env) { | 275 bool RegisterAwAutofillClient(JNIEnv* env) { |
281 return RegisterNativesImpl(env); | 276 return RegisterNativesImpl(env); |
282 } | 277 } |
283 | 278 |
284 } // namespace android_webview | 279 } // namespace android_webview |
OLD | NEW |