| 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/autofill_ie_toolbar_import_win.h" | 5 #include "chrome/browser/autofill/autofill_ie_toolbar_import_win.h" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <map> |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 7 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/logging.h" |
| 8 #include "base/string16.h" | 14 #include "base/string16.h" |
| 9 #include "base/win/registry.h" | 15 #include "base/win/registry.h" |
| 10 #include "chrome/browser/autofill/autofill_profile.h" | 16 #include "chrome/browser/autofill/autofill_profile.h" |
| 11 #include "chrome/browser/autofill/credit_card.h" | 17 #include "chrome/browser/autofill/credit_card.h" |
| 12 #include "chrome/browser/autofill/crypto/rc4_decryptor.h" | 18 #include "chrome/browser/autofill/crypto/rc4_decryptor.h" |
| 13 #include "chrome/browser/autofill/field_types.h" | 19 #include "chrome/browser/autofill/field_types.h" |
| 20 #include "chrome/browser/autofill/form_group.h" |
| 14 #include "chrome/browser/autofill/personal_data_manager.h" | 21 #include "chrome/browser/autofill/personal_data_manager.h" |
| 15 #include "chrome/browser/sync/util/data_encryption.h" | 22 #include "chrome/browser/sync/util/data_encryption.h" |
| 16 | 23 |
| 17 using base::win::RegKey; | 24 using base::win::RegKey; |
| 18 | 25 |
| 19 // Forward declaration. This function is not in unnamed namespace as it | 26 // Forward declaration. This function is not in unnamed namespace as it |
| 20 // is referenced in the unittest. | 27 // is referenced in the unittest. |
| 21 bool ImportCurrentUserProfiles(std::vector<AutofillProfile>* profiles, | 28 bool ImportCurrentUserProfiles(std::vector<AutofillProfile>* profiles, |
| 22 std::vector<CreditCard>* credit_cards); | 29 std::vector<CreditCard>* credit_cards); |
| 23 namespace { | 30 namespace { |
| 24 | 31 |
| 25 const wchar_t* const kProfileKey = | 32 const wchar_t* const kProfileKey = |
| 26 L"Software\\Google\\Google Toolbar\\4.0\\Autofill\\Profiles"; | 33 L"Software\\Google\\Google Toolbar\\4.0\\Autofill\\Profiles"; |
| 27 const wchar_t* const kCreditCardKey = | 34 const wchar_t* const kCreditCardKey = |
| 28 L"Software\\Google\\Google Toolbar\\4.0\\Autofill\\Credit Cards"; | 35 L"Software\\Google\\Google Toolbar\\4.0\\Autofill\\Credit Cards"; |
| 29 const wchar_t* const kPasswordHashValue = L"password_hash"; | 36 const wchar_t* const kPasswordHashValue = L"password_hash"; |
| 30 const wchar_t* const kSaltValue = L"salt"; | 37 const wchar_t* const kSaltValue = L"salt"; |
| 31 | 38 |
| 32 // This is RC4 decryption for Toolbar credit card data. This is necessary | 39 // This is RC4 decryption for Toolbar credit card data. This is necessary |
| 33 // because it is not standard, so Crypto api cannot be used. | 40 // because it is not standard, so Crypto API cannot be used. |
| 34 std::wstring DecryptCCNumber(const std::wstring& data) { | 41 std::wstring DecryptCCNumber(const std::wstring& data) { |
| 35 const wchar_t* kEmptyKey = | 42 const wchar_t* kEmptyKey = |
| 36 L"\x3605\xCEE5\xCE49\x44F7\xCF4E\xF6CC\x604B\xFCBE\xC70A\x08FD"; | 43 L"\x3605\xCEE5\xCE49\x44F7\xCF4E\xF6CC\x604B\xFCBE\xC70A\x08FD"; |
| 37 const size_t kMacLen = 10; | 44 const size_t kMacLen = 10; |
| 38 | 45 |
| 39 if (data.length() <= kMacLen) | 46 if (data.length() <= kMacLen) |
| 40 return std::wstring(); | 47 return std::wstring(); |
| 41 | 48 |
| 42 RC4Decryptor rc4_algorithm(kEmptyKey); | 49 RC4Decryptor rc4_algorithm(kEmptyKey); |
| 43 return rc4_algorithm.Run(data.substr(kMacLen)); | 50 return rc4_algorithm.Run(data.substr(kMacLen)); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 | 257 |
| 251 bool ImportAutofillDataWin(PersonalDataManager* pdm) { | 258 bool ImportAutofillDataWin(PersonalDataManager* pdm) { |
| 252 // In incognito mode we do not have PDM - and we should not import anything. | 259 // In incognito mode we do not have PDM - and we should not import anything. |
| 253 if (!pdm) | 260 if (!pdm) |
| 254 return false; | 261 return false; |
| 255 AutofillImporter *importer = new AutofillImporter(pdm); | 262 AutofillImporter *importer = new AutofillImporter(pdm); |
| 256 // importer will self delete. | 263 // importer will self delete. |
| 257 return importer->ImportProfiles(); | 264 return importer->ImportProfiles(); |
| 258 } | 265 } |
| 259 | 266 |
| OLD | NEW |