OLD | NEW |
| (Empty) |
1 // Copyright 2013 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_BROWSER_AW_AUTOFILL_MANAGER_DELEGATE_H_ | |
6 #define ANDROID_WEBVIEW_BROWSER_AW_AUTOFILL_MANAGER_DELEGATE_H_ | |
7 | |
8 #include <jni.h> | |
9 #include <vector> | |
10 | |
11 #include "base/android/jni_weak_ref.h" | |
12 #include "base/basictypes.h" | |
13 #include "base/compiler_specific.h" | |
14 #include "base/prefs/pref_registry_simple.h" | |
15 #include "base/prefs/pref_service_factory.h" | |
16 #include "components/autofill/core/browser/autofill_manager_delegate.h" | |
17 #include "content/public/browser/web_contents_user_data.h" | |
18 | |
19 namespace autofill { | |
20 class AutofillMetrics; | |
21 class AutofillPopupDelegate; | |
22 class CreditCard; | |
23 class FormStructure; | |
24 class PasswordGenerator; | |
25 class PersonalDataManager; | |
26 struct FormData; | |
27 } | |
28 | |
29 namespace content { | |
30 class WebContents; | |
31 } | |
32 | |
33 namespace gfx { | |
34 class RectF; | |
35 } | |
36 | |
37 class PersonalDataManager; | |
38 class PrefService; | |
39 | |
40 namespace android_webview { | |
41 | |
42 // Manager delegate for the autofill functionality. Android webview | |
43 // supports enabling autocomplete feature for each webview instance | |
44 // (different than the browser which supports enabling/disabling for | |
45 // a profile). Since there is only one pref service for a given browser | |
46 // context, we cannot enable this feature via UserPrefs. Rather, we always | |
47 // keep the feature enabled at the pref service, and control it via | |
48 // the delegates. | |
49 class AwAutofillManagerDelegate | |
50 : public autofill::AutofillManagerDelegate, | |
51 public content::WebContentsUserData<AwAutofillManagerDelegate> { | |
52 | |
53 public: | |
54 virtual ~AwAutofillManagerDelegate(); | |
55 | |
56 void SetSaveFormData(bool enabled); | |
57 bool GetSaveFormData(); | |
58 | |
59 // AutofillManagerDelegate implementation. | |
60 virtual autofill::PersonalDataManager* GetPersonalDataManager() OVERRIDE; | |
61 virtual scoped_refptr<autofill::AutofillWebDataService> | |
62 GetDatabase() OVERRIDE; | |
63 virtual PrefService* GetPrefs() OVERRIDE; | |
64 virtual void HideRequestAutocompleteDialog() OVERRIDE; | |
65 virtual void ShowAutofillSettings() OVERRIDE; | |
66 virtual void ConfirmSaveCreditCard( | |
67 const autofill::AutofillMetrics& metric_logger, | |
68 const base::Closure& save_card_callback) OVERRIDE; | |
69 virtual void ShowRequestAutocompleteDialog( | |
70 const autofill::FormData& form, | |
71 const GURL& source_url, | |
72 const ResultCallback& callback) | |
73 OVERRIDE; | |
74 virtual void ShowAutofillPopup( | |
75 const gfx::RectF& element_bounds, | |
76 base::i18n::TextDirection text_direction, | |
77 const std::vector<base::string16>& values, | |
78 const std::vector<base::string16>& labels, | |
79 const std::vector<base::string16>& icons, | |
80 const std::vector<int>& identifiers, | |
81 base::WeakPtr<autofill::AutofillPopupDelegate> delegate) OVERRIDE; | |
82 virtual void UpdateAutofillPopupDataListValues( | |
83 const std::vector<base::string16>& values, | |
84 const std::vector<base::string16>& labels) OVERRIDE; | |
85 virtual void HideAutofillPopup() OVERRIDE; | |
86 virtual bool IsAutocompleteEnabled() OVERRIDE; | |
87 virtual void DetectAccountCreationForms( | |
88 const std::vector<autofill::FormStructure*>& forms) OVERRIDE; | |
89 virtual void DidFillOrPreviewField( | |
90 const base::string16& autofilled_value, | |
91 const base::string16& profile_full_name) OVERRIDE; | |
92 | |
93 void SuggestionSelected(JNIEnv* env, | |
94 jobject obj, | |
95 jint position); | |
96 private: | |
97 AwAutofillManagerDelegate(content::WebContents* web_contents); | |
98 friend class content::WebContentsUserData<AwAutofillManagerDelegate>; | |
99 | |
100 void ShowAutofillPopupImpl(const gfx::RectF& element_bounds, | |
101 const std::vector<base::string16>& values, | |
102 const std::vector<base::string16>& labels, | |
103 const std::vector<int>& identifiers); | |
104 | |
105 // The web_contents associated with this delegate. | |
106 content::WebContents* web_contents_; | |
107 bool save_form_data_; | |
108 JavaObjectWeakGlobalRef java_ref_; | |
109 | |
110 // The current Autofill query values. | |
111 std::vector<base::string16> values_; | |
112 std::vector<int> identifiers_; | |
113 base::WeakPtr<autofill::AutofillPopupDelegate> delegate_; | |
114 | |
115 DISALLOW_COPY_AND_ASSIGN(AwAutofillManagerDelegate); | |
116 }; | |
117 | |
118 bool RegisterAwAutofillManagerDelegate(JNIEnv* env); | |
119 | |
120 } // namespace android_webview | |
121 | |
122 #endif // ANDROID_WEBVIEW_BROWSER_AW_AUTOFILL_MANAGER_DELEGATE_H_ | |
OLD | NEW |