| 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/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/string16.h" | 12 #include "base/string16.h" |
| 13 #include "chrome/browser/autofill/password_autofill_manager.h" | 13 #include "chrome/browser/autofill/password_autofill_manager.h" |
| 14 #include "chrome/browser/ui/autofill/autofill_popup_delegate.h" | 14 #include "chrome/browser/ui/autofill/autofill_popup_delegate.h" |
| 15 #include "chrome/common/form_data.h" | 15 #include "chrome/common/form_data.h" |
| 16 #include "chrome/common/form_field_data.h" | 16 #include "chrome/common/form_field_data.h" |
| 17 #include "chrome/common/password_form_fill_data.h" | 17 #include "chrome/common/password_form_fill_data.h" |
| 18 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 20 #include "content/public/browser/web_contents_user_data.h" | 20 #include "content/public/browser/web_contents_user_data.h" |
| 21 #include "ui/gfx/rect.h" | 21 #include "ui/gfx/rect.h" |
| 22 | 22 |
| 23 class AutofillManager; | 23 class AutofillManager; |
| 24 class AutofillPopupControllerImpl; | |
| 25 | 24 |
| 26 namespace gfx { | 25 namespace gfx { |
| 27 class Rect; | 26 class Rect; |
| 28 } | 27 } |
| 29 | 28 |
| 30 namespace content { | 29 namespace content { |
| 31 class WebContents; | 30 class WebContents; |
| 32 } | 31 } |
| 33 | 32 |
| 34 // TODO(csharp): A lot of the logic in this class is copied from autofillagent. | 33 // TODO(csharp): A lot of the logic in this class is copied from autofillagent. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 94 |
| 96 // Returns the delegate to its starting state by removing any page specific | 95 // Returns the delegate to its starting state by removing any page specific |
| 97 // values or settings. | 96 // values or settings. |
| 98 void Reset(); | 97 void Reset(); |
| 99 | 98 |
| 100 // Inform the Password Manager of a filled form. | 99 // Inform the Password Manager of a filled form. |
| 101 void AddPasswordFormMapping( | 100 void AddPasswordFormMapping( |
| 102 const FormFieldData& form, | 101 const FormFieldData& form, |
| 103 const PasswordFormFillData& fill_data); | 102 const PasswordFormFillData& fill_data); |
| 104 | 103 |
| 105 virtual void HideAutofillPopup(); | |
| 106 | |
| 107 protected: | 104 protected: |
| 108 friend class content::WebContentsUserData<AutofillExternalDelegate>; | 105 friend class content::WebContentsUserData<AutofillExternalDelegate>; |
| 109 AutofillExternalDelegate(content::WebContents* web_contents, | 106 AutofillExternalDelegate(content::WebContents* web_contents, |
| 110 AutofillManager* autofill_manager); | 107 AutofillManager* autofill_manager); |
| 111 virtual ~AutofillExternalDelegate(); | 108 virtual ~AutofillExternalDelegate(); |
| 112 | 109 |
| 113 // Displays the Autofill results to the user with an external Autofill popup | |
| 114 // that lives completely in the browser. The suggestions have been correctly | |
| 115 // formatted by this point. | |
| 116 virtual void ApplyAutofillSuggestions( | |
| 117 const std::vector<string16>& autofill_values, | |
| 118 const std::vector<string16>& autofill_labels, | |
| 119 const std::vector<string16>& autofill_icons, | |
| 120 const std::vector<int>& autofill_unique_ids); | |
| 121 | |
| 122 // Create the popup if it doesn't already exist. |element_bounds| is the | |
| 123 // bounding rect for the element it is popping up for. | |
| 124 virtual void EnsurePopupForElement(const gfx::RectF& element_bounds); | |
| 125 | |
| 126 content::WebContents* web_contents() { return web_contents_; } | 110 content::WebContents* web_contents() { return web_contents_; } |
| 127 | 111 |
| 128 AutofillPopupControllerImpl* controller() { return controller_; } | |
| 129 | |
| 130 private: | 112 private: |
| 131 // Fills the form with the Autofill data corresponding to |unique_id|. | 113 // Fills the form with the Autofill data corresponding to |unique_id|. |
| 132 // If |is_preview| is true then this is just a preview to show the user what | 114 // If |is_preview| is true then this is just a preview to show the user what |
| 133 // would be selected and if |is_preview| is false then the user has selected | 115 // would be selected and if |is_preview| is false then the user has selected |
| 134 // this data. | 116 // this data. |
| 135 void FillAutofillFormData(int unique_id, bool is_preview); | 117 void FillAutofillFormData(int unique_id, bool is_preview); |
| 136 | 118 |
| 137 // Handle applying any Autofill warnings to the Autofill popup. | 119 // Handle applying any Autofill warnings to the Autofill popup. |
| 138 void ApplyAutofillWarnings(std::vector<string16>* autofill_values, | 120 void ApplyAutofillWarnings(std::vector<string16>* autofill_values, |
| 139 std::vector<string16>* autofill_labels, | 121 std::vector<string16>* autofill_labels, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 156 std::vector<int>* autofill_unique_ids); | 138 std::vector<int>* autofill_unique_ids); |
| 157 | 139 |
| 158 // content::NotificationObserver method override. | 140 // content::NotificationObserver method override. |
| 159 virtual void Observe(int type, | 141 virtual void Observe(int type, |
| 160 const content::NotificationSource& source, | 142 const content::NotificationSource& source, |
| 161 const content::NotificationDetails& details) OVERRIDE; | 143 const content::NotificationDetails& details) OVERRIDE; |
| 162 | 144 |
| 163 // The web_contents associated with this delegate. | 145 // The web_contents associated with this delegate. |
| 164 content::WebContents* web_contents_; // weak; owns me. | 146 content::WebContents* web_contents_; // weak; owns me. |
| 165 AutofillManager* autofill_manager_; // weak. | 147 AutofillManager* autofill_manager_; // weak. |
| 166 base::WeakPtr<AutofillPopupControllerImpl> controller_; | |
| 167 | 148 |
| 168 // Password Autofill manager, handles all password-related Autofilling. | 149 // Password Autofill manager, handles all password-related Autofilling. |
| 169 PasswordAutofillManager password_autofill_manager_; | 150 PasswordAutofillManager password_autofill_manager_; |
| 170 | 151 |
| 171 // The ID of the last request sent for form field Autofill. Used to ignore | 152 // The ID of the last request sent for form field Autofill. Used to ignore |
| 172 // out of date responses. | 153 // out of date responses. |
| 173 int autofill_query_id_; | 154 int autofill_query_id_; |
| 174 | 155 |
| 175 // A scoped container for notification registries. | 156 // A scoped container for notification registries. |
| 176 content::NotificationRegistrar registrar_; | 157 content::NotificationRegistrar registrar_; |
| 177 | 158 |
| 178 // The current form and field selected by Autofill. | 159 // The current form and field selected by Autofill. |
| 179 FormData autofill_query_form_; | 160 FormData autofill_query_form_; |
| 180 FormFieldData autofill_query_field_; | 161 FormFieldData autofill_query_field_; |
| 181 | 162 |
| 163 // The bounds of the form field that user is interacting with. |
| 164 gfx::RectF element_bounds_; |
| 165 |
| 182 // Should we display a warning if Autofill is disabled? | 166 // Should we display a warning if Autofill is disabled? |
| 183 bool display_warning_if_disabled_; | 167 bool display_warning_if_disabled_; |
| 184 | 168 |
| 185 // Does the popup include any Autofill profile or credit card suggestions? | 169 // Does the popup include any Autofill profile or credit card suggestions? |
| 186 bool has_autofill_suggestion_; | 170 bool has_autofill_suggestion_; |
| 187 | 171 |
| 188 // Have we already shown Autofill suggestions for the field the user is | 172 // Have we already shown Autofill suggestions for the field the user is |
| 189 // currently editing? Used to keep track of state for metrics logging. | 173 // currently editing? Used to keep track of state for metrics logging. |
| 190 bool has_shown_autofill_popup_for_current_edit_; | 174 bool has_shown_autofill_popup_for_current_edit_; |
| 191 | 175 |
| 192 // The RenderViewHost that this object has been registered with as a | 176 // The RenderViewHost that this object has been registered with as a |
| 193 // keyboard listener. | 177 // keyboard listener. |
| 194 content::RenderViewHost* registered_keyboard_listener_with_; | 178 content::RenderViewHost* registered_keyboard_listener_with_; |
| 195 | 179 |
| 196 // The current data list values. | 180 // The current data list values. |
| 197 std::vector<string16> data_list_values_; | 181 std::vector<string16> data_list_values_; |
| 198 std::vector<string16> data_list_labels_; | 182 std::vector<string16> data_list_labels_; |
| 199 std::vector<string16> data_list_icons_; | 183 std::vector<string16> data_list_icons_; |
| 200 std::vector<int> data_list_unique_ids_; | 184 std::vector<int> data_list_unique_ids_; |
| 201 | 185 |
| 202 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); | 186 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); |
| 203 }; | 187 }; |
| 204 | 188 |
| 205 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ | 189 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ |
| OLD | NEW |