OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_ie_toolbar_import_win.h" | 5 #include "chrome/browser/autofill/autofill_ie_toolbar_import_win.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 continue; | 141 continue; |
142 RegToFieldMap::const_iterator it = reg_to_field.find(value_name); | 142 RegToFieldMap::const_iterator it = reg_to_field.find(value_name); |
143 if (it == reg_to_field.end()) | 143 if (it == reg_to_field.end()) |
144 continue; // This field is not imported. | 144 continue; // This field is not imported. |
145 string16 field_value = ReadAndDecryptValue(key, value_name.c_str()); | 145 string16 field_value = ReadAndDecryptValue(key, value_name.c_str()); |
146 if (!field_value.empty()) { | 146 if (!field_value.empty()) { |
147 has_non_empty_fields = true; | 147 has_non_empty_fields = true; |
148 if (it->second == CREDIT_CARD_NUMBER) | 148 if (it->second == CREDIT_CARD_NUMBER) |
149 field_value = DecryptCCNumber(field_value); | 149 field_value = DecryptCCNumber(field_value); |
150 | 150 |
151 // TODO(isherman): Call SetCanonicalizedInfo below, rather than SetRawInfo | |
Dan Beam
2012/11/09 18:46:30
nit: .
Ilya Sherman
2012/11/10 03:21:33
Done.
| |
151 // We need to store phone data in |phone| before building the whole number | 152 // We need to store phone data in |phone| before building the whole number |
152 // at the end. The rest of the fields are set "as is". | 153 // at the end. The rest of the fields are set "as is". |
153 if (!phone.SetInfo(it->second, field_value)) | 154 if (!phone.SetInfo(it->second, field_value)) |
154 profile->SetInfo(it->second, field_value); | 155 profile->SetRawInfo(it->second, field_value); |
155 } | 156 } |
156 } | 157 } |
157 // Now re-construct the phones if needed. | 158 // Now re-construct the phones if needed. |
158 string16 constructed_number; | 159 string16 constructed_number; |
159 if (!phone.IsEmpty() && | 160 if (!phone.IsEmpty() && |
160 phone.ParseNumber(std::string("US"), &constructed_number)) { | 161 phone.ParseNumber(std::string("US"), &constructed_number)) { |
161 profile->SetCanonicalizedInfo(PHONE_HOME_WHOLE_NUMBER, constructed_number); | 162 profile->SetCanonicalizedInfo(PHONE_HOME_WHOLE_NUMBER, constructed_number); |
162 } | 163 } |
163 | 164 |
164 return has_non_empty_fields; | 165 return has_non_empty_fields; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
248 if (password_hash.empty() && IsEmptySalt(salt)) { | 249 if (password_hash.empty() && IsEmptySalt(salt)) { |
249 base::win::RegistryKeyIterator iterator_cc(HKEY_CURRENT_USER, | 250 base::win::RegistryKeyIterator iterator_cc(HKEY_CURRENT_USER, |
250 kCreditCardKey); | 251 kCreditCardKey); |
251 for (; iterator_cc.Valid(); ++iterator_cc) { | 252 for (; iterator_cc.Valid(); ++iterator_cc) { |
252 std::wstring key_name(kCreditCardKey); | 253 std::wstring key_name(kCreditCardKey); |
253 key_name.append(L"\\"); | 254 key_name.append(L"\\"); |
254 key_name.append(iterator_cc.Name()); | 255 key_name.append(iterator_cc.Name()); |
255 RegKey key(HKEY_CURRENT_USER, key_name.c_str(), KEY_READ); | 256 RegKey key(HKEY_CURRENT_USER, key_name.c_str(), KEY_READ); |
256 CreditCard credit_card; | 257 CreditCard credit_card; |
257 if (ImportSingleProfile(&credit_card, &key, reg_to_field)) { | 258 if (ImportSingleProfile(&credit_card, &key, reg_to_field)) { |
258 string16 cc_number = credit_card.GetInfo(CREDIT_CARD_NUMBER); | 259 // TODO(isherman): Call into GetCanonicalizedInfo() below, rather than |
260 // GetRawInfo(). | |
261 string16 cc_number = credit_card.GetRawInfo(CREDIT_CARD_NUMBER); | |
259 if (!cc_number.empty()) | 262 if (!cc_number.empty()) |
260 credit_cards->push_back(credit_card); | 263 credit_cards->push_back(credit_card); |
261 } | 264 } |
262 } | 265 } |
263 } | 266 } |
264 return (profiles->size() + credit_cards->size()) > 0; | 267 return (profiles->size() + credit_cards->size()) > 0; |
265 } | 268 } |
266 | 269 |
267 bool ImportAutofillDataWin(PersonalDataManager* pdm) { | 270 bool ImportAutofillDataWin(PersonalDataManager* pdm) { |
268 // In incognito mode we do not have PDM - and we should not import anything. | 271 // In incognito mode we do not have PDM - and we should not import anything. |
269 if (!pdm) | 272 if (!pdm) |
270 return false; | 273 return false; |
271 AutofillImporter *importer = new AutofillImporter(pdm); | 274 AutofillImporter *importer = new AutofillImporter(pdm); |
272 // importer will self delete. | 275 // importer will self delete. |
273 return importer->ImportProfiles(); | 276 return importer->ImportProfiles(); |
274 } | 277 } |
275 | |
OLD | NEW |