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" | 14 #include "components/autofill/core/browser/password_autofill_manager.h" |
15 #include "components/autofill/core/common/form_data.h" | 15 #include "components/autofill/core/common/form_data.h" |
16 #include "components/autofill/core/common/form_field_data.h" | 16 #include "components/autofill/core/common/form_field_data.h" |
17 #include "components/autofill/core/common/password_form_fill_data.h" | 17 #include "components/autofill/core/common/password_form_fill_data.h" |
18 #include "content/public/browser/notification_observer.h" | |
19 #include "content/public/browser/notification_registrar.h" | |
20 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
21 | 19 |
22 namespace gfx { | 20 namespace gfx { |
23 class Rect; | 21 class Rect; |
24 } | 22 } |
25 | 23 |
26 namespace content { | 24 namespace content { |
27 class RenderViewHost; | 25 class RenderViewHost; |
28 class WebContents; | 26 class WebContents; |
29 } | 27 } |
30 | 28 |
31 namespace autofill { | 29 namespace autofill { |
32 | 30 |
33 class AutofillManager; | 31 class AutofillManager; |
34 | 32 |
35 // 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. |
36 // Once Autofill is moved out of WebKit this class should be the only home for | 34 // Once Autofill is moved out of WebKit this class should be the only home for |
37 // this logic. See http://crbug.com/51644 | 35 // this logic. See http://crbug.com/51644 |
38 | 36 |
39 // Delegate for in-browser Autocomplete and Autofill display and selection. | 37 // Delegate for in-browser Autocomplete and Autofill display and selection. |
40 class AutofillExternalDelegate | 38 class AutofillExternalDelegate |
41 : public content::NotificationObserver, | 39 : public AutofillPopupDelegate { |
42 public AutofillPopupDelegate { | |
43 public: | 40 public: |
44 // Creates an AutofillExternalDelegate for the specified contents; the second | 41 // Creates an AutofillExternalDelegate for the specified contents; the second |
45 // argument is an AutofillManager managing Autofill for that WebContents. | 42 // argument is an AutofillManager managing Autofill for that WebContents. |
46 AutofillExternalDelegate(content::WebContents* web_contents, | 43 AutofillExternalDelegate(content::WebContents* web_contents, |
47 AutofillManager* autofill_manager); | 44 AutofillManager* autofill_manager); |
48 virtual ~AutofillExternalDelegate(); | 45 virtual ~AutofillExternalDelegate(); |
49 | 46 |
50 // AutofillPopupDelegate implementation. | 47 // AutofillPopupDelegate implementation. |
51 virtual void OnPopupShown(content::KeyboardListener* listener) OVERRIDE; | 48 virtual void OnPopupShown(content::KeyboardListener* listener) OVERRIDE; |
52 virtual void OnPopupHidden(content::KeyboardListener* listener) OVERRIDE; | 49 virtual void OnPopupHidden(content::KeyboardListener* listener) OVERRIDE; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 std::vector<base::string16>* autofill_icons, | 128 std::vector<base::string16>* autofill_icons, |
132 std::vector<int>* autofill_unique_ids); | 129 std::vector<int>* autofill_unique_ids); |
133 | 130 |
134 // Insert the data list values at the start of the given list, including | 131 // Insert the data list values at the start of the given list, including |
135 // any required separators. | 132 // any required separators. |
136 void InsertDataListValues(std::vector<base::string16>* autofill_values, | 133 void InsertDataListValues(std::vector<base::string16>* autofill_values, |
137 std::vector<base::string16>* autofill_labels, | 134 std::vector<base::string16>* autofill_labels, |
138 std::vector<base::string16>* autofill_icons, | 135 std::vector<base::string16>* autofill_icons, |
139 std::vector<int>* autofill_unique_ids); | 136 std::vector<int>* autofill_unique_ids); |
140 | 137 |
141 // content::NotificationObserver method override. | |
142 virtual void Observe(int type, | |
143 const content::NotificationSource& source, | |
144 const content::NotificationDetails& details) OVERRIDE; | |
145 | |
146 // The web_contents associated with this delegate. | 138 // The web_contents associated with this delegate. |
147 content::WebContents* web_contents_; // weak; owns me. | 139 content::WebContents* web_contents_; // weak; owns me. |
148 AutofillManager* autofill_manager_; // weak. | 140 AutofillManager* autofill_manager_; // weak. |
149 | 141 |
150 // Password Autofill manager, handles all password-related Autofilling. | 142 // Password Autofill manager, handles all password-related Autofilling. |
151 PasswordAutofillManager password_autofill_manager_; | 143 PasswordAutofillManager password_autofill_manager_; |
152 | 144 |
153 // The ID of the last request sent for form field Autofill. Used to ignore | 145 // The ID of the last request sent for form field Autofill. Used to ignore |
154 // out of date responses. | 146 // out of date responses. |
155 int autofill_query_id_; | 147 int autofill_query_id_; |
156 | 148 |
157 // A scoped container for notification registries. | |
158 content::NotificationRegistrar registrar_; | |
159 | |
160 // The current form and field selected by Autofill. | 149 // The current form and field selected by Autofill. |
161 FormData autofill_query_form_; | 150 FormData autofill_query_form_; |
162 FormFieldData autofill_query_field_; | 151 FormFieldData autofill_query_field_; |
163 | 152 |
164 // The bounds of the form field that user is interacting with. | 153 // The bounds of the form field that user is interacting with. |
165 gfx::RectF element_bounds_; | 154 gfx::RectF element_bounds_; |
166 | 155 |
167 // Should we display a warning if Autofill is disabled? | 156 // Should we display a warning if Autofill is disabled? |
168 bool display_warning_if_disabled_; | 157 bool display_warning_if_disabled_; |
169 | 158 |
(...skipping 15 matching lines...) Expand all Loading... |
185 std::vector<int> data_list_unique_ids_; | 174 std::vector<int> data_list_unique_ids_; |
186 | 175 |
187 base::WeakPtrFactory<AutofillExternalDelegate> weak_ptr_factory_; | 176 base::WeakPtrFactory<AutofillExternalDelegate> weak_ptr_factory_; |
188 | 177 |
189 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); | 178 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); |
190 }; | 179 }; |
191 | 180 |
192 } // namespace autofill | 181 } // namespace autofill |
193 | 182 |
194 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_EXTERNAL_DELEGATE_H_ | 183 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_EXTERNAL_DELEGATE_H_ |
OLD | NEW |