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