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 #ifndef ANDROID_WEBVIEW_NATIVE_AW_AUTOFILL_CLIENT_H_ | 5 #ifndef ANDROID_WEBVIEW_NATIVE_AW_AUTOFILL_CLIENT_H_ |
6 #define ANDROID_WEBVIEW_NATIVE_AW_AUTOFILL_CLIENT_H_ | 6 #define ANDROID_WEBVIEW_NATIVE_AW_AUTOFILL_CLIENT_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <memory> |
| 10 #include <string> |
9 #include <vector> | 11 #include <vector> |
10 | 12 |
11 #include "base/android/jni_weak_ref.h" | 13 #include "base/android/jni_weak_ref.h" |
12 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
13 #include "base/macros.h" | 15 #include "base/macros.h" |
14 #include "components/autofill/core/browser/autofill_client.h" | 16 #include "components/autofill/core/browser/autofill_client.h" |
15 #include "components/prefs/pref_registry_simple.h" | 17 #include "components/prefs/pref_registry_simple.h" |
16 #include "components/prefs/pref_service_factory.h" | 18 #include "components/prefs/pref_service_factory.h" |
17 #include "content/public/browser/web_contents_user_data.h" | 19 #include "content/public/browser/web_contents_user_data.h" |
18 #include "ui/android/view_android.h" | 20 #include "ui/android/view_android.h" |
(...skipping 10 matching lines...) Expand all Loading... |
29 } | 31 } |
30 | 32 |
31 namespace content { | 33 namespace content { |
32 class WebContents; | 34 class WebContents; |
33 } | 35 } |
34 | 36 |
35 namespace gfx { | 37 namespace gfx { |
36 class RectF; | 38 class RectF; |
37 } | 39 } |
38 | 40 |
39 namespace sync_driver { | 41 namespace syncer { |
40 class SyncService; | 42 class SyncService; |
41 } | 43 } |
42 | 44 |
43 class PersonalDataManager; | 45 class PersonalDataManager; |
44 class PrefService; | 46 class PrefService; |
45 | 47 |
46 namespace android_webview { | 48 namespace android_webview { |
47 | 49 |
48 // Manager delegate for the autofill functionality. Android webview | 50 // Manager delegate for the autofill functionality. Android webview |
49 // supports enabling autocomplete feature for each webview instance | 51 // supports enabling autocomplete feature for each webview instance |
50 // (different than the browser which supports enabling/disabling for | 52 // (different than the browser which supports enabling/disabling for |
51 // a profile). Since there is only one pref service for a given browser | 53 // a profile). Since there is only one pref service for a given browser |
52 // context, we cannot enable this feature via UserPrefs. Rather, we always | 54 // context, we cannot enable this feature via UserPrefs. Rather, we always |
53 // keep the feature enabled at the pref service, and control it via | 55 // keep the feature enabled at the pref service, and control it via |
54 // the delegates. | 56 // the delegates. |
55 class AwAutofillClient : public autofill::AutofillClient, | 57 class AwAutofillClient : public autofill::AutofillClient, |
56 public content::WebContentsUserData<AwAutofillClient> { | 58 public content::WebContentsUserData<AwAutofillClient> { |
57 public: | 59 public: |
58 ~AwAutofillClient() override; | 60 ~AwAutofillClient() override; |
59 | 61 |
60 void SetSaveFormData(bool enabled); | 62 void SetSaveFormData(bool enabled); |
61 bool GetSaveFormData(); | 63 bool GetSaveFormData(); |
62 | 64 |
63 // AutofillClient: | 65 // AutofillClient: |
64 autofill::PersonalDataManager* GetPersonalDataManager() override; | 66 autofill::PersonalDataManager* GetPersonalDataManager() override; |
65 scoped_refptr<autofill::AutofillWebDataService> GetDatabase() override; | 67 scoped_refptr<autofill::AutofillWebDataService> GetDatabase() override; |
66 PrefService* GetPrefs() override; | 68 PrefService* GetPrefs() override; |
67 sync_driver::SyncService* GetSyncService() override; | 69 syncer::SyncService* GetSyncService() override; |
68 IdentityProvider* GetIdentityProvider() override; | 70 IdentityProvider* GetIdentityProvider() override; |
69 rappor::RapporService* GetRapporService() override; | 71 rappor::RapporService* GetRapporService() override; |
70 void ShowAutofillSettings() override; | 72 void ShowAutofillSettings() override; |
71 void ShowUnmaskPrompt( | 73 void ShowUnmaskPrompt( |
72 const autofill::CreditCard& card, | 74 const autofill::CreditCard& card, |
73 UnmaskCardReason reason, | 75 UnmaskCardReason reason, |
74 base::WeakPtr<autofill::CardUnmaskDelegate> delegate) override; | 76 base::WeakPtr<autofill::CardUnmaskDelegate> delegate) override; |
75 void OnUnmaskVerificationResult(PaymentsRpcResult result) override; | 77 void OnUnmaskVerificationResult(PaymentsRpcResult result) override; |
76 void ConfirmSaveCreditCardLocally(const autofill::CreditCard& card, | 78 void ConfirmSaveCreditCardLocally(const autofill::CreditCard& card, |
77 const base::Closure& callback) override; | 79 const base::Closure& callback) override; |
(...skipping 27 matching lines...) Expand all Loading... |
105 bool ShouldShowSigninPromo() override; | 107 bool ShouldShowSigninPromo() override; |
106 void StartSigninFlow() override; | 108 void StartSigninFlow() override; |
107 | 109 |
108 void Dismissed(JNIEnv* env, | 110 void Dismissed(JNIEnv* env, |
109 const base::android::JavaParamRef<jobject>& obj); | 111 const base::android::JavaParamRef<jobject>& obj); |
110 void SuggestionSelected(JNIEnv* env, | 112 void SuggestionSelected(JNIEnv* env, |
111 const base::android::JavaParamRef<jobject>& obj, | 113 const base::android::JavaParamRef<jobject>& obj, |
112 jint position); | 114 jint position); |
113 | 115 |
114 private: | 116 private: |
115 AwAutofillClient(content::WebContents* web_contents); | 117 explicit AwAutofillClient(content::WebContents* web_contents); |
116 friend class content::WebContentsUserData<AwAutofillClient>; | 118 friend class content::WebContentsUserData<AwAutofillClient>; |
117 | 119 |
118 void ShowAutofillPopupImpl( | 120 void ShowAutofillPopupImpl( |
119 const gfx::RectF& element_bounds, | 121 const gfx::RectF& element_bounds, |
120 bool is_rtl, | 122 bool is_rtl, |
121 const std::vector<autofill::Suggestion>& suggestions); | 123 const std::vector<autofill::Suggestion>& suggestions); |
122 | 124 |
123 // The web_contents associated with this delegate. | 125 // The web_contents associated with this delegate. |
124 content::WebContents* web_contents_; | 126 content::WebContents* web_contents_; |
125 bool save_form_data_; | 127 bool save_form_data_; |
126 JavaObjectWeakGlobalRef java_ref_; | 128 JavaObjectWeakGlobalRef java_ref_; |
127 | 129 |
128 ui::ViewAndroid::ScopedAnchorView anchor_view_; | 130 ui::ViewAndroid::ScopedAnchorView anchor_view_; |
129 | 131 |
130 // The current Autofill query values. | 132 // The current Autofill query values. |
131 std::vector<autofill::Suggestion> suggestions_; | 133 std::vector<autofill::Suggestion> suggestions_; |
132 base::WeakPtr<autofill::AutofillPopupDelegate> delegate_; | 134 base::WeakPtr<autofill::AutofillPopupDelegate> delegate_; |
133 | 135 |
134 DISALLOW_COPY_AND_ASSIGN(AwAutofillClient); | 136 DISALLOW_COPY_AND_ASSIGN(AwAutofillClient); |
135 }; | 137 }; |
136 | 138 |
137 bool RegisterAwAutofillClient(JNIEnv* env); | 139 bool RegisterAwAutofillClient(JNIEnv* env); |
138 | 140 |
139 } // namespace android_webview | 141 } // namespace android_webview |
140 | 142 |
141 #endif // ANDROID_WEBVIEW_NATIVE_AW_AUTOFILL_CLIENT_H_ | 143 #endif // ANDROID_WEBVIEW_NATIVE_AW_AUTOFILL_CLIENT_H_ |
OLD | NEW |