| OLD | NEW |
| 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> |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 re2::RE2::Options options; | 98 re2::RE2::Options options; |
| 99 options.set_case_sensitive(false); | 99 options.set_case_sensitive(false); |
| 100 // Use placement new to initialize the instance in the preallocated space. | 100 // Use placement new to initialize the instance in the preallocated space. |
| 101 // The "(instance)" is very important to force POD type initialization. | 101 // The "(instance)" is very important to force POD type initialization. |
| 102 re2::RE2* matcher = new (instance) re2::RE2(pattern, options); | 102 re2::RE2* matcher = new (instance) re2::RE2(pattern, options); |
| 103 DCHECK(matcher->ok()); | 103 DCHECK(matcher->ok()); |
| 104 return matcher; | 104 return matcher; |
| 105 } | 105 } |
| 106 | 106 |
| 107 struct LoginAndSignupLazyInstanceTraits | 107 struct LoginAndSignupLazyInstanceTraits |
| 108 : public base::DefaultLazyInstanceTraits<re2::RE2> { | 108 : public base::internal::DestructorAtExitLazyInstanceTraits<re2::RE2> { |
| 109 static re2::RE2* New(void* instance) { | 109 static re2::RE2* New(void* instance) { |
| 110 return CreateMatcher(instance, kLoginAndSignupRegex); | 110 return CreateMatcher(instance, kLoginAndSignupRegex); |
| 111 } | 111 } |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 base::LazyInstance<re2::RE2, LoginAndSignupLazyInstanceTraits> | 114 base::LazyInstance<re2::RE2, LoginAndSignupLazyInstanceTraits> |
| 115 g_login_and_signup_matcher = LAZY_INSTANCE_INITIALIZER; | 115 g_login_and_signup_matcher = LAZY_INSTANCE_INITIALIZER; |
| 116 | 116 |
| 117 // Given the sequence of non-password and password text input fields of a form, | 117 // Given the sequence of non-password and password text input fields of a form, |
| 118 // represented as a string of Ns (non-password) and Ps (password), computes the | 118 // represented as a string of Ns (non-password) and Ps (password), computes the |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 } | 301 } |
| 302 } | 302 } |
| 303 } | 303 } |
| 304 | 304 |
| 305 // TODO(crbug.com/543085): Move the reauthentication recognition code to the | 305 // TODO(crbug.com/543085): Move the reauthentication recognition code to the |
| 306 // browser. | 306 // browser. |
| 307 const char kPasswordSiteUrlRegex[] = | 307 const char kPasswordSiteUrlRegex[] = |
| 308 "passwords(?:-[a-z-]+\\.corp)?\\.google\\.com"; | 308 "passwords(?:-[a-z-]+\\.corp)?\\.google\\.com"; |
| 309 | 309 |
| 310 struct PasswordSiteUrlLazyInstanceTraits | 310 struct PasswordSiteUrlLazyInstanceTraits |
| 311 : public base::DefaultLazyInstanceTraits<re2::RE2> { | 311 : public base::internal::DestructorAtExitLazyInstanceTraits<re2::RE2> { |
| 312 static re2::RE2* New(void* instance) { | 312 static re2::RE2* New(void* instance) { |
| 313 return CreateMatcher(instance, kPasswordSiteUrlRegex); | 313 return CreateMatcher(instance, kPasswordSiteUrlRegex); |
| 314 } | 314 } |
| 315 }; | 315 }; |
| 316 | 316 |
| 317 base::LazyInstance<re2::RE2, PasswordSiteUrlLazyInstanceTraits> | 317 base::LazyInstance<re2::RE2, PasswordSiteUrlLazyInstanceTraits> |
| 318 g_password_site_matcher = LAZY_INSTANCE_INITIALIZER; | 318 g_password_site_matcher = LAZY_INSTANCE_INITIALIZER; |
| 319 | 319 |
| 320 // Returns the |input_field| name if its non-empty; otherwise a |dummy_name|. | 320 // Returns the |input_field| name if its non-empty; otherwise a |dummy_name|. |
| 321 base::string16 FieldName(const WebInputElement& input_field, | 321 base::string16 FieldName(const WebInputElement& input_field, |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 const char* value_in_lowercase) { | 726 const char* value_in_lowercase) { |
| 727 base::string16 autocomplete_attribute( | 727 base::string16 autocomplete_attribute( |
| 728 element.getAttribute("autocomplete").utf16()); | 728 element.getAttribute("autocomplete").utf16()); |
| 729 std::vector<std::string> tokens = LowercaseAndTokenizeAttributeString( | 729 std::vector<std::string> tokens = LowercaseAndTokenizeAttributeString( |
| 730 base::UTF16ToUTF8(autocomplete_attribute)); | 730 base::UTF16ToUTF8(autocomplete_attribute)); |
| 731 | 731 |
| 732 return base::ContainsValue(tokens, value_in_lowercase); | 732 return base::ContainsValue(tokens, value_in_lowercase); |
| 733 } | 733 } |
| 734 | 734 |
| 735 } // namespace autofill | 735 } // namespace autofill |
| OLD | NEW |