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> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/string16.h" | 15 #include "base/string16.h" |
16 #include "base/win/registry.h" | 16 #include "base/win/registry.h" |
17 #include "chrome/browser/autofill/autofill_country.h" | |
17 #include "chrome/browser/autofill/autofill_profile.h" | 18 #include "chrome/browser/autofill/autofill_profile.h" |
18 #include "chrome/browser/autofill/credit_card.h" | 19 #include "chrome/browser/autofill/credit_card.h" |
19 #include "chrome/browser/autofill/crypto/rc4_decryptor.h" | 20 #include "chrome/browser/autofill/crypto/rc4_decryptor.h" |
20 #include "chrome/browser/autofill/field_types.h" | 21 #include "chrome/browser/autofill/field_types.h" |
21 #include "chrome/browser/autofill/form_group.h" | 22 #include "chrome/browser/autofill/form_group.h" |
22 #include "chrome/browser/autofill/personal_data_manager.h" | 23 #include "chrome/browser/autofill/personal_data_manager.h" |
23 #include "chrome/browser/autofill/personal_data_manager_observer.h" | 24 #include "chrome/browser/autofill/personal_data_manager_observer.h" |
24 #include "chrome/browser/autofill/phone_number.h" | 25 #include "chrome/browser/autofill/phone_number.h" |
25 #include "chrome/browser/autofill/phone_number_i18n.h" | 26 #include "chrome/browser/autofill/phone_number_i18n.h" |
26 #include "sync/util/data_encryption_win.h" | 27 #include "sync/util/data_encryption_win.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 | 151 |
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 // TODO(isherman): Call SetInfo(), rather than SetRawInfo(). | 154 // TODO(isherman): Call SetInfo(), rather than SetRawInfo(). |
154 if (!phone.SetInfo(it->second, field_value)) | 155 if (!phone.SetInfo(it->second, field_value)) |
155 profile->SetRawInfo(it->second, field_value); | 156 profile->SetRawInfo(it->second, field_value); |
156 } | 157 } |
157 } | 158 } |
158 // Now re-construct the phones if needed. | 159 // Now re-construct the phones if needed. |
159 string16 constructed_number; | 160 string16 constructed_number; |
160 if (!phone.IsEmpty() && | 161 const std::string app_locale = AutofillCountry::ApplicationLocale(), |
dhollowa
2013/01/09 01:26:54
win compile problem.
Ilya Sherman
2013/01/09 01:29:10
Whoops. Fixed.
| |
161 phone.ParseNumber(std::string("US"), &constructed_number)) { | 162 if (phone.ParseNumber(*profile, app_locale, &constructed_number)) |
162 profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, constructed_number); | 163 profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, constructed_number); |
163 } | |
164 | 164 |
165 return has_non_empty_fields; | 165 return has_non_empty_fields; |
166 } | 166 } |
167 | 167 |
168 // Imports profiles from the IE toolbar and stores them. Asynchronous | 168 // Imports profiles from the IE toolbar and stores them. Asynchronous |
169 // if PersonalDataManager has not been loaded yet. Deletes itself on completion. | 169 // if PersonalDataManager has not been loaded yet. Deletes itself on completion. |
170 class AutofillImporter : public PersonalDataManagerObserver { | 170 class AutofillImporter : public PersonalDataManagerObserver { |
171 public: | 171 public: |
172 explicit AutofillImporter(PersonalDataManager* personal_data_manager) | 172 explicit AutofillImporter(PersonalDataManager* personal_data_manager) |
173 : personal_data_manager_(personal_data_manager) { | 173 : personal_data_manager_(personal_data_manager) { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 } | 267 } |
268 | 268 |
269 bool ImportAutofillDataWin(PersonalDataManager* pdm) { | 269 bool ImportAutofillDataWin(PersonalDataManager* pdm) { |
270 // In incognito mode we do not have PDM - and we should not import anything. | 270 // In incognito mode we do not have PDM - and we should not import anything. |
271 if (!pdm) | 271 if (!pdm) |
272 return false; | 272 return false; |
273 AutofillImporter *importer = new AutofillImporter(pdm); | 273 AutofillImporter *importer = new AutofillImporter(pdm); |
274 // importer will self delete. | 274 // importer will self delete. |
275 return importer->ImportProfiles(); | 275 return importer->ImportProfiles(); |
276 } | 276 } |
OLD | NEW |