OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ |
6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ | 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "chrome/browser/autofill/password_autofill_manager.h" | 12 #include "chrome/browser/autofill/password_autofill_manager.h" |
13 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 13 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
14 #include "webkit/forms/form_data.h" | 14 #include "chrome/common/form_data.h" |
15 #include "webkit/forms/form_field.h" | 15 #include "chrome/common/form_field_data.h" |
16 #include "webkit/forms/password_form_dom_manager.h" | 16 #include "chrome/common/password_form_fill_data.h" |
17 | 17 |
18 class AutofillManager; | 18 class AutofillManager; |
19 | 19 |
20 namespace gfx { | 20 namespace gfx { |
21 class Rect; | 21 class Rect; |
22 } | 22 } |
23 | 23 |
24 namespace content { | 24 namespace content { |
25 class WebContents; | 25 class WebContents; |
26 } | 26 } |
(...skipping 13 matching lines...) Expand all Loading... |
40 virtual void SelectAutofillSuggestionAtIndex(int unique_id); | 40 virtual void SelectAutofillSuggestionAtIndex(int unique_id); |
41 | 41 |
42 // Records and associates a query_id with web form data. Called | 42 // Records and associates a query_id with web form data. Called |
43 // when the renderer posts an Autofill query to the browser. |bounds| | 43 // when the renderer posts an Autofill query to the browser. |bounds| |
44 // is window relative. |display_warning_if_disabled| tells us if we should | 44 // is window relative. |display_warning_if_disabled| tells us if we should |
45 // display warnings (such as autofill is disabled, but had suggestions). | 45 // display warnings (such as autofill is disabled, but had suggestions). |
46 // We might not want to display the warning if a website has disabled | 46 // We might not want to display the warning if a website has disabled |
47 // Autocomplete because they have their own popup, and showing our popup | 47 // Autocomplete because they have their own popup, and showing our popup |
48 // on to of theirs would be a poor user experience. | 48 // on to of theirs would be a poor user experience. |
49 virtual void OnQuery(int query_id, | 49 virtual void OnQuery(int query_id, |
50 const webkit::forms::FormData& form, | 50 const FormData& form, |
51 const webkit::forms::FormField& field, | 51 const FormFieldData& field, |
52 const gfx::Rect& bounds, | 52 const gfx::Rect& bounds, |
53 bool display_warning_if_disabled); | 53 bool display_warning_if_disabled); |
54 | 54 |
55 // Records query results and correctly formats them before sending them off | 55 // Records query results and correctly formats them before sending them off |
56 // to be displayed. Called when an Autofill query result is available. | 56 // to be displayed. Called when an Autofill query result is available. |
57 virtual void OnSuggestionsReturned( | 57 virtual void OnSuggestionsReturned( |
58 int query_id, | 58 int query_id, |
59 const std::vector<string16>& autofill_values, | 59 const std::vector<string16>& autofill_values, |
60 const std::vector<string16>& autofill_labels, | 60 const std::vector<string16>& autofill_labels, |
61 const std::vector<string16>& autofill_icons, | 61 const std::vector<string16>& autofill_icons, |
62 const std::vector<int>& autofill_unique_ids); | 62 const std::vector<int>& autofill_unique_ids); |
63 | 63 |
64 // Show password suggestions in the popup. | 64 // Show password suggestions in the popup. |
65 void OnShowPasswordSuggestions(const std::vector<string16>& suggestions, | 65 void OnShowPasswordSuggestions(const std::vector<string16>& suggestions, |
66 const webkit::forms::FormField& field, | 66 const FormFieldData& field, |
67 const gfx::Rect& bounds); | 67 const gfx::Rect& bounds); |
68 | 68 |
69 // Set the data list value associated with the current field. | 69 // Set the data list value associated with the current field. |
70 void SetCurrentDataListValues(const std::vector<string16>& autofill_values, | 70 void SetCurrentDataListValues(const std::vector<string16>& autofill_values, |
71 const std::vector<string16>& autofill_labels, | 71 const std::vector<string16>& autofill_labels, |
72 const std::vector<string16>& autofill_icons, | 72 const std::vector<string16>& autofill_icons, |
73 const std::vector<int>& autofill_unique_ids); | 73 const std::vector<int>& autofill_unique_ids); |
74 | 74 |
75 // Remove the given Autocomplete entry from the DB. | 75 // Remove the given Autocomplete entry from the DB. |
76 virtual void RemoveAutocompleteEntry(const string16& value); | 76 virtual void RemoveAutocompleteEntry(const string16& value); |
(...skipping 16 matching lines...) Expand all Loading... |
93 | 93 |
94 // Hide the Autofill poup. | 94 // Hide the Autofill poup. |
95 virtual void HideAutofillPopup(); | 95 virtual void HideAutofillPopup(); |
96 | 96 |
97 // Returns the delegate to its starting state by removing any page specific | 97 // Returns the delegate to its starting state by removing any page specific |
98 // values or settings. | 98 // values or settings. |
99 void Reset(); | 99 void Reset(); |
100 | 100 |
101 // Inform the Password Manager of a filled form. | 101 // Inform the Password Manager of a filled form. |
102 void AddPasswordFormMapping( | 102 void AddPasswordFormMapping( |
103 const webkit::forms::FormField& form, | 103 const FormFieldData& form, |
104 const webkit::forms::PasswordFormFillData& fill_data); | 104 const PasswordFormFillData& fill_data); |
105 | 105 |
106 // Platforms that wish to implement an external Autofill delegate | 106 // Platforms that wish to implement an external Autofill delegate |
107 // MUST implement this. The 1st arg is the tab contents that owns | 107 // MUST implement this. The 1st arg is the tab contents that owns |
108 // this delegate; the second is the Autofill manager owned by the | 108 // this delegate; the second is the Autofill manager owned by the |
109 // tab contents. | 109 // tab contents. |
110 static AutofillExternalDelegate* Create(TabContents*, | 110 static AutofillExternalDelegate* Create(TabContents*, |
111 AutofillManager*); | 111 AutofillManager*); |
112 protected: | 112 protected: |
113 explicit AutofillExternalDelegate(TabContents* tab_contents, | 113 explicit AutofillExternalDelegate(TabContents* tab_contents, |
114 AutofillManager* autofill_manager); | 114 AutofillManager* autofill_manager); |
115 | 115 |
116 // Displays the the Autofill results to the user with an external | 116 // Displays the the Autofill results to the user with an external |
117 // Autofill popup that lives completely in the browser. The suggestions | 117 // Autofill popup that lives completely in the browser. The suggestions |
118 // have be correctly formatted by this point. | 118 // have be correctly formatted by this point. |
119 virtual void ApplyAutofillSuggestions( | 119 virtual void ApplyAutofillSuggestions( |
120 const std::vector<string16>& autofill_values, | 120 const std::vector<string16>& autofill_values, |
121 const std::vector<string16>& autofill_labels, | 121 const std::vector<string16>& autofill_labels, |
122 const std::vector<string16>& autofill_icons, | 122 const std::vector<string16>& autofill_icons, |
123 const std::vector<int>& autofill_unique_ids) = 0; | 123 const std::vector<int>& autofill_unique_ids) = 0; |
124 | 124 |
125 // Handle instance specific OnQueryCode. | 125 // Handle instance specific OnQueryCode. |
126 virtual void OnQueryPlatformSpecific(int query_id, | 126 virtual void OnQueryPlatformSpecific(int query_id, |
127 const webkit::forms::FormData& form, | 127 const FormData& form, |
128 const webkit::forms::FormField& field, | 128 const FormFieldData& field, |
129 const gfx::Rect& bounds) = 0; | 129 const gfx::Rect& bounds) = 0; |
130 | 130 |
131 // Handle platform-dependent hiding. | 131 // Handle platform-dependent hiding. |
132 virtual void HideAutofillPopupInternal() = 0; | 132 virtual void HideAutofillPopupInternal() = 0; |
133 | 133 |
134 // Set the bounds of the Autofill element being worked with. | 134 // Set the bounds of the Autofill element being worked with. |
135 virtual void SetBounds(const gfx::Rect& bounds) = 0; | 135 virtual void SetBounds(const gfx::Rect& bounds) = 0; |
136 | 136 |
137 // Return the profile that this autofill delegate is currently working with. | 137 // Return the profile that this autofill delegate is currently working with. |
138 Profile* profile() { return tab_contents_->profile(); } | 138 Profile* profile() { return tab_contents_->profile(); } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 AutofillManager* autofill_manager_; // weak. | 172 AutofillManager* autofill_manager_; // weak. |
173 | 173 |
174 // Password Autofill manager, handles all password-related Autofilling. | 174 // Password Autofill manager, handles all password-related Autofilling. |
175 PasswordAutofillManager password_autofill_manager_; | 175 PasswordAutofillManager password_autofill_manager_; |
176 | 176 |
177 // The ID of the last request sent for form field Autofill. Used to ignore | 177 // The ID of the last request sent for form field Autofill. Used to ignore |
178 // out of date responses. | 178 // out of date responses. |
179 int autofill_query_id_; | 179 int autofill_query_id_; |
180 | 180 |
181 // The current form and field selected by Autofill. | 181 // The current form and field selected by Autofill. |
182 webkit::forms::FormData autofill_query_form_; | 182 FormData autofill_query_form_; |
183 webkit::forms::FormField autofill_query_field_; | 183 FormFieldData autofill_query_field_; |
184 | 184 |
185 // Should we display a warning if Autofill is disabled? | 185 // Should we display a warning if Autofill is disabled? |
186 bool display_warning_if_disabled_; | 186 bool display_warning_if_disabled_; |
187 | 187 |
188 // Have we already shown Autofill suggestions for the field the user is | 188 // Have we already shown Autofill suggestions for the field the user is |
189 // currently editing? Used to keep track of state for metrics logging. | 189 // currently editing? Used to keep track of state for metrics logging. |
190 bool has_shown_autofill_popup_for_current_edit_; | 190 bool has_shown_autofill_popup_for_current_edit_; |
191 | 191 |
192 // Used to indicate if a popup is currently being shown or not. | 192 // Used to indicate if a popup is currently being shown or not. |
193 bool popup_visible_; | 193 bool popup_visible_; |
194 | 194 |
195 // The current data list values. | 195 // The current data list values. |
196 std::vector<string16> data_list_values_; | 196 std::vector<string16> data_list_values_; |
197 std::vector<string16> data_list_labels_; | 197 std::vector<string16> data_list_labels_; |
198 std::vector<string16> data_list_icons_; | 198 std::vector<string16> data_list_icons_; |
199 std::vector<int> data_list_unique_ids_; | 199 std::vector<int> data_list_unique_ids_; |
200 | 200 |
201 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); | 201 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); |
202 }; | 202 }; |
203 | 203 |
204 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ | 204 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ |
OLD | NEW |