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 "chrome/browser/autofill/password_autofill_manager.h" |
14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 14 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
15 #include "webkit/forms/form_data.h" | 15 #include "webkit/forms/form_data.h" |
16 #include "webkit/forms/form_field.h" | 16 #include "webkit/forms/form_field.h" |
17 #include "webkit/forms/password_form_dom_manager.h" | 17 #include "webkit/forms/password_form_dom_manager.h" |
18 | 18 |
19 class AutofillManager; | 19 class AutofillManager; |
20 | 20 |
21 namespace gfx { | 21 namespace gfx { |
22 class Rect; | 22 class Rect; |
23 } | 23 } |
24 | 24 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 // Inform the Password Manager of a filled form. | 92 // Inform the Password Manager of a filled form. |
93 void AddPasswordFormMapping( | 93 void AddPasswordFormMapping( |
94 const webkit::forms::FormField& form, | 94 const webkit::forms::FormField& form, |
95 const webkit::forms::PasswordFormFillData& fill_data); | 95 const webkit::forms::PasswordFormFillData& fill_data); |
96 | 96 |
97 // Platforms that wish to implement an external Autofill delegate | 97 // Platforms that wish to implement an external Autofill delegate |
98 // MUST implement this. The 1st arg is the tab contents that owns | 98 // MUST implement this. The 1st arg is the tab contents that owns |
99 // this delegate; the second is the Autofill manager owned by the | 99 // this delegate; the second is the Autofill manager owned by the |
100 // tab contents. | 100 // tab contents. |
101 static AutofillExternalDelegate* Create(TabContentsWrapper*, | 101 static AutofillExternalDelegate* Create(TabContents*, |
102 AutofillManager*); | 102 AutofillManager*); |
103 protected: | 103 protected: |
104 explicit AutofillExternalDelegate(TabContentsWrapper* tab_contents_wrapper, | 104 explicit AutofillExternalDelegate(TabContents* tab_contents, |
105 AutofillManager* autofill_manager); | 105 AutofillManager* autofill_manager); |
106 | 106 |
107 // Displays the the Autofill results to the user with an external | 107 // Displays the the Autofill results to the user with an external |
108 // Autofill popup that lives completely in the browser. The suggestions | 108 // Autofill popup that lives completely in the browser. The suggestions |
109 // have be correctly formatted by this point. | 109 // have be correctly formatted by this point. |
110 virtual void ApplyAutofillSuggestions( | 110 virtual void ApplyAutofillSuggestions( |
111 const std::vector<string16>& autofill_values, | 111 const std::vector<string16>& autofill_values, |
112 const std::vector<string16>& autofill_labels, | 112 const std::vector<string16>& autofill_labels, |
113 const std::vector<string16>& autofill_icons, | 113 const std::vector<string16>& autofill_icons, |
114 const std::vector<int>& autofill_unique_ids) = 0; | 114 const std::vector<int>& autofill_unique_ids) = 0; |
115 | 115 |
116 // Handle instance specific OnQueryCode. | 116 // Handle instance specific OnQueryCode. |
117 virtual void OnQueryPlatformSpecific(int query_id, | 117 virtual void OnQueryPlatformSpecific(int query_id, |
118 const webkit::forms::FormData& form, | 118 const webkit::forms::FormData& form, |
119 const webkit::forms::FormField& field, | 119 const webkit::forms::FormField& field, |
120 const gfx::Rect& bounds) = 0; | 120 const gfx::Rect& bounds) = 0; |
121 | 121 |
122 // Handle platform-dependent hiding. | 122 // Handle platform-dependent hiding. |
123 virtual void HideAutofillPopupInternal() = 0; | 123 virtual void HideAutofillPopupInternal() = 0; |
124 | 124 |
125 // Set the bounds of the Autofill element being worked with. | 125 // Set the bounds of the Autofill element being worked with. |
126 virtual void SetBounds(const gfx::Rect& bounds) = 0; | 126 virtual void SetBounds(const gfx::Rect& bounds) = 0; |
127 | 127 |
128 // Return the profile that this autofill delegate is currently working with. | 128 // Return the profile that this autofill delegate is currently working with. |
129 Profile* profile() { return tab_contents_wrapper_->profile(); } | 129 Profile* profile() { return tab_contents_->profile(); } |
130 | 130 |
131 private: | 131 private: |
132 // Fills the form with the Autofill data corresponding to |unique_id|. | 132 // Fills the form with the Autofill data corresponding to |unique_id|. |
133 // If |is_preview| is true then this is just a preview to show the user what | 133 // If |is_preview| is true then this is just a preview to show the user what |
134 // would be selected and if |is_preview| is false then the user has selected | 134 // would be selected and if |is_preview| is false then the user has selected |
135 // this data. | 135 // this data. |
136 void FillAutofillFormData(int unique_id, bool is_preview); | 136 void FillAutofillFormData(int unique_id, bool is_preview); |
137 | 137 |
138 TabContentsWrapper* tab_contents_wrapper_; // weak; owns me. | 138 TabContents* tab_contents_; // weak; owns me. |
139 AutofillManager* autofill_manager_; // weak. | 139 AutofillManager* autofill_manager_; // weak. |
140 | 140 |
141 // Password Autofill manager, handles all password-related Autofilling. | 141 // Password Autofill manager, handles all password-related Autofilling. |
142 PasswordAutofillManager password_autofill_manager_; | 142 PasswordAutofillManager password_autofill_manager_; |
143 | 143 |
144 // The ID of the last request sent for form field Autofill. Used to ignore | 144 // The ID of the last request sent for form field Autofill. Used to ignore |
145 // out of date responses. | 145 // out of date responses. |
146 int autofill_query_id_; | 146 int autofill_query_id_; |
147 | 147 |
148 // The current form and field selected by Autofill. | 148 // The current form and field selected by Autofill. |
149 webkit::forms::FormData autofill_query_form_; | 149 webkit::forms::FormData autofill_query_form_; |
150 webkit::forms::FormField autofill_query_field_; | 150 webkit::forms::FormField autofill_query_field_; |
151 | 151 |
152 // Should we display a warning if Autofill is disabled? | 152 // Should we display a warning if Autofill is disabled? |
153 bool display_warning_if_disabled_; | 153 bool display_warning_if_disabled_; |
154 | 154 |
155 // Have we already shown Autofill suggestions for the field the user is | 155 // Have we already shown Autofill suggestions for the field the user is |
156 // currently editing? Used to keep track of state for metrics logging. | 156 // currently editing? Used to keep track of state for metrics logging. |
157 bool has_shown_autofill_popup_for_current_edit_; | 157 bool has_shown_autofill_popup_for_current_edit_; |
158 | 158 |
159 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); | 159 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); |
160 }; | 160 }; |
161 | 161 |
162 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ | 162 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ |
OLD | NEW |