Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: chrome/browser/autofill/autofill_external_delegate.cc

Issue 9600038: Add Password Autofill Manager to New Autofill (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "base/utf_string_conversions.h" 5 #include "base/utf_string_conversions.h"
6 #include "chrome/browser/autofill/autofill_external_delegate.h" 6 #include "chrome/browser/autofill/autofill_external_delegate.h"
7 #include "chrome/browser/autofill/autofill_manager.h" 7 #include "chrome/browser/autofill/autofill_manager.h"
8 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 8 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
9 #include "chrome/common/autofill_messages.h" 9 #include "chrome/common/autofill_messages.h"
10 #include "chrome/common/chrome_constants.h" 10 #include "chrome/common/chrome_constants.h"
11 #include "content/browser/renderer_host/render_view_host.h" 11 #include "content/browser/renderer_host/render_view_host.h"
12 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
13 #include "grit/chromium_strings.h" 13 #include "grit/chromium_strings.h"
14 #include "grit/generated_resources.h" 14 #include "grit/generated_resources.h"
15 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
16 16
17 AutofillExternalDelegate::~AutofillExternalDelegate() { 17 AutofillExternalDelegate::~AutofillExternalDelegate() {
18 } 18 }
19 19
20 AutofillExternalDelegate::AutofillExternalDelegate( 20 AutofillExternalDelegate::AutofillExternalDelegate(
21 TabContentsWrapper* tab_contents_wrapper, 21 TabContentsWrapper* tab_contents_wrapper,
22 AutofillManager* autofill_manager) 22 AutofillManager* autofill_manager)
23 : tab_contents_wrapper_(tab_contents_wrapper), 23 : tab_contents_wrapper_(tab_contents_wrapper),
24 autofill_manager_(autofill_manager), 24 autofill_manager_(autofill_manager),
25 password_autofill_manager_(tab_contents_wrapper),
25 autofill_query_id_(0), 26 autofill_query_id_(0),
26 display_warning_if_disabled_(false), 27 display_warning_if_disabled_(false),
27 has_shown_autofill_popup_for_current_edit_(false), 28 has_shown_autofill_popup_for_current_edit_(false),
28 suggestions_clear_index_(-1), 29 suggestions_clear_index_(-1),
29 suggestions_options_index_(-1) { 30 suggestions_options_index_(-1) {
30 } 31 }
31 32
32 void AutofillExternalDelegate::SelectAutofillSuggestionAtIndex(int unique_id, 33 void AutofillExternalDelegate::SelectAutofillSuggestionAtIndex(int unique_id,
33 int list_index) { 34 int list_index) {
35 if (password_autofill_manager_.DidSelectAutofillSuggestion(
36 autofill_query_field_))
37 return;
38
34 if (list_index == suggestions_options_index_ || 39 if (list_index == suggestions_options_index_ ||
35 list_index == suggestions_clear_index_ || 40 list_index == suggestions_clear_index_ ||
36 unique_id == -1) 41 unique_id == -1)
37 return; 42 return;
38 43
39 FillAutofillFormData(unique_id, true); 44 FillAutofillFormData(unique_id, true);
40 } 45 }
41 46
42 void AutofillExternalDelegate::OnQuery(int query_id, 47 void AutofillExternalDelegate::OnQuery(int query_id,
43 const webkit::forms::FormData& form, 48 const webkit::forms::FormData& form,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 144 }
140 145
141 void AutofillExternalDelegate::DidAcceptAutofillSuggestions( 146 void AutofillExternalDelegate::DidAcceptAutofillSuggestions(
142 const string16& value, 147 const string16& value,
143 int unique_id, 148 int unique_id,
144 unsigned index) { 149 unsigned index) {
145 // If the selected element is a warning we don't want to do anything. 150 // If the selected element is a warning we don't want to do anything.
146 if (unique_id < 0) 151 if (unique_id < 0)
147 return; 152 return;
148 153
149 // TODO(csharp): Add the password autofill manager. 154 if (password_autofill_manager_.DidAcceptAutofillSuggestion(
150 // if (password_autofill_manager_->DidAcceptAutofillSuggestion(node, value)) 155 autofill_query_field_, value))
151 // return; 156 return;
152 157
153 if (suggestions_options_index_ != -1 && 158 if (suggestions_options_index_ != -1 &&
154 index == static_cast<unsigned>(suggestions_options_index_)) { 159 index == static_cast<unsigned>(suggestions_options_index_)) {
155 // User selected 'Autofill Options'. 160 // User selected 'Autofill Options'.
156 autofill_manager_->OnShowAutofillDialog(); 161 autofill_manager_->OnShowAutofillDialog();
157 } else if (suggestions_clear_index_ != -1 && 162 } else if (suggestions_clear_index_ != -1 &&
158 index == static_cast<unsigned>(suggestions_clear_index_)) { 163 index == static_cast<unsigned>(suggestions_clear_index_)) {
159 // User selected 'Clear form'. 164 // User selected 'Clear form'.
160 RenderViewHost* host = 165 RenderViewHost* host =
161 tab_contents_wrapper_->web_contents()->GetRenderViewHost(); 166 tab_contents_wrapper_->web_contents()->GetRenderViewHost();
162 host->Send(new AutofillMsg_ClearForm(host->GetRoutingID())); 167 host->Send(new AutofillMsg_ClearForm(host->GetRoutingID()));
163 } else if (!unique_id) { 168 } else if (!unique_id) {
164 // User selected an Autocomplete entry, so we fill directly. 169 // User selected an Autocomplete entry, so we fill directly.
165 RenderViewHost* host = 170 RenderViewHost* host =
166 tab_contents_wrapper_->web_contents()->GetRenderViewHost(); 171 tab_contents_wrapper_->web_contents()->GetRenderViewHost();
167 host->Send(new AutofillMsg_SetNodeText( 172 host->Send(new AutofillMsg_SetNodeText(
168 host->GetRoutingID(), 173 host->GetRoutingID(),
169 value)); 174 value));
170 } else { 175 } else {
171 FillAutofillFormData(unique_id, false); 176 FillAutofillFormData(unique_id, false);
172 } 177 }
173 178
174 HideAutofillPopup(); 179 HideAutofillPopup();
175 } 180 }
176 181
177 void AutofillExternalDelegate::ClearPreviewedForm() { 182 void AutofillExternalDelegate::ClearPreviewedForm() {
183 if (password_autofill_manager_.DidClearAutofillSelection(
184 autofill_query_field_))
185 return;
186
178 RenderViewHost* host = 187 RenderViewHost* host =
179 tab_contents_wrapper_->web_contents()->GetRenderViewHost(); 188 tab_contents_wrapper_->web_contents()->GetRenderViewHost();
180 host->Send(new AutofillMsg_ClearPreviewedForm(host->GetRoutingID())); 189 host->Send(new AutofillMsg_ClearPreviewedForm(host->GetRoutingID()));
181 } 190 }
182 191
183 void AutofillExternalDelegate::HideAutofillPopup() { 192 void AutofillExternalDelegate::HideAutofillPopup() {
184 suggestions_clear_index_ = -1; 193 suggestions_clear_index_ = -1;
185 suggestions_options_index_ = -1; 194 suggestions_options_index_ = -1;
186 195
187 HideAutofillPopupInternal(); 196 HideAutofillPopupInternal();
188 } 197 }
189 198
199 void AutofillExternalDelegate::FrameClosing(int frame_id) {
200 password_autofill_manager_.FrameClosing(frame_id);
201 }
202
203 void AutofillExternalDelegate::FillPasswordForm(
204 const webkit::forms::FormField& form,
205 const webkit::forms::PasswordFormFillData& fill_data,
206 int frame_id) {
207 password_autofill_manager_.FillPasswordForm(form, fill_data, frame_id);
208 }
209
190 void AutofillExternalDelegate::FillAutofillFormData(int unique_id, 210 void AutofillExternalDelegate::FillAutofillFormData(int unique_id,
191 bool is_preview) { 211 bool is_preview) {
192 RenderViewHost* host = 212 RenderViewHost* host =
193 tab_contents_wrapper_->web_contents()->GetRenderViewHost(); 213 tab_contents_wrapper_->web_contents()->GetRenderViewHost();
194 214
195 if (is_preview) { 215 if (is_preview) {
196 host->Send(new AutofillMsg_SetAutofillActionPreview( 216 host->Send(new AutofillMsg_SetAutofillActionPreview(
197 host->GetRoutingID())); 217 host->GetRoutingID()));
198 } else { 218 } else {
199 host->Send(new AutofillMsg_SetAutofillActionFill( 219 host->Send(new AutofillMsg_SetAutofillActionFill(
(...skipping 12 matching lines...) Expand all
212 // none, so all platforms use the default. 232 // none, so all platforms use the default.
213 233
214 #if !defined(OS_ANDROID) && !defined(TOOLKIT_GTK) 234 #if !defined(OS_ANDROID) && !defined(TOOLKIT_GTK)
215 235
216 AutofillExternalDelegate* AutofillExternalDelegate::Create( 236 AutofillExternalDelegate* AutofillExternalDelegate::Create(
217 TabContentsWrapper*, AutofillManager*) { 237 TabContentsWrapper*, AutofillManager*) {
218 return NULL; 238 return NULL;
219 } 239 }
220 240
221 #endif 241 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698