OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/autofill/autofill_field.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "base/sha1.h" |
| 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" |
| 11 |
| 12 namespace { |
| 13 |
| 14 static std::string Hash32Bit(const std::string& str) { |
| 15 std::string hash_bin = base::SHA1HashString(str); |
| 16 DCHECK(hash_bin.length() == 20); |
| 17 |
| 18 uint32 hash32 = ((hash_bin[0] & 0xFF) << 24) | |
| 19 ((hash_bin[1] & 0xFF) << 16) | |
| 20 ((hash_bin[2] & 0xFF) << 8) | |
| 21 (hash_bin[3] & 0xFF); |
| 22 |
| 23 return UintToString(hash32); |
| 24 } |
| 25 |
| 26 } // namespace |
| 27 |
| 28 AutoFillField::AutoFillField(const webkit_glue::FormField& field) |
| 29 : webkit_glue::FormField(field) { |
| 30 } |
| 31 |
| 32 std::string AutoFillField::FieldSignature() const { |
| 33 std::string field_name = UTF16ToUTF8(name()); |
| 34 std::string type = UTF16ToUTF8(html_input_type()); |
| 35 std::string field_string = field_name + "&" + type; |
| 36 return Hash32Bit(field_string); |
| 37 } |
OLD | NEW |