| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 const PasswordFormFillData& fill_data); | 102 const PasswordFormFillData& fill_data); |
| 104 | 103 |
| 105 virtual void HideAutofillPopup(); | 104 virtual void HideAutofillPopup(); |
| 106 | 105 |
| 107 protected: | 106 protected: |
| 108 friend class content::WebContentsUserData<AutofillExternalDelegate>; | 107 friend class content::WebContentsUserData<AutofillExternalDelegate>; |
| 109 AutofillExternalDelegate(content::WebContents* web_contents, | 108 AutofillExternalDelegate(content::WebContents* web_contents, |
| 110 AutofillManager* autofill_manager); | 109 AutofillManager* autofill_manager); |
| 111 virtual ~AutofillExternalDelegate(); | 110 virtual ~AutofillExternalDelegate(); |
| 112 | 111 |
| 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_; } | 112 content::WebContents* web_contents() { return web_contents_; } |
| 127 | 113 |
| 128 AutofillPopupControllerImpl* controller() { return controller_; } | |
| 129 | |
| 130 private: | 114 private: |
| 131 // Fills the form with the Autofill data corresponding to |unique_id|. | 115 // 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 | 116 // 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 | 117 // would be selected and if |is_preview| is false then the user has selected |
| 134 // this data. | 118 // this data. |
| 135 void FillAutofillFormData(int unique_id, bool is_preview); | 119 void FillAutofillFormData(int unique_id, bool is_preview); |
| 136 | 120 |
| 137 // Handle applying any Autofill warnings to the Autofill popup. | 121 // Handle applying any Autofill warnings to the Autofill popup. |
| 138 void ApplyAutofillWarnings(std::vector<string16>* autofill_values, | 122 void ApplyAutofillWarnings(std::vector<string16>* autofill_values, |
| 139 std::vector<string16>* autofill_labels, | 123 std::vector<string16>* autofill_labels, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 156 std::vector<int>* autofill_unique_ids); | 140 std::vector<int>* autofill_unique_ids); |
| 157 | 141 |
| 158 // content::NotificationObserver method override. | 142 // content::NotificationObserver method override. |
| 159 virtual void Observe(int type, | 143 virtual void Observe(int type, |
| 160 const content::NotificationSource& source, | 144 const content::NotificationSource& source, |
| 161 const content::NotificationDetails& details) OVERRIDE; | 145 const content::NotificationDetails& details) OVERRIDE; |
| 162 | 146 |
| 163 // The web_contents associated with this delegate. | 147 // The web_contents associated with this delegate. |
| 164 content::WebContents* web_contents_; // weak; owns me. | 148 content::WebContents* web_contents_; // weak; owns me. |
| 165 AutofillManager* autofill_manager_; // weak. | 149 AutofillManager* autofill_manager_; // weak. |
| 166 base::WeakPtr<AutofillPopupControllerImpl> controller_; | |
| 167 | 150 |
| 168 // Password Autofill manager, handles all password-related Autofilling. | 151 // Password Autofill manager, handles all password-related Autofilling. |
| 169 PasswordAutofillManager password_autofill_manager_; | 152 PasswordAutofillManager password_autofill_manager_; |
| 170 | 153 |
| 171 // The ID of the last request sent for form field Autofill. Used to ignore | 154 // The ID of the last request sent for form field Autofill. Used to ignore |
| 172 // out of date responses. | 155 // out of date responses. |
| 173 int autofill_query_id_; | 156 int autofill_query_id_; |
| 174 | 157 |
| 175 // A scoped container for notification registries. | 158 // A scoped container for notification registries. |
| 176 content::NotificationRegistrar registrar_; | 159 content::NotificationRegistrar registrar_; |
| 177 | 160 |
| 178 // The current form and field selected by Autofill. | 161 // The current form and field selected by Autofill. |
| 179 FormData autofill_query_form_; | 162 FormData autofill_query_form_; |
| 180 FormFieldData autofill_query_field_; | 163 FormFieldData autofill_query_field_; |
| 181 | 164 |
| 165 // The bounds of the form field that user is interacting with. |
| 166 gfx::RectF element_bounds_; |
| 167 |
| 182 // Should we display a warning if Autofill is disabled? | 168 // Should we display a warning if Autofill is disabled? |
| 183 bool display_warning_if_disabled_; | 169 bool display_warning_if_disabled_; |
| 184 | 170 |
| 185 // Does the popup include any Autofill profile or credit card suggestions? | 171 // Does the popup include any Autofill profile or credit card suggestions? |
| 186 bool has_autofill_suggestion_; | 172 bool has_autofill_suggestion_; |
| 187 | 173 |
| 188 // 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 |
| 189 // currently editing? Used to keep track of state for metrics logging. | 175 // currently editing? Used to keep track of state for metrics logging. |
| 190 bool has_shown_autofill_popup_for_current_edit_; | 176 bool has_shown_autofill_popup_for_current_edit_; |
| 191 | 177 |
| 192 // The RenderViewHost that this object has been registered with as a | 178 // The RenderViewHost that this object has been registered with as a |
| 193 // keyboard listener. | 179 // keyboard listener. |
| 194 content::RenderViewHost* registered_keyboard_listener_with_; | 180 content::RenderViewHost* registered_keyboard_listener_with_; |
| 195 | 181 |
| 196 // The current data list values. | 182 // The current data list values. |
| 197 std::vector<string16> data_list_values_; | 183 std::vector<string16> data_list_values_; |
| 198 std::vector<string16> data_list_labels_; | 184 std::vector<string16> data_list_labels_; |
| 199 std::vector<string16> data_list_icons_; | 185 std::vector<string16> data_list_icons_; |
| 200 std::vector<int> data_list_unique_ids_; | 186 std::vector<int> data_list_unique_ids_; |
| 201 | 187 |
| 202 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); | 188 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); |
| 203 }; | 189 }; |
| 204 | 190 |
| 205 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ | 191 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ |
| OLD | NEW |