OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/autofill/autofill_field.h" | 5 #include "chrome/browser/autofill/autofill_field.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/sha1.h" | 8 #include "base/sha1.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 const string16& unique_name) | 34 const string16& unique_name) |
35 : webkit_glue::FormField(field), | 35 : webkit_glue::FormField(field), |
36 unique_name_(unique_name), | 36 unique_name_(unique_name), |
37 server_type_(NO_SERVER_DATA), | 37 server_type_(NO_SERVER_DATA), |
38 heuristic_type_(UNKNOWN_TYPE) { | 38 heuristic_type_(UNKNOWN_TYPE) { |
39 } | 39 } |
40 | 40 |
41 AutoFillField::~AutoFillField() {} | 41 AutoFillField::~AutoFillField() {} |
42 | 42 |
43 void AutoFillField::set_heuristic_type(const AutoFillFieldType& type) { | 43 void AutoFillField::set_heuristic_type(const AutoFillFieldType& type) { |
44 DCHECK(type >= 0 && type < MAX_VALID_FIELD_TYPE); | 44 if (type >= 0 && type < MAX_VALID_FIELD_TYPE) { |
45 if (type >= 0 && type < MAX_VALID_FIELD_TYPE) | |
46 heuristic_type_ = type; | 45 heuristic_type_ = type; |
47 else | 46 } else { |
| 47 NOTREACHED(); |
| 48 // This case should not be reachable; but since this has potential |
| 49 // implications on data uploaded to the server, better safe than sorry. |
48 heuristic_type_ = UNKNOWN_TYPE; | 50 heuristic_type_ = UNKNOWN_TYPE; |
| 51 } |
49 } | 52 } |
50 | 53 |
51 AutoFillFieldType AutoFillField::type() const { | 54 AutoFillFieldType AutoFillField::type() const { |
52 if (server_type_ != NO_SERVER_DATA) | 55 if (server_type_ != NO_SERVER_DATA) |
53 return server_type_; | 56 return server_type_; |
54 | 57 |
55 return heuristic_type_; | 58 return heuristic_type_; |
56 } | 59 } |
57 | 60 |
58 bool AutoFillField::IsEmpty() const { | 61 bool AutoFillField::IsEmpty() const { |
59 return value().empty(); | 62 return value().empty(); |
60 } | 63 } |
61 | 64 |
62 std::string AutoFillField::FieldSignature() const { | 65 std::string AutoFillField::FieldSignature() const { |
63 std::string field_name = UTF16ToUTF8(name()); | 66 std::string field_name = UTF16ToUTF8(name()); |
64 std::string type = UTF16ToUTF8(form_control_type()); | 67 std::string type = UTF16ToUTF8(form_control_type()); |
65 std::string field_string = field_name + "&" + type; | 68 std::string field_string = field_name + "&" + type; |
66 return Hash32Bit(field_string); | 69 return Hash32Bit(field_string); |
67 } | 70 } |
68 | 71 |
69 bool AutoFillField::IsFieldFillable() const { | 72 bool AutoFillField::IsFieldFillable() const { |
70 return type() != UNKNOWN_TYPE; | 73 return type() != UNKNOWN_TYPE; |
71 } | 74 } |
OLD | NEW |