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/browser/aw_pref_store.h" | 10 #include "android_webview/browser/aw_pref_store.h" |
11 #include "android_webview/native/aw_contents.h" | 11 #include "android_webview/native/aw_contents.h" |
12 #include "base/android/jni_android.h" | 12 #include "base/android/jni_android.h" |
13 #include "base/android/jni_string.h" | 13 #include "base/android/jni_string.h" |
14 #include "base/android/scoped_java_ref.h" | 14 #include "base/android/scoped_java_ref.h" |
| 15 #include "base/i18n/rtl.h" |
15 #include "base/logging.h" | 16 #include "base/logging.h" |
16 #include "base/prefs/pref_registry_simple.h" | 17 #include "base/prefs/pref_registry_simple.h" |
17 #include "base/prefs/pref_service.h" | 18 #include "base/prefs/pref_service.h" |
18 #include "base/prefs/pref_service_factory.h" | 19 #include "base/prefs/pref_service_factory.h" |
19 #include "components/autofill/core/browser/autofill_popup_delegate.h" | 20 #include "components/autofill/core/browser/autofill_popup_delegate.h" |
20 #include "components/autofill/core/browser/suggestion.h" | 21 #include "components/autofill/core/browser/suggestion.h" |
21 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 22 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
22 #include "components/autofill/core/common/autofill_pref_names.h" | 23 #include "components/autofill/core/common/autofill_pref_names.h" |
23 #include "components/user_prefs/user_prefs.h" | 24 #include "components/user_prefs/user_prefs.h" |
24 #include "content/public/browser/navigation_entry.h" | 25 #include "content/public/browser/navigation_entry.h" |
25 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
26 #include "content/public/common/ssl_status.h" | 27 #include "content/public/common/ssl_status.h" |
27 #include "jni/AwAutofillClient_jni.h" | 28 #include "jni/AwAutofillClient_jni.h" |
28 | 29 |
29 using base::android::AttachCurrentThread; | 30 using base::android::AttachCurrentThread; |
30 using base::android::ConvertUTF16ToJavaString; | 31 using base::android::ConvertUTF16ToJavaString; |
31 using base::android::ScopedJavaLocalRef; | 32 using base::android::ScopedJavaLocalRef; |
32 using content::WebContents; | 33 using content::WebContents; |
33 | 34 |
34 DEFINE_WEB_CONTENTS_USER_DATA_KEY(android_webview::AwAutofillClient); | 35 DEFINE_WEB_CONTENTS_USER_DATA_KEY(android_webview::AwAutofillClient); |
35 | 36 |
36 namespace android_webview { | 37 namespace android_webview { |
37 | 38 |
38 // Ownership: The native object is created (if autofill enabled) and owned by | 39 // Ownership: The native object is created (if autofill enabled) and owned by |
39 // AwContents. The native object creates the java peer which handles most | 40 // AwContents. The native object creates the java peer which handles most |
40 // autofill functionality at the java side. The java peer is owned by Java | 41 // autofill functionality at the java side. The java peer is owned by Java |
41 // AwContents. The native object only maintains a weak ref to it. | 42 // AwContents. The native object only maintains a weak ref to it. |
42 AwAutofillClient::AwAutofillClient(WebContents* contents) | 43 AwAutofillClient::AwAutofillClient(WebContents* contents) |
43 : web_contents_(contents), save_form_data_(false) { | 44 : web_contents_(contents), |
| 45 save_form_data_(false), |
| 46 application_locale_(base::i18n::GetConfiguredLocale()) { |
44 JNIEnv* env = AttachCurrentThread(); | 47 JNIEnv* env = AttachCurrentThread(); |
45 ScopedJavaLocalRef<jobject> delegate; | 48 ScopedJavaLocalRef<jobject> delegate; |
46 delegate.Reset( | 49 delegate.Reset( |
47 Java_AwAutofillClient_create(env, reinterpret_cast<intptr_t>(this))); | 50 Java_AwAutofillClient_create(env, reinterpret_cast<intptr_t>(this))); |
48 | 51 |
49 AwContents* aw_contents = AwContents::FromWebContents(web_contents_); | 52 AwContents* aw_contents = AwContents::FromWebContents(web_contents_); |
50 aw_contents->SetAwAutofillClient(delegate.obj()); | 53 aw_contents->SetAwAutofillClient(delegate.obj()); |
51 java_ref_ = JavaObjectWeakGlobalRef(env, delegate.obj()); | 54 java_ref_ = JavaObjectWeakGlobalRef(env, delegate.obj()); |
52 } | 55 } |
53 | 56 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 193 |
191 ssl_status = navigation_entry->GetSSL(); | 194 ssl_status = navigation_entry->GetSSL(); |
192 // Note: The implementation below is a copy of the one in | 195 // Note: The implementation below is a copy of the one in |
193 // ChromeAutofillClient::IsContextSecure, and should be kept in sync | 196 // ChromeAutofillClient::IsContextSecure, and should be kept in sync |
194 // until crbug.com/505388 gets implemented. | 197 // until crbug.com/505388 gets implemented. |
195 return ssl_status.security_style == | 198 return ssl_status.security_style == |
196 content::SECURITY_STYLE_AUTHENTICATED && | 199 content::SECURITY_STYLE_AUTHENTICATED && |
197 ssl_status.content_status == content::SSLStatus::NORMAL_CONTENT; | 200 ssl_status.content_status == content::SSLStatus::NORMAL_CONTENT; |
198 } | 201 } |
199 | 202 |
| 203 const std::string& AwAutofillClient::GetApplicationLocale() { |
| 204 return application_locale_; |
| 205 } |
| 206 |
200 void AwAutofillClient::SuggestionSelected(JNIEnv* env, | 207 void AwAutofillClient::SuggestionSelected(JNIEnv* env, |
201 const JavaParamRef<jobject>& object, | 208 const JavaParamRef<jobject>& object, |
202 jint position) { | 209 jint position) { |
203 if (delegate_) { | 210 if (delegate_) { |
204 delegate_->DidAcceptSuggestion(suggestions_[position].value, | 211 delegate_->DidAcceptSuggestion(suggestions_[position].value, |
205 suggestions_[position].frontend_id, | 212 suggestions_[position].frontend_id, |
206 position); | 213 position); |
207 } | 214 } |
208 } | 215 } |
209 | 216 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 content::RenderFrameHost* rfh, | 263 content::RenderFrameHost* rfh, |
257 const ResultCallback& callback) { | 264 const ResultCallback& callback) { |
258 NOTIMPLEMENTED(); | 265 NOTIMPLEMENTED(); |
259 } | 266 } |
260 | 267 |
261 bool RegisterAwAutofillClient(JNIEnv* env) { | 268 bool RegisterAwAutofillClient(JNIEnv* env) { |
262 return RegisterNativesImpl(env); | 269 return RegisterNativesImpl(env); |
263 } | 270 } |
264 | 271 |
265 } // namespace android_webview | 272 } // namespace android_webview |
OLD | NEW |