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

Side by Side Diff: components/autofill/content/renderer/autofill_agent.cc

Issue 376133004: [Refactor] Use isEmailField() for input element. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits fixed Created 6 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/autofill/content/renderer/autofill_agent.h" 5 #include "components/autofill/content/renderer/autofill_agent.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 bool ignore_current_value, 73 bool ignore_current_value,
74 std::vector<base::string16>* values, 74 std::vector<base::string16>* values,
75 std::vector<base::string16>* labels) { 75 std::vector<base::string16>* labels) {
76 WebElementCollection options = element.dataListOptions(); 76 WebElementCollection options = element.dataListOptions();
77 if (options.isNull()) 77 if (options.isNull())
78 return; 78 return;
79 79
80 base::string16 prefix; 80 base::string16 prefix;
81 if (!ignore_current_value) { 81 if (!ignore_current_value) {
82 prefix = element.editingValue(); 82 prefix = element.editingValue();
83 if (element.isMultiple() && 83 if (element.isMultiple() && element.isEmailField()) {
84 element.formControlType() == WebString::fromUTF8("email")) {
85 std::vector<base::string16> parts; 84 std::vector<base::string16> parts;
86 base::SplitStringDontTrim(prefix, ',', &parts); 85 base::SplitStringDontTrim(prefix, ',', &parts);
87 if (parts.size() > 0) { 86 if (parts.size() > 0) {
88 base::TrimWhitespace(parts[parts.size() - 1], base::TRIM_LEADING, 87 base::TrimWhitespace(parts[parts.size() - 1], base::TRIM_LEADING,
89 &prefix); 88 &prefix);
90 } 89 }
91 } 90 }
92 } 91 }
93 for (WebOptionElement option = options.firstItem().to<WebOptionElement>(); 92 for (WebOptionElement option = options.firstItem().to<WebOptionElement>();
94 !option.isNull(); option = options.nextItem().to<WebOptionElement>()) { 93 !option.isNull(); option = options.nextItem().to<WebOptionElement>()) {
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 password_autofill_agent_->FirstUserGestureObserved(); 406 password_autofill_agent_->FirstUserGestureObserved();
408 } 407 }
409 408
410 void AutofillAgent::AcceptDataListSuggestion( 409 void AutofillAgent::AcceptDataListSuggestion(
411 const base::string16& suggested_value) { 410 const base::string16& suggested_value) {
412 WebInputElement* input_element = toWebInputElement(&element_); 411 WebInputElement* input_element = toWebInputElement(&element_);
413 DCHECK(input_element); 412 DCHECK(input_element);
414 base::string16 new_value = suggested_value; 413 base::string16 new_value = suggested_value;
415 // If this element takes multiple values then replace the last part with 414 // If this element takes multiple values then replace the last part with
416 // the suggestion. 415 // the suggestion.
417 if (input_element->isMultiple() && 416 if (input_element->isMultiple() && input_element->isEmailField()) {
418 input_element->formControlType() == WebString::fromUTF8("email")) {
419 std::vector<base::string16> parts; 417 std::vector<base::string16> parts;
420 418
421 base::SplitStringDontTrim(input_element->editingValue(), ',', &parts); 419 base::SplitStringDontTrim(input_element->editingValue(), ',', &parts);
422 if (parts.size() == 0) 420 if (parts.size() == 0)
423 parts.push_back(base::string16()); 421 parts.push_back(base::string16());
424 422
425 base::string16 last_part = parts.back(); 423 base::string16 last_part = parts.back();
426 // We want to keep just the leading whitespace. 424 // We want to keep just the leading whitespace.
427 for (size_t i = 0; i < last_part.size(); ++i) { 425 for (size_t i = 0; i < last_part.size(); ++i) {
428 if (!IsWhitespace(last_part[i])) { 426 if (!IsWhitespace(last_part[i])) {
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 // parsed form. 719 // parsed form.
722 if (frame && !frame->parent() && !frame->isLoading()) { 720 if (frame && !frame->parent() && !frame->isLoading()) {
723 ProcessForms(*frame); 721 ProcessForms(*frame);
724 password_autofill_agent_->OnDynamicFormsSeen(frame); 722 password_autofill_agent_->OnDynamicFormsSeen(frame);
725 return; 723 return;
726 } 724 }
727 } 725 }
728 } 726 }
729 727
730 } // namespace autofill 728 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698