Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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() && |
| 84 element.formControlType() == WebString::fromUTF8("email")) { | 84 element.isEmailField()) { |
|
Ilya Sherman
2014/07/09 23:17:51
nit: No need for this line to wrap anymore.
pals
2014/07/10 06:25:12
Done.
| |
| 85 std::vector<base::string16> parts; | 85 std::vector<base::string16> parts; |
| 86 base::SplitStringDontTrim(prefix, ',', &parts); | 86 base::SplitStringDontTrim(prefix, ',', &parts); |
| 87 if (parts.size() > 0) { | 87 if (parts.size() > 0) { |
| 88 base::TrimWhitespace(parts[parts.size() - 1], base::TRIM_LEADING, | 88 base::TrimWhitespace(parts[parts.size() - 1], base::TRIM_LEADING, |
| 89 &prefix); | 89 &prefix); |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 for (WebOptionElement option = options.firstItem().to<WebOptionElement>(); | 93 for (WebOptionElement option = options.firstItem().to<WebOptionElement>(); |
| 94 !option.isNull(); option = options.nextItem().to<WebOptionElement>()) { | 94 !option.isNull(); option = options.nextItem().to<WebOptionElement>()) { |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 408 } | 408 } |
| 409 | 409 |
| 410 void AutofillAgent::AcceptDataListSuggestion( | 410 void AutofillAgent::AcceptDataListSuggestion( |
| 411 const base::string16& suggested_value) { | 411 const base::string16& suggested_value) { |
| 412 WebInputElement* input_element = toWebInputElement(&element_); | 412 WebInputElement* input_element = toWebInputElement(&element_); |
| 413 DCHECK(input_element); | 413 DCHECK(input_element); |
| 414 base::string16 new_value = suggested_value; | 414 base::string16 new_value = suggested_value; |
| 415 // If this element takes multiple values then replace the last part with | 415 // If this element takes multiple values then replace the last part with |
| 416 // the suggestion. | 416 // the suggestion. |
| 417 if (input_element->isMultiple() && | 417 if (input_element->isMultiple() && |
| 418 input_element->formControlType() == WebString::fromUTF8("email")) { | 418 input_element->isEmailField()) { |
|
Ilya Sherman
2014/07/09 23:17:51
nit: No need for this line to wrap anymore.
pals
2014/07/10 06:25:12
Done.
| |
| 419 std::vector<base::string16> parts; | 419 std::vector<base::string16> parts; |
| 420 | 420 |
| 421 base::SplitStringDontTrim(input_element->editingValue(), ',', &parts); | 421 base::SplitStringDontTrim(input_element->editingValue(), ',', &parts); |
| 422 if (parts.size() == 0) | 422 if (parts.size() == 0) |
| 423 parts.push_back(base::string16()); | 423 parts.push_back(base::string16()); |
| 424 | 424 |
| 425 base::string16 last_part = parts.back(); | 425 base::string16 last_part = parts.back(); |
| 426 // We want to keep just the leading whitespace. | 426 // We want to keep just the leading whitespace. |
| 427 for (size_t i = 0; i < last_part.size(); ++i) { | 427 for (size_t i = 0; i < last_part.size(); ++i) { |
| 428 if (!IsWhitespace(last_part[i])) { | 428 if (!IsWhitespace(last_part[i])) { |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 721 // parsed form. | 721 // parsed form. |
| 722 if (frame && !frame->parent() && !frame->isLoading()) { | 722 if (frame && !frame->parent() && !frame->isLoading()) { |
| 723 ProcessForms(*frame); | 723 ProcessForms(*frame); |
| 724 password_autofill_agent_->OnDynamicFormsSeen(frame); | 724 password_autofill_agent_->OnDynamicFormsSeen(frame); |
| 725 return; | 725 return; |
| 726 } | 726 } |
| 727 } | 727 } |
| 728 } | 728 } |
| 729 | 729 |
| 730 } // namespace autofill | 730 } // namespace autofill |
| OLD | NEW |