OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef ANDROID_WEBVIEW_NATIVE_AW_AUTOFILL_CLIENT_H_ | |
6 #define ANDROID_WEBVIEW_NATIVE_AW_AUTOFILL_CLIENT_H_ | |
7 | |
8 #include <jni.h> | |
9 #include <memory> | |
10 #include <string> | |
11 #include <vector> | |
12 | |
13 #include "base/android/jni_weak_ref.h" | |
14 #include "base/compiler_specific.h" | |
15 #include "base/macros.h" | |
16 #include "components/autofill/core/browser/autofill_client.h" | |
17 #include "components/prefs/pref_registry_simple.h" | |
18 #include "components/prefs/pref_service_factory.h" | |
19 #include "content/public/browser/web_contents_user_data.h" | |
20 #include "ui/android/view_android.h" | |
21 | |
22 namespace autofill { | |
23 class AutofillPopupDelegate; | |
24 class CardUnmaskDelegate; | |
25 class CreditCard; | |
26 class FormStructure; | |
27 class PersonalDataManager; | |
28 class SaveCardBubbleController; | |
29 } | |
30 | |
31 namespace content { | |
32 class WebContents; | |
33 } | |
34 | |
35 namespace gfx { | |
36 class RectF; | |
37 } | |
38 | |
39 namespace syncer { | |
40 class SyncService; | |
41 } | |
42 | |
43 class PersonalDataManager; | |
44 class PrefService; | |
45 | |
46 namespace android_webview { | |
47 | |
48 // Manager delegate for the autofill functionality. Android webview | |
49 // supports enabling autocomplete feature for each webview instance | |
50 // (different than the browser which supports enabling/disabling for | |
51 // 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 | |
53 // keep the feature enabled at the pref service, and control it via | |
54 // the delegates. | |
55 class AwAutofillClient : public autofill::AutofillClient, | |
56 public content::WebContentsUserData<AwAutofillClient> { | |
57 public: | |
58 ~AwAutofillClient() override; | |
59 | |
60 void SetSaveFormData(bool enabled); | |
61 bool GetSaveFormData(); | |
62 | |
63 // AutofillClient: | |
64 autofill::PersonalDataManager* GetPersonalDataManager() override; | |
65 scoped_refptr<autofill::AutofillWebDataService> GetDatabase() override; | |
66 PrefService* GetPrefs() override; | |
67 syncer::SyncService* GetSyncService() override; | |
68 IdentityProvider* GetIdentityProvider() override; | |
69 rappor::RapporServiceImpl* GetRapporServiceImpl() override; | |
70 ukm::UkmService* GetUkmService() override; | |
71 autofill::SaveCardBubbleController* GetSaveCardBubbleController() override; | |
72 void ShowAutofillSettings() override; | |
73 void ShowUnmaskPrompt( | |
74 const autofill::CreditCard& card, | |
75 UnmaskCardReason reason, | |
76 base::WeakPtr<autofill::CardUnmaskDelegate> delegate) override; | |
77 void OnUnmaskVerificationResult(PaymentsRpcResult result) override; | |
78 void ConfirmSaveCreditCardLocally(const autofill::CreditCard& card, | |
79 const base::Closure& callback) override; | |
80 void ConfirmSaveCreditCardToCloud( | |
81 const autofill::CreditCard& card, | |
82 std::unique_ptr<base::DictionaryValue> legal_message, | |
83 bool should_cvc_be_requested, | |
84 const base::Closure& callback) override; | |
85 void ConfirmCreditCardFillAssist(const autofill::CreditCard& card, | |
86 const base::Closure& callback) override; | |
87 void LoadRiskData( | |
88 const base::Callback<void(const std::string&)>& callback) override; | |
89 bool HasCreditCardScanFeature() override; | |
90 void ScanCreditCard(const CreditCardScanCallback& callback) override; | |
91 void ShowAutofillPopup( | |
92 const gfx::RectF& element_bounds, | |
93 base::i18n::TextDirection text_direction, | |
94 const std::vector<autofill::Suggestion>& suggestions, | |
95 base::WeakPtr<autofill::AutofillPopupDelegate> delegate) override; | |
96 void UpdateAutofillPopupDataListValues( | |
97 const std::vector<base::string16>& values, | |
98 const std::vector<base::string16>& labels) override; | |
99 void HideAutofillPopup() override; | |
100 bool IsAutocompleteEnabled() override; | |
101 void PropagateAutofillPredictions( | |
102 content::RenderFrameHost* rfh, | |
103 const std::vector<autofill::FormStructure*>& forms) override; | |
104 void DidFillOrPreviewField(const base::string16& autofilled_value, | |
105 const base::string16& profile_full_name) override; | |
106 bool IsContextSecure() override; | |
107 bool ShouldShowSigninPromo() override; | |
108 void StartSigninFlow() override; | |
109 void ShowHttpNotSecureExplanation() override; | |
110 | |
111 void Dismissed(JNIEnv* env, | |
112 const base::android::JavaParamRef<jobject>& obj); | |
113 void SuggestionSelected(JNIEnv* env, | |
114 const base::android::JavaParamRef<jobject>& obj, | |
115 jint position); | |
116 | |
117 private: | |
118 explicit AwAutofillClient(content::WebContents* web_contents); | |
119 friend class content::WebContentsUserData<AwAutofillClient>; | |
120 | |
121 void ShowAutofillPopupImpl( | |
122 const gfx::RectF& element_bounds, | |
123 bool is_rtl, | |
124 const std::vector<autofill::Suggestion>& suggestions); | |
125 | |
126 // The web_contents associated with this delegate. | |
127 content::WebContents* web_contents_; | |
128 bool save_form_data_; | |
129 JavaObjectWeakGlobalRef java_ref_; | |
130 | |
131 ui::ViewAndroid::ScopedAnchorView anchor_view_; | |
132 | |
133 // The current Autofill query values. | |
134 std::vector<autofill::Suggestion> suggestions_; | |
135 base::WeakPtr<autofill::AutofillPopupDelegate> delegate_; | |
136 | |
137 DISALLOW_COPY_AND_ASSIGN(AwAutofillClient); | |
138 }; | |
139 | |
140 bool RegisterAwAutofillClient(JNIEnv* env); | |
141 | |
142 } // namespace android_webview | |
143 | |
144 #endif // ANDROID_WEBVIEW_NATIVE_AW_AUTOFILL_CLIENT_H_ | |
OLD | NEW |