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

Side by Side Diff: components/autofill/core/browser/webdata/autofill_table.cc

Issue 2008253003: Explicitly set modification_date when loading server entries from db. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comments to implementation file Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/autofill/core/browser/webdata/autofill_table_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/autofill/core/browser/webdata/autofill_table.h" 5 #include "components/autofill/core/browser/webdata/autofill_table.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 "language_code " 946 "language_code "
947 "FROM server_addresses addresses " 947 "FROM server_addresses addresses "
948 "LEFT OUTER JOIN server_address_metadata USING (id)")); 948 "LEFT OUTER JOIN server_address_metadata USING (id)"));
949 949
950 while (s.Step()) { 950 while (s.Step()) {
951 int index = 0; 951 int index = 0;
952 std::unique_ptr<AutofillProfile> profile(new AutofillProfile( 952 std::unique_ptr<AutofillProfile> profile(new AutofillProfile(
953 AutofillProfile::SERVER_PROFILE, s.ColumnString(index++))); 953 AutofillProfile::SERVER_PROFILE, s.ColumnString(index++)));
954 profile->set_use_count(s.ColumnInt64(index++)); 954 profile->set_use_count(s.ColumnInt64(index++));
955 profile->set_use_date(Time::FromInternalValue(s.ColumnInt64(index++))); 955 profile->set_use_date(Time::FromInternalValue(s.ColumnInt64(index++)));
956 // Modification date is not tracked for server profiles. Explicitly set it
957 // here to override the default value of Time::Now().
958 profile->set_modification_date(Time());
956 959
957 base::string16 recipient_name = s.ColumnString16(index++); 960 base::string16 recipient_name = s.ColumnString16(index++);
958 profile->SetRawInfo(COMPANY_NAME, s.ColumnString16(index++)); 961 profile->SetRawInfo(COMPANY_NAME, s.ColumnString16(index++));
959 profile->SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, s.ColumnString16(index++)); 962 profile->SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, s.ColumnString16(index++));
960 profile->SetRawInfo(ADDRESS_HOME_STATE, s.ColumnString16(index++)); 963 profile->SetRawInfo(ADDRESS_HOME_STATE, s.ColumnString16(index++));
961 profile->SetRawInfo(ADDRESS_HOME_CITY, s.ColumnString16(index++)); 964 profile->SetRawInfo(ADDRESS_HOME_CITY, s.ColumnString16(index++));
962 profile->SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY, 965 profile->SetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY,
963 s.ColumnString16(index++)); 966 s.ColumnString16(index++));
964 index++; // Skip address_4 which we haven't added to AutofillProfile yet. 967 index++; // Skip address_4 which we haven't added to AutofillProfile yet.
965 profile->SetRawInfo(ADDRESS_HOME_ZIP, s.ColumnString16(index++)); 968 profile->SetRawInfo(ADDRESS_HOME_ZIP, s.ColumnString16(index++));
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 CreditCard::FULL_SERVER_CARD; 1215 CreditCard::FULL_SERVER_CARD;
1213 std::string server_id = s.ColumnString(index++); 1216 std::string server_id = s.ColumnString(index++);
1214 1217
1215 CreditCard* card = new CreditCard(record_type, server_id); 1218 CreditCard* card = new CreditCard(record_type, server_id);
1216 card->SetRawInfo( 1219 card->SetRawInfo(
1217 CREDIT_CARD_NUMBER, 1220 CREDIT_CARD_NUMBER,
1218 record_type == CreditCard::MASKED_SERVER_CARD ? last_four 1221 record_type == CreditCard::MASKED_SERVER_CARD ? last_four
1219 : full_card_number); 1222 : full_card_number);
1220 card->set_use_count(s.ColumnInt64(index++)); 1223 card->set_use_count(s.ColumnInt64(index++));
1221 card->set_use_date(Time::FromInternalValue(s.ColumnInt64(index++))); 1224 card->set_use_date(Time::FromInternalValue(s.ColumnInt64(index++)));
1225 // Modification date is not tracked for server cards. Explicitly set it here
1226 // to override the default value of Time::Now().
1227 card->set_modification_date(Time());
1222 1228
1223 std::string card_type = s.ColumnString(index++); 1229 std::string card_type = s.ColumnString(index++);
1224 if (record_type == CreditCard::MASKED_SERVER_CARD) { 1230 if (record_type == CreditCard::MASKED_SERVER_CARD) {
1225 // The type must be set after setting the number to override the 1231 // The type must be set after setting the number to override the
1226 // autodectected type. 1232 // autodectected type.
1227 card->SetTypeForMaskedCard(card_type.c_str()); 1233 card->SetTypeForMaskedCard(card_type.c_str());
1228 } else { 1234 } else {
1229 DCHECK_EQ(CreditCard::GetCreditCardType(full_card_number), card_type); 1235 DCHECK_EQ(CreditCard::GetCreditCardType(full_card_number), card_type);
1230 } 1236 }
1231 1237
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
2256 insert.BindString16(index++, profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); 2262 insert.BindString16(index++, profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
2257 insert.BindString(index++, profile.language_code()); 2263 insert.BindString(index++, profile.language_code());
2258 insert.Run(); 2264 insert.Run();
2259 insert.Reset(true); 2265 insert.Reset(true);
2260 } 2266 }
2261 2267
2262 return transaction.Commit(); 2268 return transaction.Commit();
2263 } 2269 }
2264 2270
2265 } // namespace autofill 2271 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | components/autofill/core/browser/webdata/autofill_table_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698