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" |
11 #include "base/android/jni_android.h" | 11 #include "base/android/jni_android.h" |
12 #include "base/android/jni_string.h" | 12 #include "base/android/jni_string.h" |
13 #include "base/android/scoped_java_ref.h" | 13 #include "base/android/scoped_java_ref.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "components/autofill/core/browser/autofill_popup_delegate.h" | 15 #include "components/autofill/core/browser/autofill_popup_delegate.h" |
16 #include "components/autofill/core/browser/suggestion.h" | 16 #include "components/autofill/core/browser/suggestion.h" |
17 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 17 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
18 #include "components/autofill/core/common/autofill_pref_names.h" | 18 #include "components/autofill/core/common/autofill_pref_names.h" |
19 #include "components/prefs/pref_registry_simple.h" | 19 #include "components/prefs/pref_registry_simple.h" |
20 #include "components/prefs/pref_service.h" | 20 #include "components/prefs/pref_service.h" |
21 #include "components/prefs/pref_service_factory.h" | 21 #include "components/prefs/pref_service_factory.h" |
22 #include "components/user_prefs/user_prefs.h" | 22 #include "components/user_prefs/user_prefs.h" |
23 #include "content/public/browser/android/content_view_core.h" | |
23 #include "content/public/browser/navigation_entry.h" | 24 #include "content/public/browser/navigation_entry.h" |
24 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
25 #include "content/public/common/ssl_status.h" | 26 #include "content/public/common/ssl_status.h" |
26 #include "jni/AwAutofillClient_jni.h" | 27 #include "jni/AwAutofillClient_jni.h" |
28 #include "ui/android/view_android.h" | |
27 #include "ui/gfx/geometry/rect_f.h" | 29 #include "ui/gfx/geometry/rect_f.h" |
28 | 30 |
29 using base::android::AttachCurrentThread; | 31 using base::android::AttachCurrentThread; |
30 using base::android::ConvertUTF16ToJavaString; | 32 using base::android::ConvertUTF16ToJavaString; |
31 using base::android::ScopedJavaLocalRef; | 33 using base::android::ScopedJavaLocalRef; |
32 using content::WebContents; | 34 using content::WebContents; |
33 | 35 |
34 DEFINE_WEB_CONTENTS_USER_DATA_KEY(android_webview::AwAutofillClient); | 36 DEFINE_WEB_CONTENTS_USER_DATA_KEY(android_webview::AwAutofillClient); |
35 | 37 |
36 namespace android_webview { | 38 namespace android_webview { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 | 129 |
128 for (size_t i = 0; i < count; ++i) { | 130 for (size_t i = 0; i < count; ++i) { |
129 ScopedJavaLocalRef<jstring> name = | 131 ScopedJavaLocalRef<jstring> name = |
130 ConvertUTF16ToJavaString(env, suggestions[i].value); | 132 ConvertUTF16ToJavaString(env, suggestions[i].value); |
131 ScopedJavaLocalRef<jstring> label = | 133 ScopedJavaLocalRef<jstring> label = |
132 ConvertUTF16ToJavaString(env, suggestions[i].label); | 134 ConvertUTF16ToJavaString(env, suggestions[i].label); |
133 Java_AwAutofillClient_addToAutofillSuggestionArray( | 135 Java_AwAutofillClient_addToAutofillSuggestionArray( |
134 env, data_array.obj(), i, name.obj(), label.obj(), | 136 env, data_array.obj(), i, name.obj(), label.obj(), |
135 suggestions[i].frontend_id); | 137 suggestions[i].frontend_id); |
136 } | 138 } |
137 | 139 if (anchor_view_.is_null()) { |
140 anchor_view_.Reset(view_android_->AcquireAnchorView()); | |
no sievers
2016/07/14 23:14:31
Does this need to also be removed again somewhere?
Jinsuk Kim
2016/07/15 05:46:26
Added |Dismissed| and hooked it up to Java layer.
| |
141 } | |
142 view_android_->SetAnchorRect(anchor_view_.obj(), element_bounds); | |
138 Java_AwAutofillClient_showAutofillPopup(env, | 143 Java_AwAutofillClient_showAutofillPopup(env, |
139 obj.obj(), | 144 obj.obj(), |
140 element_bounds.x(), | 145 anchor_view_.obj(), |
141 element_bounds.y(), | |
142 element_bounds.width(), | 146 element_bounds.width(), |
143 element_bounds.height(), | |
144 is_rtl, | 147 is_rtl, |
145 data_array.obj()); | 148 data_array.obj()); |
146 } | 149 } |
147 | 150 |
148 void AwAutofillClient::UpdateAutofillPopupDataListValues( | 151 void AwAutofillClient::UpdateAutofillPopupDataListValues( |
149 const std::vector<base::string16>& values, | 152 const std::vector<base::string16>& values, |
150 const std::vector<base::string16>& labels) { | 153 const std::vector<base::string16>& labels) { |
151 // Leaving as an empty method since updating autofill popup window | 154 // Leaving as an empty method since updating autofill popup window |
152 // dynamically does not seem to be a useful feature for android webview. | 155 // dynamically does not seem to be a useful feature for android webview. |
153 // See crrev.com/18102002 if need to implement. | 156 // See crrev.com/18102002 if need to implement. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 void AwAutofillClient::SuggestionSelected(JNIEnv* env, | 209 void AwAutofillClient::SuggestionSelected(JNIEnv* env, |
207 const JavaParamRef<jobject>& object, | 210 const JavaParamRef<jobject>& object, |
208 jint position) { | 211 jint position) { |
209 if (delegate_) { | 212 if (delegate_) { |
210 delegate_->DidAcceptSuggestion(suggestions_[position].value, | 213 delegate_->DidAcceptSuggestion(suggestions_[position].value, |
211 suggestions_[position].frontend_id, | 214 suggestions_[position].frontend_id, |
212 position); | 215 position); |
213 } | 216 } |
214 } | 217 } |
215 | 218 |
219 void AwAutofillClient::SetViewAndroid(ui::ViewAndroid* view_android) { | |
220 view_android_ = view_android; | |
no sievers
2016/07/14 23:14:31
Actually, you can get ViewAndroid dynamically abov
Jinsuk Kim
2016/07/15 05:46:26
Ah, that's nice. Done.
| |
221 } | |
222 | |
216 void AwAutofillClient::ShowAutofillSettings() { | 223 void AwAutofillClient::ShowAutofillSettings() { |
217 NOTIMPLEMENTED(); | 224 NOTIMPLEMENTED(); |
218 } | 225 } |
219 | 226 |
220 void AwAutofillClient::ShowUnmaskPrompt( | 227 void AwAutofillClient::ShowUnmaskPrompt( |
221 const autofill::CreditCard& card, | 228 const autofill::CreditCard& card, |
222 UnmaskCardReason reason, | 229 UnmaskCardReason reason, |
223 base::WeakPtr<autofill::CardUnmaskDelegate> delegate) { | 230 base::WeakPtr<autofill::CardUnmaskDelegate> delegate) { |
224 NOTIMPLEMENTED(); | 231 NOTIMPLEMENTED(); |
225 } | 232 } |
(...skipping 26 matching lines...) Expand all Loading... | |
252 | 259 |
253 void AwAutofillClient::ScanCreditCard(const CreditCardScanCallback& callback) { | 260 void AwAutofillClient::ScanCreditCard(const CreditCardScanCallback& callback) { |
254 NOTIMPLEMENTED(); | 261 NOTIMPLEMENTED(); |
255 } | 262 } |
256 | 263 |
257 bool RegisterAwAutofillClient(JNIEnv* env) { | 264 bool RegisterAwAutofillClient(JNIEnv* env) { |
258 return RegisterNativesImpl(env); | 265 return RegisterNativesImpl(env); |
259 } | 266 } |
260 | 267 |
261 } // namespace android_webview | 268 } // namespace android_webview |
OLD | NEW |