| 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 COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_EXTERNAL_DELEGATE_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_EXTERNAL_DELEGATE_H_ |
| 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_EXTERNAL_DELEGATE_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_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" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "components/autofill/core/browser/autofill_popup_delegate.h" | 13 #include "components/autofill/core/browser/autofill_popup_delegate.h" |
| 14 #include "components/autofill/core/browser/password_autofill_manager.h" | |
| 15 #include "components/autofill/core/common/form_data.h" | 14 #include "components/autofill/core/common/form_data.h" |
| 16 #include "components/autofill/core/common/form_field_data.h" | 15 #include "components/autofill/core/common/form_field_data.h" |
| 17 #include "components/autofill/core/common/password_form_fill_data.h" | |
| 18 #include "ui/gfx/rect.h" | 16 #include "ui/gfx/rect.h" |
| 19 | 17 |
| 20 namespace gfx { | |
| 21 class Rect; | |
| 22 } | |
| 23 | |
| 24 namespace autofill { | 18 namespace autofill { |
| 25 | 19 |
| 26 class AutofillDriver; | 20 class AutofillDriver; |
| 27 class AutofillManager; | 21 class AutofillManager; |
| 28 | 22 |
| 29 // TODO(csharp): A lot of the logic in this class is copied from autofillagent. | 23 // TODO(csharp): A lot of the logic in this class is copied from autofillagent. |
| 30 // Once Autofill is moved out of WebKit this class should be the only home for | 24 // Once Autofill is moved out of WebKit this class should be the only home for |
| 31 // this logic. See http://crbug.com/51644 | 25 // this logic. See http://crbug.com/51644 |
| 32 | 26 |
| 33 // Delegate for in-browser Autocomplete and Autofill display and selection. | 27 // Delegate for in-browser Autocomplete and Autofill display and selection. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 60 |
| 67 // Records query results and correctly formats them before sending them off | 61 // Records query results and correctly formats them before sending them off |
| 68 // to be displayed. Called when an Autofill query result is available. | 62 // to be displayed. Called when an Autofill query result is available. |
| 69 virtual void OnSuggestionsReturned( | 63 virtual void OnSuggestionsReturned( |
| 70 int query_id, | 64 int query_id, |
| 71 const std::vector<base::string16>& values, | 65 const std::vector<base::string16>& values, |
| 72 const std::vector<base::string16>& labels, | 66 const std::vector<base::string16>& labels, |
| 73 const std::vector<base::string16>& icons, | 67 const std::vector<base::string16>& icons, |
| 74 const std::vector<int>& unique_ids); | 68 const std::vector<int>& unique_ids); |
| 75 | 69 |
| 76 // Show password suggestions in the popup. | |
| 77 void OnShowPasswordSuggestions(const std::vector<base::string16>& suggestions, | |
| 78 const std::vector<base::string16>& realms, | |
| 79 const FormFieldData& field, | |
| 80 const gfx::RectF& bounds); | |
| 81 | |
| 82 // Set the data list value associated with the current field. | 70 // Set the data list value associated with the current field. |
| 83 void SetCurrentDataListValues( | 71 void SetCurrentDataListValues( |
| 84 const std::vector<base::string16>& data_list_values, | 72 const std::vector<base::string16>& data_list_values, |
| 85 const std::vector<base::string16>& data_list_labels); | 73 const std::vector<base::string16>& data_list_labels); |
| 86 | 74 |
| 87 // Inform the delegate that the text field editing has ended. This is | 75 // Inform the delegate that the text field editing has ended. This is |
| 88 // used to help record the metrics of when a new popup is shown. | 76 // used to help record the metrics of when a new popup is shown. |
| 89 void DidEndTextFieldEditing(); | 77 void DidEndTextFieldEditing(); |
| 90 | 78 |
| 91 // Returns the delegate to its starting state by removing any page specific | 79 // Returns the delegate to its starting state by removing any page specific |
| 92 // values or settings. | 80 // values or settings. |
| 93 void Reset(); | 81 void Reset(); |
| 94 | 82 |
| 95 // Inform the Password Manager of a filled form. | |
| 96 void AddPasswordFormMapping(const FormFieldData& username_field, | |
| 97 const PasswordFormFillData& fill_data); | |
| 98 | |
| 99 protected: | 83 protected: |
| 100 base::WeakPtr<AutofillExternalDelegate> GetWeakPtr(); | 84 base::WeakPtr<AutofillExternalDelegate> GetWeakPtr(); |
| 101 | 85 |
| 102 private: | 86 private: |
| 103 // Fills the form with the Autofill data corresponding to |unique_id|. | 87 // Fills the form with the Autofill data corresponding to |unique_id|. |
| 104 // If |is_preview| is true then this is just a preview to show the user what | 88 // If |is_preview| is true then this is just a preview to show the user what |
| 105 // would be selected and if |is_preview| is false then the user has selected | 89 // would be selected and if |is_preview| is false then the user has selected |
| 106 // this data. | 90 // this data. |
| 107 void FillAutofillFormData(int unique_id, bool is_preview); | 91 void FillAutofillFormData(int unique_id, bool is_preview); |
| 108 | 92 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 126 std::vector<base::string16>* labels, | 110 std::vector<base::string16>* labels, |
| 127 std::vector<base::string16>* icons, | 111 std::vector<base::string16>* icons, |
| 128 std::vector<int>* unique_ids); | 112 std::vector<int>* unique_ids); |
| 129 | 113 |
| 130 AutofillManager* manager_; // weak. | 114 AutofillManager* manager_; // weak. |
| 131 | 115 |
| 132 // Provides driver-level context to the shared code of the component. Must | 116 // Provides driver-level context to the shared code of the component. Must |
| 133 // outlive this object. | 117 // outlive this object. |
| 134 AutofillDriver* driver_; // weak | 118 AutofillDriver* driver_; // weak |
| 135 | 119 |
| 136 // Password Autofill manager, handles all password-related Autofilling. | |
| 137 PasswordAutofillManager password_manager_; | |
| 138 | |
| 139 // The ID of the last request sent for form field Autofill. Used to ignore | 120 // The ID of the last request sent for form field Autofill. Used to ignore |
| 140 // out of date responses. | 121 // out of date responses. |
| 141 int query_id_; | 122 int query_id_; |
| 142 | 123 |
| 143 // The current form and field selected by Autofill. | 124 // The current form and field selected by Autofill. |
| 144 FormData query_form_; | 125 FormData query_form_; |
| 145 FormFieldData query_field_; | 126 FormFieldData query_field_; |
| 146 | 127 |
| 147 // The bounds of the form field that user is interacting with. | 128 // The bounds of the form field that user is interacting with. |
| 148 gfx::RectF element_bounds_; | 129 gfx::RectF element_bounds_; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 162 std::vector<base::string16> data_list_labels_; | 143 std::vector<base::string16> data_list_labels_; |
| 163 | 144 |
| 164 base::WeakPtrFactory<AutofillExternalDelegate> weak_ptr_factory_; | 145 base::WeakPtrFactory<AutofillExternalDelegate> weak_ptr_factory_; |
| 165 | 146 |
| 166 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); | 147 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); |
| 167 }; | 148 }; |
| 168 | 149 |
| 169 } // namespace autofill | 150 } // namespace autofill |
| 170 | 151 |
| 171 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_EXTERNAL_DELEGATE_H_ | 152 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_EXTERNAL_DELEGATE_H_ |
| OLD | NEW |