| 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 COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_EXTERNAL_DELEGATE_H_ | 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_EXTERNAL_DELEGATE_H_ |
| 6 #define COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_EXTERNAL_DELEGATE_H_ | 6 #define COMPONENTS_AUTOFILL_BROWSER_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" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // Creates an AutofillExternalDelegate and attaches it to the specified | 43 // Creates an AutofillExternalDelegate and attaches it to the specified |
| 44 // contents; the second argument is an AutofillManager managing Autofill for | 44 // contents; the second argument is an AutofillManager managing Autofill for |
| 45 // that WebContents. | 45 // that WebContents. |
| 46 static void CreateForWebContentsAndManager(content::WebContents* web_contents, | 46 static void CreateForWebContentsAndManager(content::WebContents* web_contents, |
| 47 AutofillManager* autofill_manager); | 47 AutofillManager* autofill_manager); |
| 48 | 48 |
| 49 // AutofillPopupDelegate implementation. | 49 // AutofillPopupDelegate implementation. |
| 50 virtual void OnPopupShown(content::KeyboardListener* listener) OVERRIDE; | 50 virtual void OnPopupShown(content::KeyboardListener* listener) OVERRIDE; |
| 51 virtual void OnPopupHidden(content::KeyboardListener* listener) OVERRIDE; | 51 virtual void OnPopupHidden(content::KeyboardListener* listener) OVERRIDE; |
| 52 virtual void DidSelectSuggestion(int identifier) OVERRIDE; | 52 virtual void DidSelectSuggestion(int identifier) OVERRIDE; |
| 53 virtual void DidAcceptSuggestion(const string16& value, | 53 virtual void DidAcceptSuggestion(const base::string16& value, |
| 54 int identifier) OVERRIDE; | 54 int identifier) OVERRIDE; |
| 55 virtual void RemoveSuggestion(const string16& value, int identifier) OVERRIDE; | 55 virtual void RemoveSuggestion(const base::string16& value, |
| 56 int identifier) OVERRIDE; |
| 56 virtual void ClearPreviewedForm() OVERRIDE; | 57 virtual void ClearPreviewedForm() OVERRIDE; |
| 57 | 58 |
| 58 // Records and associates a query_id with web form data. Called | 59 // Records and associates a query_id with web form data. Called |
| 59 // when the renderer posts an Autofill query to the browser. |bounds| | 60 // when the renderer posts an Autofill query to the browser. |bounds| |
| 60 // is window relative. |display_warning_if_disabled| tells us if we should | 61 // is window relative. |display_warning_if_disabled| tells us if we should |
| 61 // display warnings (such as autofill is disabled, but had suggestions). | 62 // display warnings (such as autofill is disabled, but had suggestions). |
| 62 // We might not want to display the warning if a website has disabled | 63 // We might not want to display the warning if a website has disabled |
| 63 // Autocomplete because they have their own popup, and showing our popup | 64 // Autocomplete because they have their own popup, and showing our popup |
| 64 // on to of theirs would be a poor user experience. | 65 // on to of theirs would be a poor user experience. |
| 65 virtual void OnQuery(int query_id, | 66 virtual void OnQuery(int query_id, |
| 66 const FormData& form, | 67 const FormData& form, |
| 67 const FormFieldData& field, | 68 const FormFieldData& field, |
| 68 const gfx::RectF& element_bounds, | 69 const gfx::RectF& element_bounds, |
| 69 bool display_warning_if_disabled); | 70 bool display_warning_if_disabled); |
| 70 | 71 |
| 71 // Records query results and correctly formats them before sending them off | 72 // Records query results and correctly formats them before sending them off |
| 72 // to be displayed. Called when an Autofill query result is available. | 73 // to be displayed. Called when an Autofill query result is available. |
| 73 virtual void OnSuggestionsReturned( | 74 virtual void OnSuggestionsReturned( |
| 74 int query_id, | 75 int query_id, |
| 75 const std::vector<string16>& autofill_values, | 76 const std::vector<base::string16>& autofill_values, |
| 76 const std::vector<string16>& autofill_labels, | 77 const std::vector<base::string16>& autofill_labels, |
| 77 const std::vector<string16>& autofill_icons, | 78 const std::vector<base::string16>& autofill_icons, |
| 78 const std::vector<int>& autofill_unique_ids); | 79 const std::vector<int>& autofill_unique_ids); |
| 79 | 80 |
| 80 // Show password suggestions in the popup. | 81 // Show password suggestions in the popup. |
| 81 void OnShowPasswordSuggestions(const std::vector<string16>& suggestions, | 82 void OnShowPasswordSuggestions(const std::vector<base::string16>& suggestions, |
| 82 const FormFieldData& field, | 83 const FormFieldData& field, |
| 83 const gfx::RectF& bounds); | 84 const gfx::RectF& bounds); |
| 84 | 85 |
| 85 // Set the data list value associated with the current field. | 86 // Set the data list value associated with the current field. |
| 86 void SetCurrentDataListValues(const std::vector<string16>& autofill_values, | 87 void SetCurrentDataListValues( |
| 87 const std::vector<string16>& autofill_labels, | 88 const std::vector<base::string16>& autofill_values, |
| 88 const std::vector<string16>& autofill_icons, | 89 const std::vector<base::string16>& autofill_labels, |
| 89 const std::vector<int>& autofill_unique_ids); | 90 const std::vector<base::string16>& autofill_icons, |
| 91 const std::vector<int>& autofill_unique_ids); |
| 90 | 92 |
| 91 // Inform the delegate that the text field editing has ended. This is | 93 // Inform the delegate that the text field editing has ended. This is |
| 92 // used to help record the metrics of when a new popup is shown. | 94 // used to help record the metrics of when a new popup is shown. |
| 93 void DidEndTextFieldEditing(); | 95 void DidEndTextFieldEditing(); |
| 94 | 96 |
| 95 // 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 |
| 96 // values or settings. | 98 // values or settings. |
| 97 void Reset(); | 99 void Reset(); |
| 98 | 100 |
| 99 // Inform the Password Manager of a filled form. | 101 // Inform the Password Manager of a filled form. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 110 content::WebContents* web_contents() { return web_contents_; } | 112 content::WebContents* web_contents() { return web_contents_; } |
| 111 | 113 |
| 112 private: | 114 private: |
| 113 // Fills the form with the Autofill data corresponding to |unique_id|. | 115 // Fills the form with the Autofill data corresponding to |unique_id|. |
| 114 // If |is_preview| is true then this is just a preview to show the user what | 116 // If |is_preview| is true then this is just a preview to show the user what |
| 115 // would be selected and if |is_preview| is false then the user has selected | 117 // would be selected and if |is_preview| is false then the user has selected |
| 116 // this data. | 118 // this data. |
| 117 void FillAutofillFormData(int unique_id, bool is_preview); | 119 void FillAutofillFormData(int unique_id, bool is_preview); |
| 118 | 120 |
| 119 // Handle applying any Autofill warnings to the Autofill popup. | 121 // Handle applying any Autofill warnings to the Autofill popup. |
| 120 void ApplyAutofillWarnings(std::vector<string16>* autofill_values, | 122 void ApplyAutofillWarnings(std::vector<base::string16>* autofill_values, |
| 121 std::vector<string16>* autofill_labels, | 123 std::vector<base::string16>* autofill_labels, |
| 122 std::vector<string16>* autofill_icons, | 124 std::vector<base::string16>* autofill_icons, |
| 123 std::vector<int>* autofill_unique_ids); | 125 std::vector<int>* autofill_unique_ids); |
| 124 | 126 |
| 125 // Handle applying any Autofill option listings to the Autofill popup. | 127 // Handle applying any Autofill option listings to the Autofill popup. |
| 126 // This function should only get called when there is at least one | 128 // This function should only get called when there is at least one |
| 127 // multi-field suggestion in the list of suggestions. | 129 // multi-field suggestion in the list of suggestions. |
| 128 void ApplyAutofillOptions(std::vector<string16>* autofill_values, | 130 void ApplyAutofillOptions(std::vector<base::string16>* autofill_values, |
| 129 std::vector<string16>* autofill_labels, | 131 std::vector<base::string16>* autofill_labels, |
| 130 std::vector<string16>* autofill_icons, | 132 std::vector<base::string16>* autofill_icons, |
| 131 std::vector<int>* autofill_unique_ids); | 133 std::vector<int>* autofill_unique_ids); |
| 132 | 134 |
| 133 // Insert the data list values at the start of the given list, including | 135 // Insert the data list values at the start of the given list, including |
| 134 // any required separators. | 136 // any required separators. |
| 135 void InsertDataListValues(std::vector<string16>* autofill_values, | 137 void InsertDataListValues(std::vector<base::string16>* autofill_values, |
| 136 std::vector<string16>* autofill_labels, | 138 std::vector<base::string16>* autofill_labels, |
| 137 std::vector<string16>* autofill_icons, | 139 std::vector<base::string16>* autofill_icons, |
| 138 std::vector<int>* autofill_unique_ids); | 140 std::vector<int>* autofill_unique_ids); |
| 139 | 141 |
| 140 // content::NotificationObserver method override. | 142 // content::NotificationObserver method override. |
| 141 virtual void Observe(int type, | 143 virtual void Observe(int type, |
| 142 const content::NotificationSource& source, | 144 const content::NotificationSource& source, |
| 143 const content::NotificationDetails& details) OVERRIDE; | 145 const content::NotificationDetails& details) OVERRIDE; |
| 144 | 146 |
| 145 // The web_contents associated with this delegate. | 147 // The web_contents associated with this delegate. |
| 146 content::WebContents* web_contents_; // weak; owns me. | 148 content::WebContents* web_contents_; // weak; owns me. |
| 147 AutofillManager* autofill_manager_; // weak. | 149 AutofillManager* autofill_manager_; // weak. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 171 | 173 |
| 172 // Have we already shown Autofill suggestions for the field the user is | 174 // Have we already shown Autofill suggestions for the field the user is |
| 173 // currently editing? Used to keep track of state for metrics logging. | 175 // currently editing? Used to keep track of state for metrics logging. |
| 174 bool has_shown_autofill_popup_for_current_edit_; | 176 bool has_shown_autofill_popup_for_current_edit_; |
| 175 | 177 |
| 176 // The RenderViewHost that this object has been registered with as a | 178 // The RenderViewHost that this object has been registered with as a |
| 177 // keyboard listener. | 179 // keyboard listener. |
| 178 content::RenderViewHost* registered_keyboard_listener_with_; | 180 content::RenderViewHost* registered_keyboard_listener_with_; |
| 179 | 181 |
| 180 // The current data list values. | 182 // The current data list values. |
| 181 std::vector<string16> data_list_values_; | 183 std::vector<base::string16> data_list_values_; |
| 182 std::vector<string16> data_list_labels_; | 184 std::vector<base::string16> data_list_labels_; |
| 183 std::vector<string16> data_list_icons_; | 185 std::vector<base::string16> data_list_icons_; |
| 184 std::vector<int> data_list_unique_ids_; | 186 std::vector<int> data_list_unique_ids_; |
| 185 | 187 |
| 186 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); | 188 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); |
| 187 }; | 189 }; |
| 188 | 190 |
| 189 #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_EXTERNAL_DELEGATE_H_ | 191 #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_EXTERNAL_DELEGATE_H_ |
| OLD | NEW |