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

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

Issue 1220653002: Fix some case-insensitive cases for StartsWith (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: grt's review comments, 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/password_form_conversion_utils.h" 5 #include "components/autofill/content/renderer/password_form_conversion_utils.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/i18n/case_conversion.h"
9 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
12 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
13 #include "components/autofill/content/renderer/form_autofill_util.h" 14 #include "components/autofill/content/renderer/form_autofill_util.h"
14 #include "components/autofill/core/common/password_form.h" 15 #include "components/autofill/core/common/password_form.h"
15 #include "components/autofill/core/common/password_form_field_prediction_map.h" 16 #include "components/autofill/core/common/password_form_field_prediction_map.h"
16 #include "third_party/WebKit/public/platform/WebString.h" 17 #include "third_party/WebKit/public/platform/WebString.h"
17 #include "third_party/WebKit/public/web/WebDocument.h" 18 #include "third_party/WebKit/public/web/WebDocument.h"
18 #include "third_party/WebKit/public/web/WebFormControlElement.h" 19 #include "third_party/WebKit/public/web/WebFormControlElement.h"
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 } 374 }
374 375
375 if (!username_element.isNull()) { 376 if (!username_element.isNull()) {
376 password_form->username_element = username_element.nameForAutofill(); 377 password_form->username_element = username_element.nameForAutofill();
377 base::string16 username_value = username_element.value(); 378 base::string16 username_value = username_element.value();
378 if (nonscript_modified_values != nullptr) { 379 if (nonscript_modified_values != nullptr) {
379 auto username_iterator = 380 auto username_iterator =
380 nonscript_modified_values->find(username_element); 381 nonscript_modified_values->find(username_element);
381 if (username_iterator != nonscript_modified_values->end()) { 382 if (username_iterator != nonscript_modified_values->end()) {
382 base::string16 typed_username_value = username_iterator->second; 383 base::string16 typed_username_value = username_iterator->second;
383 if (!base::StartsWith(username_value, typed_username_value, false)) { 384 if (!base::StartsWith(
385 base::i18n::ToLower(username_value),
386 base::i18n::ToLower(typed_username_value),
387 base::CompareCase::SENSITIVE)) {
384 // We check that |username_value| was not obtained by autofilling 388 // We check that |username_value| was not obtained by autofilling
385 // |typed_username_value|. In case when it was, |typed_username_value| 389 // |typed_username_value|. In case when it was, |typed_username_value|
386 // is incomplete, so we should leave autofilled value. 390 // is incomplete, so we should leave autofilled value.
387 username_value = typed_username_value; 391 username_value = typed_username_value;
388 } 392 }
389 } 393 }
390 } 394 }
391 password_form->username_value = username_value; 395 password_form->username_value = username_value;
392 } 396 }
393 397
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 WebFormElementToFormData(web_form, 493 WebFormElementToFormData(web_form,
490 blink::WebFormControlElement(), 494 blink::WebFormControlElement(),
491 EXTRACT_NONE, 495 EXTRACT_NONE,
492 &password_form->form_data, 496 &password_form->form_data,
493 NULL /* FormFieldData */); 497 NULL /* FormFieldData */);
494 498
495 return password_form.Pass(); 499 return password_form.Pass();
496 } 500 }
497 501
498 } // namespace autofill 502 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698