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 #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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 std::vector<string16>* values, | 54 std::vector<string16>* values, |
55 std::vector<string16>* labels, | 55 std::vector<string16>* labels, |
56 std::vector<string16>* icons, | 56 std::vector<string16>* icons, |
57 std::vector<int>* item_ids) { | 57 std::vector<int>* item_ids) { |
58 WebNodeCollection options = element.dataListOptions(); | 58 WebNodeCollection options = element.dataListOptions(); |
59 if (options.isNull()) | 59 if (options.isNull()) |
60 return; | 60 return; |
61 | 61 |
62 for (WebOptionElement option = options.firstItem().to<WebOptionElement>(); | 62 for (WebOptionElement option = options.firstItem().to<WebOptionElement>(); |
63 !option.isNull(); option = options.nextItem().to<WebOptionElement>()) { | 63 !option.isNull(); option = options.nextItem().to<WebOptionElement>()) { |
64 if (!StartsWith(option.value(), element.value(), false)) | 64 if (!StartsWith(option.value(), element.value(), false) || |
| 65 !element.isValidValue(option.value())) |
65 continue; | 66 continue; |
66 | 67 |
67 values->push_back(option.value()); | 68 values->push_back(option.value()); |
68 if (option.value() != option.label()) | 69 if (option.value() != option.label()) |
69 labels->push_back(option.label()); | 70 labels->push_back(option.label()); |
70 else | 71 else |
71 labels->push_back(string16()); | 72 labels->push_back(string16()); |
72 icons->push_back(string16()); | 73 icons->push_back(string16()); |
73 item_ids->push_back(WebAutofillClient::MenuItemIDDataListEntry); | 74 item_ids->push_back(WebAutofillClient::MenuItemIDDataListEntry); |
74 } | 75 } |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 | 584 |
584 void AutofillAgent::SetNodeText(const string16& value, | 585 void AutofillAgent::SetNodeText(const string16& value, |
585 WebKit::WebInputElement* node) { | 586 WebKit::WebInputElement* node) { |
586 string16 substring = value; | 587 string16 substring = value; |
587 substring = substring.substr(0, node->maxLength()); | 588 substring = substring.substr(0, node->maxLength()); |
588 | 589 |
589 node->setValue(substring, true); | 590 node->setValue(substring, true); |
590 } | 591 } |
591 | 592 |
592 } // namespace autofill | 593 } // namespace autofill |
OLD | NEW |