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

Side by Side Diff: android_webview/native/aw_autofill_client.cc

Issue 2103243002: Factor out ContentViewAndroidDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 4 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 unified diff | Download patch
OLDNEW
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::JavaParamRef; 33 using base::android::JavaParamRef;
32 using base::android::ScopedJavaLocalRef; 34 using base::android::ScopedJavaLocalRef;
33 using content::WebContents; 35 using content::WebContents;
34 36
35 DEFINE_WEB_CONTENTS_USER_DATA_KEY(android_webview::AwAutofillClient); 37 DEFINE_WEB_CONTENTS_USER_DATA_KEY(android_webview::AwAutofillClient);
36 38
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 130
129 for (size_t i = 0; i < count; ++i) { 131 for (size_t i = 0; i < count; ++i) {
130 ScopedJavaLocalRef<jstring> name = 132 ScopedJavaLocalRef<jstring> name =
131 ConvertUTF16ToJavaString(env, suggestions[i].value); 133 ConvertUTF16ToJavaString(env, suggestions[i].value);
132 ScopedJavaLocalRef<jstring> label = 134 ScopedJavaLocalRef<jstring> label =
133 ConvertUTF16ToJavaString(env, suggestions[i].label); 135 ConvertUTF16ToJavaString(env, suggestions[i].label);
134 Java_AwAutofillClient_addToAutofillSuggestionArray( 136 Java_AwAutofillClient_addToAutofillSuggestionArray(
135 env, data_array.obj(), i, name.obj(), label.obj(), 137 env, data_array.obj(), i, name.obj(), label.obj(),
136 suggestions[i].frontend_id); 138 suggestions[i].frontend_id);
137 } 139 }
140 ui::ViewAndroid* view_android = web_contents_->GetNativeView();
141 if (!view_android)
142 return;
138 143
144 const ScopedJavaLocalRef<jobject> current_view = anchor_view_.view();
145 if (current_view.is_null())
146 anchor_view_ = view_android->AcquireAnchorView();
147
148 const ScopedJavaLocalRef<jobject> view = anchor_view_.view();
149 if (view.is_null())
150 return;
151
152 view_android->SetAnchorRect(view, element_bounds);
139 Java_AwAutofillClient_showAutofillPopup(env, 153 Java_AwAutofillClient_showAutofillPopup(env,
140 obj.obj(), 154 obj.obj(),
141 element_bounds.x(), 155 view.obj(),
142 element_bounds.y(),
143 element_bounds.width(),
144 element_bounds.height(),
145 is_rtl, 156 is_rtl,
146 data_array.obj()); 157 data_array.obj());
147 } 158 }
148 159
149 void AwAutofillClient::UpdateAutofillPopupDataListValues( 160 void AwAutofillClient::UpdateAutofillPopupDataListValues(
150 const std::vector<base::string16>& values, 161 const std::vector<base::string16>& values,
151 const std::vector<base::string16>& labels) { 162 const std::vector<base::string16>& labels) {
152 // Leaving as an empty method since updating autofill popup window 163 // Leaving as an empty method since updating autofill popup window
153 // dynamically does not seem to be a useful feature for android webview. 164 // dynamically does not seem to be a useful feature for android webview.
154 // See crrev.com/18102002 if need to implement. 165 // See crrev.com/18102002 if need to implement.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 !(ssl_status.content_status & 208 !(ssl_status.content_status &
198 content::SSLStatus::RAN_INSECURE_CONTENT); 209 content::SSLStatus::RAN_INSECURE_CONTENT);
199 } 210 }
200 211
201 bool AwAutofillClient::ShouldShowSigninPromo() { 212 bool AwAutofillClient::ShouldShowSigninPromo() {
202 return false; 213 return false;
203 } 214 }
204 215
205 void AwAutofillClient::StartSigninFlow() {} 216 void AwAutofillClient::StartSigninFlow() {}
206 217
218 void AwAutofillClient::Dismissed(JNIEnv* env,
219 const JavaParamRef<jobject>& obj) {
220 anchor_view_.Reset();
221 }
222
207 void AwAutofillClient::SuggestionSelected(JNIEnv* env, 223 void AwAutofillClient::SuggestionSelected(JNIEnv* env,
208 const JavaParamRef<jobject>& object, 224 const JavaParamRef<jobject>& object,
209 jint position) { 225 jint position) {
210 if (delegate_) { 226 if (delegate_) {
211 delegate_->DidAcceptSuggestion(suggestions_[position].value, 227 delegate_->DidAcceptSuggestion(suggestions_[position].value,
212 suggestions_[position].frontend_id, 228 suggestions_[position].frontend_id,
213 position); 229 position);
214 } 230 }
215 } 231 }
216 232
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 275
260 void AwAutofillClient::ScanCreditCard(const CreditCardScanCallback& callback) { 276 void AwAutofillClient::ScanCreditCard(const CreditCardScanCallback& callback) {
261 NOTIMPLEMENTED(); 277 NOTIMPLEMENTED();
262 } 278 }
263 279
264 bool RegisterAwAutofillClient(JNIEnv* env) { 280 bool RegisterAwAutofillClient(JNIEnv* env) {
265 return RegisterNativesImpl(env); 281 return RegisterNativesImpl(env);
266 } 282 }
267 283
268 } // namespace android_webview 284 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698