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

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

Issue 2411333004: Make HasAutocompleteAttributeValue handle multi-valued strings (Closed)
Patch Set: Created 4 years, 2 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
11 11
12 #include "base/i18n/case_conversion.h" 12 #include "base/i18n/case_conversion.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/metrics/histogram_macros.h" 15 #include "base/metrics/histogram_macros.h"
16 #include "base/stl_util.h"
16 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
17 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
18 #include "components/autofill/content/renderer/form_autofill_util.h" 19 #include "components/autofill/content/renderer/form_autofill_util.h"
20 #include "components/autofill/core/common/autofill_util.h"
19 #include "components/autofill/core/common/password_form.h" 21 #include "components/autofill/core/common/password_form.h"
20 #include "components/autofill/core/common/password_form_field_prediction_map.h" 22 #include "components/autofill/core/common/password_form_field_prediction_map.h"
21 #include "google_apis/gaia/gaia_urls.h" 23 #include "google_apis/gaia/gaia_urls.h"
22 #include "third_party/WebKit/public/platform/WebString.h" 24 #include "third_party/WebKit/public/platform/WebString.h"
23 #include "third_party/WebKit/public/platform/WebVector.h" 25 #include "third_party/WebKit/public/platform/WebVector.h"
24 #include "third_party/WebKit/public/web/WebDocument.h" 26 #include "third_party/WebKit/public/web/WebDocument.h"
25 #include "third_party/WebKit/public/web/WebFormControlElement.h" 27 #include "third_party/WebKit/public/web/WebFormControlElement.h"
26 #include "third_party/WebKit/public/web/WebFrame.h" 28 #include "third_party/WebKit/public/web/WebFrame.h"
27 #include "third_party/WebKit/public/web/WebInputElement.h" 29 #include "third_party/WebKit/public/web/WebInputElement.h"
28 #include "third_party/re2/src/re2/re2.h" 30 #include "third_party/re2/src/re2/re2.h"
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 return std::unique_ptr<PasswordForm>(); 697 return std::unique_ptr<PasswordForm>();
696 698
697 // No actual action on the form, so use the the origin as the action. 699 // No actual action on the form, so use the the origin as the action.
698 password_form->action = password_form->origin; 700 password_form->action = password_form->origin;
699 701
700 return password_form; 702 return password_form;
701 } 703 }
702 704
703 bool HasAutocompleteAttributeValue(const blink::WebInputElement& element, 705 bool HasAutocompleteAttributeValue(const blink::WebInputElement& element,
704 const char* value_in_lowercase) { 706 const char* value_in_lowercase) {
705 return base::LowerCaseEqualsASCII( 707 base::string16 autocomplete_attribute(element.getAttribute("autocomplete"));
vabr (Chromium) 2016/10/13 12:49:31 Please #include "base/strings/string16.h"
jdoerrie 2016/10/13 13:45:07 Done.
706 base::StringPiece16(element.getAttribute("autocomplete")), 708 // Lowercase and tokenize attribute string. Convert to UTF8 beforehand.
vabr (Chromium) 2016/10/13 12:49:31 Your comments here and on line 712 are correct and
jdoerrie 2016/10/13 13:45:07 Done.
707 value_in_lowercase); 709 std::vector<std::string> tokens = LowercaseAndTokenizeAttributeString(
710 base::UTF16ToUTF8(autocomplete_attribute));
711
712 // Return if any of the obtained attribute tokens equals the value.
vabr (Chromium) 2016/10/13 12:49:31 optional nit: if -> whether
jdoerrie 2016/10/13 13:45:07 Acknowledged.
713 return base::ContainsValue(tokens, value_in_lowercase);
708 } 714 }
709 715
710 } // namespace autofill 716 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | components/autofill/core/browser/form_structure.cc » ('j') | components/autofill/core/browser/form_structure.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698