Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1397)

Unified Diff: chrome/browser/autofill/autofill_ie_toolbar_import_win.cc

Issue 6877130: These changes *are* for review :) (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/autofill/autofill_ie_toolbar_import_win_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autofill/autofill_ie_toolbar_import_win.cc
===================================================================
--- chrome/browser/autofill/autofill_ie_toolbar_import_win.cc (revision 85992)
+++ chrome/browser/autofill/autofill_ie_toolbar_import_win.cc (working copy)
@@ -19,6 +19,8 @@
#include "chrome/browser/autofill/field_types.h"
#include "chrome/browser/autofill/form_group.h"
#include "chrome/browser/autofill/personal_data_manager.h"
+#include "chrome/browser/autofill/phone_number.h"
+#include "chrome/browser/autofill/phone_number_i18n.h"
#include "chrome/browser/sync/util/data_encryption.h"
using base::win::RegKey;
@@ -131,6 +133,10 @@
bool has_non_empty_fields = false;
+ // Phones need to be rebuilt.
+ PhoneNumber::PhoneCombineHelper home(AutofillType::PHONE_HOME);
+ PhoneNumber::PhoneCombineHelper fax(AutofillType::PHONE_FAX);
+
for (uint32 value_index = 0; value_index < key->ValueCount(); ++value_index) {
std::wstring value_name;
if (key->ReadName(value_index, &value_name) != ERROR_SUCCESS)
@@ -144,9 +150,21 @@
if (it->second == CREDIT_CARD_NUMBER) {
field_value = DecryptCCNumber(field_value);
}
- profile->SetInfo(it->second, field_value);
+ // We need to store phone data in the variables, before building the whole
+ // number at the end. The rest of the fields are set "as is".
+ if (!home.SetInfo(it->second, field_value) &&
+ !fax.SetInfo(it->second, field_value)) {
+ profile->SetInfo(it->second, field_value);
+ }
}
}
+ // Now re-construct the phones if needed.
+ string16 constructed_number;
+ if (!home.empty() && home.ParseNumber(std::string("US"), &constructed_number))
+ profile->SetInfo(PHONE_HOME_WHOLE_NUMBER, constructed_number);
+ if (!fax.empty() && fax.ParseNumber(std::string("US"), &constructed_number))
+ profile->SetInfo(PHONE_FAX_WHOLE_NUMBER, constructed_number);
+
return has_non_empty_fields;
}
@@ -219,15 +237,6 @@
AutofillProfile profile;
if (ImportSingleProfile(&profile, &key, reg_to_field)) {
// Combine phones into whole phone #.
- string16 phone;
- phone = profile.GetInfo(PHONE_HOME_COUNTRY_CODE);
- phone.append(profile.GetInfo(PHONE_HOME_CITY_CODE));
- phone.append(profile.GetInfo(PHONE_HOME_NUMBER));
- profile.SetInfo(PHONE_HOME_WHOLE_NUMBER, phone);
- phone = profile.GetInfo(PHONE_FAX_COUNTRY_CODE);
- phone.append(profile.GetInfo(PHONE_FAX_CITY_CODE));
- phone.append(profile.GetInfo(PHONE_FAX_NUMBER));
- profile.SetInfo(PHONE_FAX_WHOLE_NUMBER, phone);
profiles->push_back(profile);
}
}
« no previous file with comments | « no previous file | chrome/browser/autofill/autofill_ie_toolbar_import_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698