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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
| 13 #include "chrome/browser/autofill/password_autofill_manager.h" |
13 #include "webkit/forms/form_data.h" | 14 #include "webkit/forms/form_data.h" |
14 #include "webkit/forms/form_field.h" | 15 #include "webkit/forms/form_field.h" |
| 16 #include "webkit/forms/password_form_dom_manager.h" |
15 | 17 |
16 class AutofillManager; | 18 class AutofillManager; |
17 class TabContentsWrapper; | 19 class TabContentsWrapper; |
18 | 20 |
19 namespace gfx { | 21 namespace gfx { |
20 class Rect; | 22 class Rect; |
21 } | 23 } |
22 | 24 |
23 // TODO(csharp): A lot of the logic in this class is copied from autofillagent. | 25 // TODO(csharp): A lot of the logic in this class is copied from autofillagent. |
24 // Once Autofill is moved out of WebKit this class should be the only home for | 26 // Once Autofill is moved out of WebKit this class should be the only home for |
(...skipping 25 matching lines...) Expand all Loading... |
50 | 52 |
51 // Records query results and correctly formats them before sending them off | 53 // Records query results and correctly formats them before sending them off |
52 // to be displayed. Called when an Autofill query result is available. | 54 // to be displayed. Called when an Autofill query result is available. |
53 virtual void OnSuggestionsReturned( | 55 virtual void OnSuggestionsReturned( |
54 int query_id, | 56 int query_id, |
55 const std::vector<string16>& autofill_values, | 57 const std::vector<string16>& autofill_values, |
56 const std::vector<string16>& autofill_labels, | 58 const std::vector<string16>& autofill_labels, |
57 const std::vector<string16>& autofill_icons, | 59 const std::vector<string16>& autofill_icons, |
58 const std::vector<int>& autofill_unique_ids); | 60 const std::vector<int>& autofill_unique_ids); |
59 | 61 |
| 62 // Show password suggestions in the popup. |
| 63 void OnShowPasswordSuggestions(const std::vector<string16>& suggestions, |
| 64 const webkit::forms::FormField& field, |
| 65 const gfx::Rect& bounds); |
| 66 |
60 // Inform the delegate that the text field editing has ended, this is | 67 // Inform the delegate that the text field editing has ended, this is |
61 // used to help record the metrics of when a new popup is shown. | 68 // used to help record the metrics of when a new popup is shown. |
62 void DidEndTextFieldEditing(); | 69 void DidEndTextFieldEditing(); |
63 | 70 |
64 // Inform the delegate that an autofill suggestion have been chosen. Returns | 71 // Inform the delegate that an autofill suggestion have been chosen. Returns |
65 // true if the suggestion was selected. | 72 // true if the suggestion was selected. |
66 bool DidAcceptAutofillSuggestions(const string16& value, | 73 bool DidAcceptAutofillSuggestions(const string16& value, |
67 int unique_id, | 74 int unique_id, |
68 unsigned index); | 75 unsigned index); |
69 | 76 |
70 // Informs the delegate that the Autofill previewed form should be cleared. | 77 // Informs the delegate that the Autofill previewed form should be cleared. |
71 virtual void ClearPreviewedForm(); | 78 virtual void ClearPreviewedForm(); |
72 | 79 |
73 // Hide the Autofill poup. | 80 // Hide the Autofill poup. |
74 virtual void HideAutofillPopup(); | 81 virtual void HideAutofillPopup(); |
75 | 82 |
| 83 // Returns the delegate to its starting state by removing any page specific |
| 84 // values or settings. |
| 85 void Reset(); |
| 86 |
| 87 // Inform the Password Manager of a filled form. |
| 88 void AddPasswordFormMapping( |
| 89 const webkit::forms::FormField& form, |
| 90 const webkit::forms::PasswordFormFillData& fill_data); |
| 91 |
76 // Platforms that wish to implement an external Autofill delegate | 92 // Platforms that wish to implement an external Autofill delegate |
77 // MUST implement this. The 1st arg is the tab contents that owns | 93 // MUST implement this. The 1st arg is the tab contents that owns |
78 // this delegate; the second is the Autofill manager owned by the | 94 // this delegate; the second is the Autofill manager owned by the |
79 // tab contents. | 95 // tab contents. |
80 static AutofillExternalDelegate* Create(TabContentsWrapper*, | 96 static AutofillExternalDelegate* Create(TabContentsWrapper*, |
81 AutofillManager*); | 97 AutofillManager*); |
82 protected: | 98 protected: |
83 explicit AutofillExternalDelegate(TabContentsWrapper* tab_contents_wrapper, | 99 explicit AutofillExternalDelegate(TabContentsWrapper* tab_contents_wrapper, |
84 AutofillManager* autofill_manager); | 100 AutofillManager* autofill_manager); |
85 | 101 |
86 // Displays the the Autofill results to the user with an external | 102 // Displays the the Autofill results to the user with an external |
87 // Autofill popup that lives completely in the browser. The suggestions | 103 // Autofill popup that lives completely in the browser. The suggestions |
88 // have be correctly formatted by this point. | 104 // have be correctly formatted by this point. |
89 virtual void ApplyAutofillSuggestions( | 105 virtual void ApplyAutofillSuggestions( |
90 const std::vector<string16>& autofill_values, | 106 const std::vector<string16>& autofill_values, |
91 const std::vector<string16>& autofill_labels, | 107 const std::vector<string16>& autofill_labels, |
92 const std::vector<string16>& autofill_icons, | 108 const std::vector<string16>& autofill_icons, |
93 const std::vector<int>& autofill_unique_ids, | 109 const std::vector<int>& autofill_unique_ids, |
94 int separator_index) = 0; | 110 int separator_index) = 0; |
95 | 111 |
96 // Handle instance specific OnQueryCode. | 112 // Handle instance specific OnQueryCode. |
97 virtual void OnQueryPlatformSpecific(int query_id, | 113 virtual void OnQueryPlatformSpecific(int query_id, |
98 const webkit::forms::FormData& form, | 114 const webkit::forms::FormData& form, |
99 const webkit::forms::FormField& field, | 115 const webkit::forms::FormField& field, |
100 const gfx::Rect& bounds) = 0; | 116 const gfx::Rect& bounds) = 0; |
101 | 117 |
102 // Handle platform-dependent hiding. | 118 // Handle platform-dependent hiding. |
103 virtual void HideAutofillPopupInternal() = 0; | 119 virtual void HideAutofillPopupInternal() = 0; |
104 | 120 |
| 121 // Set the bounds of the Autofill element being worked with. |
| 122 virtual void SetBounds(const gfx::Rect& bounds) = 0; |
| 123 |
105 private: | 124 private: |
106 // Fills the form with the Autofill data corresponding to |unique_id|. | 125 // Fills the form with the Autofill data corresponding to |unique_id|. |
107 // If |is_preview| is true then this is just a preview to show the user what | 126 // If |is_preview| is true then this is just a preview to show the user what |
108 // would be selected and if |is_preview| is false then the user has selected | 127 // would be selected and if |is_preview| is false then the user has selected |
109 // this data. | 128 // this data. |
110 void FillAutofillFormData(int unique_id, bool is_preview); | 129 void FillAutofillFormData(int unique_id, bool is_preview); |
111 | 130 |
112 TabContentsWrapper* tab_contents_wrapper_; // weak; owns me. | 131 TabContentsWrapper* tab_contents_wrapper_; // weak; owns me. |
113 AutofillManager* autofill_manager_; // weak. | 132 AutofillManager* autofill_manager_; // weak. |
114 | 133 |
| 134 // Password Autofill manager, handles all password-related Autofilling. |
| 135 PasswordAutofillManager password_autofill_manager_; |
| 136 |
115 // The ID of the last request sent for form field Autofill. Used to ignore | 137 // The ID of the last request sent for form field Autofill. Used to ignore |
116 // out of date responses. | 138 // out of date responses. |
117 int autofill_query_id_; | 139 int autofill_query_id_; |
118 | 140 |
119 // The current form and field selected by Autofill. | 141 // The current form and field selected by Autofill. |
120 webkit::forms::FormData autofill_query_form_; | 142 webkit::forms::FormData autofill_query_form_; |
121 webkit::forms::FormField autofill_query_field_; | 143 webkit::forms::FormField autofill_query_field_; |
122 | 144 |
123 // Should we display a warning if Autofill is disabled? | 145 // Should we display a warning if Autofill is disabled? |
124 bool display_warning_if_disabled_; | 146 bool display_warning_if_disabled_; |
125 | 147 |
126 // Have we already shown Autofill suggestions for the field the user is | 148 // Have we already shown Autofill suggestions for the field the user is |
127 // currently editing? Used to keep track of state for metrics logging. | 149 // currently editing? Used to keep track of state for metrics logging. |
128 bool has_shown_autofill_popup_for_current_edit_; | 150 bool has_shown_autofill_popup_for_current_edit_; |
129 | 151 |
130 // The menu index of the "Clear" menu item. | 152 // The menu index of the "Clear" menu item. |
131 int suggestions_clear_index_; | 153 int suggestions_clear_index_; |
132 | 154 |
133 // The menu index of the "Autofill options..." menu item. | 155 // The menu index of the "Autofill options..." menu item. |
134 int suggestions_options_index_; | 156 int suggestions_options_index_; |
135 | 157 |
136 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); | 158 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); |
137 }; | 159 }; |
138 | 160 |
139 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ | 161 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ |
OLD | NEW |