OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "webkit/glue/form_field.h" | 12 #include "webkit/forms/form_field.h" |
13 | 13 |
14 class AutofillManager; | 14 class AutofillManager; |
15 class TabContentsWrapper; | 15 class TabContentsWrapper; |
16 | 16 |
17 namespace gfx { | 17 namespace gfx { |
18 class Rect; | 18 class Rect; |
19 } | 19 } |
20 | 20 |
21 namespace webkit_glue { | 21 namespace webkit { |
| 22 namespace forms { |
22 struct FormData; | 23 struct FormData; |
23 } // namespace webkit_glue | 24 } |
| 25 } |
24 | 26 |
25 // TODO(csharp): A lot of the logic in this class is copied from autofillagent. | 27 // TODO(csharp): A lot of the logic in this class is copied from autofillagent. |
26 // Once Autofill is moved out of WebKit this class should be the only home for | 28 // Once Autofill is moved out of WebKit this class should be the only home for |
27 // this logic. See http://crbug.com/51644 | 29 // this logic. See http://crbug.com/51644 |
28 | 30 |
29 // Delegate for external processing of Autocomplete and Autofill | 31 // Delegate for external processing of Autocomplete and Autofill |
30 // display and selection. | 32 // display and selection. |
31 class AutofillExternalDelegate { | 33 class AutofillExternalDelegate { |
32 public: | 34 public: |
33 virtual ~AutofillExternalDelegate(); | 35 virtual ~AutofillExternalDelegate(); |
34 | 36 |
35 // When using an external Autofill delegate. Allows Chrome to tell | 37 // When using an external Autofill delegate. Allows Chrome to tell |
36 // WebKit which Autofill selection has been chosen. | 38 // WebKit which Autofill selection has been chosen. |
37 // TODO(jrg): add feedback mechanism for hover on relevant platforms. | 39 // TODO(jrg): add feedback mechanism for hover on relevant platforms. |
38 void SelectAutofillSuggestionAtIndex(int listIndex); | 40 void SelectAutofillSuggestionAtIndex(int listIndex); |
39 | 41 |
40 // Records and associates a query_id with web form data. Called | 42 // Records and associates a query_id with web form data. Called |
41 // when the renderer posts an Autofill query to the browser. |bounds| | 43 // when the renderer posts an Autofill query to the browser. |bounds| |
42 // is window relative. |display_warning_if_disabled| tells us if we should | 44 // is window relative. |display_warning_if_disabled| tells us if we should |
43 // display warnings (such as autofill is disabled, but had suggestions). | 45 // display warnings (such as autofill is disabled, but had suggestions). |
44 // We might not want to display the warning if a website has disabled | 46 // We might not want to display the warning if a website has disabled |
45 // Autocomplete because they have their own popup, and showing our popup | 47 // Autocomplete because they have their own popup, and showing our popup |
46 // on to of theirs would be a poor user experience. | 48 // on to of theirs would be a poor user experience. |
47 virtual void OnQuery(int query_id, | 49 virtual void OnQuery(int query_id, |
48 const webkit_glue::FormData& form, | 50 const webkit::forms::FormData& form, |
49 const webkit_glue::FormField& field, | 51 const webkit::forms::FormField& field, |
50 const gfx::Rect& bounds, | 52 const gfx::Rect& bounds, |
51 bool display_warning_if_disabled); | 53 bool display_warning_if_disabled); |
52 | 54 |
53 // Records query results and correctly formats them before sending them off | 55 // Records query results and correctly formats them before sending them off |
54 // to be displayed. Called when an Autofill query result is available. | 56 // to be displayed. Called when an Autofill query result is available. |
55 virtual void OnSuggestionsReturned( | 57 virtual void OnSuggestionsReturned( |
56 int query_id, | 58 int query_id, |
57 const std::vector<string16>& autofill_values, | 59 const std::vector<string16>& autofill_values, |
58 const std::vector<string16>& autofill_labels, | 60 const std::vector<string16>& autofill_labels, |
59 const std::vector<string16>& autofill_icons, | 61 const std::vector<string16>& autofill_icons, |
(...skipping 20 matching lines...) Expand all Loading... |
80 // Autofill popup that lives completely in the browser. The suggestions | 82 // Autofill popup that lives completely in the browser. The suggestions |
81 // have be correctly formatted by this point. | 83 // have be correctly formatted by this point. |
82 virtual void ApplyAutofillSuggestions( | 84 virtual void ApplyAutofillSuggestions( |
83 const std::vector<string16>& autofill_values, | 85 const std::vector<string16>& autofill_values, |
84 const std::vector<string16>& autofill_labels, | 86 const std::vector<string16>& autofill_labels, |
85 const std::vector<string16>& autofill_icons, | 87 const std::vector<string16>& autofill_icons, |
86 const std::vector<int>& autofill_unique_ids, | 88 const std::vector<int>& autofill_unique_ids, |
87 int separator_index) = 0; | 89 int separator_index) = 0; |
88 | 90 |
89 // Handle instance specific OnQueryCode. | 91 // Handle instance specific OnQueryCode. |
90 virtual void OnQueryPlatformSpecific(int query_id, | 92 virtual void OnQueryPlatformSpecific( |
91 const webkit_glue::FormData& form, | 93 int query_id, |
92 const webkit_glue::FormField& field) = 0; | 94 const webkit::forms::FormData& form, |
| 95 const webkit::forms::FormField& field) = 0; |
93 | 96 |
94 private: | 97 private: |
95 TabContentsWrapper* tab_contents_wrapper_; // weak; owns me. | 98 TabContentsWrapper* tab_contents_wrapper_; // weak; owns me. |
96 | 99 |
97 // The ID of the last request sent for form field Autofill. Used to ignore | 100 // The ID of the last request sent for form field Autofill. Used to ignore |
98 // out of date responses. | 101 // out of date responses. |
99 int autofill_query_id_; | 102 int autofill_query_id_; |
100 | 103 |
101 // The current field selected by Autofill. | 104 // The current field selected by Autofill. |
102 webkit_glue::FormField autofill_query_field_; | 105 webkit::forms::FormField autofill_query_field_; |
103 | 106 |
104 // Should we display a warning if Autofill is disabled? | 107 // Should we display a warning if Autofill is disabled? |
105 bool display_warning_if_disabled_; | 108 bool display_warning_if_disabled_; |
106 | 109 |
107 // Have we already shown Autofill suggestions for the field the user is | 110 // Have we already shown Autofill suggestions for the field the user is |
108 // currently editing? Used to keep track of state for metrics logging. | 111 // currently editing? Used to keep track of state for metrics logging. |
109 bool has_shown_autofill_popup_for_current_edit_; | 112 bool has_shown_autofill_popup_for_current_edit_; |
110 | 113 |
111 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); | 114 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); |
112 }; | 115 }; |
113 | 116 |
114 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ | 117 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ |
OLD | NEW |