| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/address.h" | 5 #include "chrome/browser/autofill/address.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "chrome/browser/autofill/autofill_country.h" | 9 #include "chrome/browser/autofill/autofill_country.h" |
| 10 #include "chrome/browser/autofill/autofill_type.h" | 10 #include "chrome/browser/autofill/autofill_type.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 if (!state_.empty()) | 93 if (!state_.empty()) |
| 94 available_types->insert(ADDRESS_HOME_STATE); | 94 available_types->insert(ADDRESS_HOME_STATE); |
| 95 | 95 |
| 96 if (!zip_code_.empty()) | 96 if (!zip_code_.empty()) |
| 97 available_types->insert(ADDRESS_HOME_ZIP); | 97 available_types->insert(ADDRESS_HOME_ZIP); |
| 98 | 98 |
| 99 if (!country_code_.empty()) | 99 if (!country_code_.empty()) |
| 100 available_types->insert(ADDRESS_HOME_COUNTRY); | 100 available_types->insert(ADDRESS_HOME_COUNTRY); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void Address::FindInfoMatches(const AutofillType& type, | 103 void Address::FindInfoMatches(AutofillFieldType type, |
| 104 const string16& info, | 104 const string16& info, |
| 105 std::vector<string16>* matched_text) const { | 105 std::vector<string16>* matched_text) const { |
| 106 DCHECK(matched_text); | 106 DCHECK(matched_text); |
| 107 | 107 |
| 108 string16 match; | 108 string16 match; |
| 109 if (type.field_type() == UNKNOWN_TYPE) { | 109 if (type == UNKNOWN_TYPE) { |
| 110 for (int i = 0; i < kAutoFillAddressLength; ++i) { | 110 for (int i = 0; i < kAutoFillAddressLength; ++i) { |
| 111 if (FindInfoMatchesHelper(kAutoFillAddressTypes[i], info, &match)) | 111 if (FindInfoMatchesHelper(kAutoFillAddressTypes[i], info, &match)) |
| 112 matched_text->push_back(match); | 112 matched_text->push_back(match); |
| 113 } | 113 } |
| 114 } else { | 114 } else { |
| 115 if (FindInfoMatchesHelper(type.subgroup(), info, &match)) | 115 if (FindInfoMatchesHelper(AutofillType(type).subgroup(), info, &match)) |
| 116 matched_text->push_back(match); | 116 matched_text->push_back(match); |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 string16 Address::GetFieldText(const AutofillType& type) const { | 120 string16 Address::GetFieldText(AutofillFieldType type) const { |
| 121 AutofillFieldType field_type = type.field_type(); | 121 if (type == ADDRESS_HOME_LINE1) |
| 122 if (field_type == ADDRESS_HOME_LINE1) | |
| 123 return line1_; | 122 return line1_; |
| 124 | 123 |
| 125 if (field_type == ADDRESS_HOME_LINE2) | 124 if (type == ADDRESS_HOME_LINE2) |
| 126 return line2_; | 125 return line2_; |
| 127 | 126 |
| 128 if (field_type == ADDRESS_HOME_CITY) | 127 if (type == ADDRESS_HOME_CITY) |
| 129 return city_; | 128 return city_; |
| 130 | 129 |
| 131 if (field_type == ADDRESS_HOME_STATE) | 130 if (type == ADDRESS_HOME_STATE) |
| 132 return state_; | 131 return state_; |
| 133 | 132 |
| 134 if (field_type == ADDRESS_HOME_ZIP) | 133 if (type == ADDRESS_HOME_ZIP) |
| 135 return zip_code_; | 134 return zip_code_; |
| 136 | 135 |
| 137 if (field_type == ADDRESS_HOME_COUNTRY) | 136 if (type == ADDRESS_HOME_COUNTRY) |
| 138 return Country(); | 137 return Country(); |
| 139 | 138 |
| 140 return string16(); | 139 return string16(); |
| 141 } | 140 } |
| 142 | 141 |
| 143 void Address::SetInfo(const AutofillType& type, const string16& value) { | 142 void Address::SetInfo(AutofillFieldType type, const string16& value) { |
| 144 FieldTypeSubGroup subgroup = type.subgroup(); | 143 FieldTypeSubGroup subgroup = AutofillType(type).subgroup(); |
| 145 if (subgroup == AutofillType::ADDRESS_LINE1) | 144 if (subgroup == AutofillType::ADDRESS_LINE1) |
| 146 set_line1(value); | 145 set_line1(value); |
| 147 else if (subgroup == AutofillType::ADDRESS_LINE2) | 146 else if (subgroup == AutofillType::ADDRESS_LINE2) |
| 148 set_line2(value); | 147 set_line2(value); |
| 149 else if (subgroup == AutofillType::ADDRESS_CITY) | 148 else if (subgroup == AutofillType::ADDRESS_CITY) |
| 150 city_ = value; | 149 city_ = value; |
| 151 else if (subgroup == AutofillType::ADDRESS_STATE) | 150 else if (subgroup == AutofillType::ADDRESS_STATE) |
| 152 state_ = value; | 151 state_ = value; |
| 153 else if (subgroup == AutofillType::ADDRESS_COUNTRY) | 152 else if (subgroup == AutofillType::ADDRESS_COUNTRY) |
| 154 SetCountry(value); | 153 SetCountry(value); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 bool Address::IsWordInLine(const string16& word, | 283 bool Address::IsWordInLine(const string16& word, |
| 285 const LineTokens& line_tokens) const { | 284 const LineTokens& line_tokens) const { |
| 286 LineTokens::const_iterator iter; | 285 LineTokens::const_iterator iter; |
| 287 for (iter = line_tokens.begin(); iter != line_tokens.end(); ++iter) { | 286 for (iter = line_tokens.begin(); iter != line_tokens.end(); ++iter) { |
| 288 if (StringToLowerASCII(word) == *iter) | 287 if (StringToLowerASCII(word) == *iter) |
| 289 return true; | 288 return true; |
| 290 } | 289 } |
| 291 | 290 |
| 292 return false; | 291 return false; |
| 293 } | 292 } |
| OLD | NEW |