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

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

Issue 1220653002: Fix some case-insensitive cases for StartsWith (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac fix Created 5 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
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/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/i18n/case_conversion.h"
10 #include "base/location.h" 11 #include "base/location.h"
11 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
12 #include "base/strings/string_split.h" 13 #include "base/strings/string_split.h"
13 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
15 #include "base/thread_task_runner_handle.h" 16 #include "base/thread_task_runner_handle.h"
16 #include "base/time/time.h" 17 #include "base/time/time.h"
17 #include "components/autofill/content/common/autofill_messages.h" 18 #include "components/autofill/content/common/autofill_messages.h"
18 #include "components/autofill/content/renderer/form_autofill_util.h" 19 #include "components/autofill/content/renderer/form_autofill_util.h"
19 #include "components/autofill/content/renderer/page_click_tracker.h" 20 #include "components/autofill/content/renderer/page_click_tracker.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 std::vector<base::string16>* values, 81 std::vector<base::string16>* values,
81 std::vector<base::string16>* labels) { 82 std::vector<base::string16>* labels) {
82 WebElementCollection options = element.dataListOptions(); 83 WebElementCollection options = element.dataListOptions();
83 if (options.isNull()) 84 if (options.isNull())
84 return; 85 return;
85 86
86 base::string16 prefix; 87 base::string16 prefix;
87 if (!ignore_current_value) { 88 if (!ignore_current_value) {
88 prefix = element.editingValue(); 89 prefix = element.editingValue();
89 if (element.isMultiple() && element.isEmailField()) { 90 if (element.isMultiple() && element.isEmailField()) {
90 std::vector<base::string16> parts; 91 const base::char16 comma[2] = { ',', 0 };
91 base::SplitStringDontTrim(prefix, ',', &parts); 92 std::vector<base::string16> parts = base::SplitString(
93 prefix, comma, base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
92 if (parts.size() > 0) { 94 if (parts.size() > 0) {
93 base::TrimWhitespace(parts[parts.size() - 1], base::TRIM_LEADING, 95 base::TrimWhitespace(parts[parts.size() - 1], base::TRIM_LEADING,
94 &prefix); 96 &prefix);
95 } 97 }
96 } 98 }
97 } 99 }
100 prefix = base::i18n::ToLower(prefix);
98 for (WebOptionElement option = options.firstItem().to<WebOptionElement>(); 101 for (WebOptionElement option = options.firstItem().to<WebOptionElement>();
99 !option.isNull(); option = options.nextItem().to<WebOptionElement>()) { 102 !option.isNull(); option = options.nextItem().to<WebOptionElement>()) {
100 if (!base::StartsWith(option.value(), prefix, false) || 103 if (!base::StartsWith(base::i18n::ToLower(base::string16(option.value())),
101 option.value() == prefix || !element.isValidValue(option.value())) 104 prefix, base::CompareCase::SENSITIVE) ||
105 !element.isValidValue(option.value()))
102 continue; 106 continue;
103 107
104 values->push_back(option.value()); 108 values->push_back(option.value());
105 if (option.value() != option.label()) 109 if (option.value() != option.label())
106 labels->push_back(option.label()); 110 labels->push_back(option.label());
107 else 111 else
108 labels->push_back(base::string16()); 112 labels->push_back(base::string16());
109 } 113 }
110 } 114 }
111 115
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 809
806 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { 810 void AutofillAgent::LegacyAutofillAgent::OnDestruct() {
807 // No-op. Don't delete |this|. 811 // No-op. Don't delete |this|.
808 } 812 }
809 813
810 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { 814 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() {
811 agent_->FocusChangeComplete(); 815 agent_->FocusChangeComplete();
812 } 816 }
813 817
814 } // namespace autofill 818 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698