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

Side by Side Diff: chrome/renderer/autofill/autofill_agent.cc

Issue 9600038: Add Password Autofill Manager to New Autofill (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixing final nits Created 8 years, 8 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 "chrome/renderer/autofill/autofill_agent.h" 5 #include "chrome/renderer/autofill/autofill_agent.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 IPC_MESSAGE_HANDLER(AutofillMsg_SetAutofillActionFill, 79 IPC_MESSAGE_HANDLER(AutofillMsg_SetAutofillActionFill,
80 OnSetAutofillActionFill) 80 OnSetAutofillActionFill)
81 IPC_MESSAGE_HANDLER(AutofillMsg_ClearForm, 81 IPC_MESSAGE_HANDLER(AutofillMsg_ClearForm,
82 OnClearForm) 82 OnClearForm)
83 IPC_MESSAGE_HANDLER(AutofillMsg_SetAutofillActionPreview, 83 IPC_MESSAGE_HANDLER(AutofillMsg_SetAutofillActionPreview,
84 OnSetAutofillActionPreview) 84 OnSetAutofillActionPreview)
85 IPC_MESSAGE_HANDLER(AutofillMsg_ClearPreviewedForm, 85 IPC_MESSAGE_HANDLER(AutofillMsg_ClearPreviewedForm,
86 OnClearPreviewedForm) 86 OnClearPreviewedForm)
87 IPC_MESSAGE_HANDLER(AutofillMsg_SetNodeText, 87 IPC_MESSAGE_HANDLER(AutofillMsg_SetNodeText,
88 OnSetNodeText) 88 OnSetNodeText)
89 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptPasswordAutofillSuggestion,
90 OnAcceptPasswordAutofillSuggestion)
89 IPC_MESSAGE_UNHANDLED(handled = false) 91 IPC_MESSAGE_UNHANDLED(handled = false)
90 IPC_END_MESSAGE_MAP() 92 IPC_END_MESSAGE_MAP()
91 return handled; 93 return handled;
92 } 94 }
93 95
94 void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) { 96 void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) {
95 // The document has now been fully loaded. Scan for forms to be sent up to 97 // The document has now been fully loaded. Scan for forms to be sent up to
96 // the browser. 98 // the browser.
97 std::vector<webkit::forms::FormData> forms; 99 std::vector<webkit::forms::FormData> forms;
98 form_cache_.ExtractForms(*frame, &forms); 100 form_cache_.ExtractForms(*frame, &forms);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and 225 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and
224 // it is needed to trigger autofill. 226 // it is needed to trigger autofill.
225 weak_ptr_factory_.InvalidateWeakPtrs(); 227 weak_ptr_factory_.InvalidateWeakPtrs();
226 MessageLoop::current()->PostTask( 228 MessageLoop::current()->PostTask(
227 FROM_HERE, 229 FROM_HERE,
228 base::Bind(&AutofillAgent::TextFieldDidChangeImpl, 230 base::Bind(&AutofillAgent::TextFieldDidChangeImpl,
229 weak_ptr_factory_.GetWeakPtr(), element)); 231 weak_ptr_factory_.GetWeakPtr(), element));
230 } 232 }
231 233
232 void AutofillAgent::TextFieldDidChangeImpl(const WebInputElement& element) { 234 void AutofillAgent::TextFieldDidChangeImpl(const WebInputElement& element) {
233 if (password_autofill_manager_->TextDidChangeInTextField(element)) 235 if (password_autofill_manager_->TextDidChangeInTextField(element)) {
236 autofill_query_element_ = element;
234 return; 237 return;
238 }
235 239
236 ShowSuggestions(element, false, true, false); 240 ShowSuggestions(element, false, true, false);
237 241
238 webkit::forms::FormData form; 242 webkit::forms::FormData form;
239 webkit::forms::FormField field; 243 webkit::forms::FormField field;
240 if (FindFormAndFieldForInputElement(element, &form, &field, REQUIRE_NONE)) { 244 if (FindFormAndFieldForInputElement(element, &form, &field, REQUIRE_NONE)) {
241 Send(new AutofillHostMsg_TextFieldDidChange(routing_id(), form, field, 245 Send(new AutofillHostMsg_TextFieldDidChange(routing_id(), form, field,
242 base::TimeTicks::Now())); 246 base::TimeTicks::Now()));
243 } 247 }
244 } 248 }
245 249
246 void AutofillAgent::textFieldDidReceiveKeyDown(const WebInputElement& element, 250 void AutofillAgent::textFieldDidReceiveKeyDown(const WebInputElement& element,
247 const WebKeyboardEvent& event) { 251 const WebKeyboardEvent& event) {
248 if (password_autofill_manager_->TextFieldHandlingKeyDown(element, event)) 252 if (password_autofill_manager_->TextFieldHandlingKeyDown(element, event)) {
253 autofill_query_element_ = element;
249 return; 254 return;
255 }
250 256
251 if (event.windowsKeyCode == ui::VKEY_DOWN || 257 if (event.windowsKeyCode == ui::VKEY_DOWN ||
252 event.windowsKeyCode == ui::VKEY_UP) 258 event.windowsKeyCode == ui::VKEY_UP)
253 ShowSuggestions(element, true, true, true); 259 ShowSuggestions(element, true, true, true);
254 } 260 }
255 261
256 void AutofillAgent::OnSuggestionsReturned(int query_id, 262 void AutofillAgent::OnSuggestionsReturned(int query_id,
257 const std::vector<string16>& values, 263 const std::vector<string16>& values,
258 const std::vector<string16>& labels, 264 const std::vector<string16>& labels,
259 const std::vector<string16>& icons, 265 const std::vector<string16>& icons,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 } 397 }
392 398
393 void AutofillAgent::OnClearPreviewedForm() { 399 void AutofillAgent::OnClearPreviewedForm() {
394 didClearAutofillSelection(autofill_query_element_); 400 didClearAutofillSelection(autofill_query_element_);
395 } 401 }
396 402
397 void AutofillAgent::OnSetNodeText(const string16& value) { 403 void AutofillAgent::OnSetNodeText(const string16& value) {
398 SetNodeText(value, &autofill_query_element_); 404 SetNodeText(value, &autofill_query_element_);
399 } 405 }
400 406
407 void AutofillAgent::OnAcceptPasswordAutofillSuggestion(const string16& value) {
408 // We need to make sure this is handled here because the browser process
409 // skipped it handling because it believed it would be handled here. If it
410 // isn't handled here then the browser logic needs to be updated.
411 bool handled = password_autofill_manager_->DidAcceptAutofillSuggestion(
412 autofill_query_element_,
413 value);
414 DCHECK(handled);
415 }
416
401 void AutofillAgent::ShowSuggestions(const WebInputElement& element, 417 void AutofillAgent::ShowSuggestions(const WebInputElement& element,
402 bool autofill_on_empty_values, 418 bool autofill_on_empty_values,
403 bool requires_caret_at_end, 419 bool requires_caret_at_end,
404 bool display_warning_if_disabled) { 420 bool display_warning_if_disabled) {
405 // If autocomplete is disabled at the form level, then we might want to show 421 // If autocomplete is disabled at the form level, then we might want to show
406 // a warning in place of suggestions. However, if autocomplete is disabled 422 // a warning in place of suggestions. However, if autocomplete is disabled
407 // specifically for this field, we never want to show a warning. Otherwise, 423 // specifically for this field, we never want to show a warning. Otherwise,
408 // we might interfere with custom popups (e.g. search suggestions) used by 424 // we might interfere with custom popups (e.g. search suggestions) used by
409 // the website. 425 // the website.
410 const WebFormElement form = element.form(); 426 const WebFormElement form = element.form();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 499
484 void AutofillAgent::SetNodeText(const string16& value, 500 void AutofillAgent::SetNodeText(const string16& value,
485 WebKit::WebInputElement* node) { 501 WebKit::WebInputElement* node) {
486 string16 substring = value; 502 string16 substring = value;
487 substring = substring.substr(0, node->maxLength()); 503 substring = substring.substr(0, node->maxLength());
488 504
489 node->setValue(substring, true); 505 node->setValue(substring, true);
490 } 506 }
491 507
492 } // namespace autofill 508 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/renderer/autofill/autofill_agent.h ('k') | chrome/renderer/autofill/password_autofill_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698