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