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

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

Issue 10391002: Hide invalid datalist suggestions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
« 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 (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
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
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
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