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

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

Issue 6213002: Propagate correct data to the Toolbar servers (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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
Index: chrome/browser/autofill/personal_data_manager.cc
===================================================================
--- chrome/browser/autofill/personal_data_manager.cc (revision 70750)
+++ chrome/browser/autofill/personal_data_manager.cc (working copy)
@@ -642,6 +642,32 @@
pending_creditcards_query_(0) {
}
+std::string PersonalDataManager::PresentData(const std::string& profile_guid,
+ const std::string& cc_guid) {
+ size_t data_size = (MAX_VALID_FIELD_TYPE + 7) >> 3;
Ilya Sherman 2011/01/11 23:17:37 nit: Please either use named constants for "7" and
GeorgeY 2011/01/13 23:22:28 Added comment
+ scoped_array<uint8> binary_data_mask(new uint8[data_size]);
+ memset(binary_data_mask.get(), 0, data_size);
+ for (std::vector<AutoFillProfile*>::const_iterator it = profiles().begin();
+ it != profiles().end(); ++it) {
+ if ((*it)->guid() == profile_guid)
+ SetDataPresenseBits(*it, binary_data_mask.get());
+ }
Ilya Sherman 2011/01/11 23:17:37 nit: Please use PersonalDataManager::GetProfileByG
GeorgeY 2011/01/13 23:22:28 Code removed
+ for (std::vector<CreditCard*>::const_iterator it =
+ credit_cards().begin(); it != credit_cards().end(); ++it) {
+ if ((*it)->guid() == cc_guid)
+ SetDataPresenseBits(*it, binary_data_mask.get());
+ }
+ std::string present_data;
+ present_data.reserve(data_size * 2 + 1);
+ // Skip leading zeroes. If all mask is 0 - return empty string.
+ size_t data_end = data_size;
+ for (; data_end > 0 && !binary_data_mask[data_end - 1]; --data_end);
+ for (size_t i = 0; i < data_end; ++i) {
+ base::StringAppendF(&present_data, "%02x", binary_data_mask[i]);
+ }
+ return present_data;
+}
+
void PersonalDataManager::Init(Profile* profile) {
profile_ = profile;
LoadProfiles();
@@ -799,3 +825,16 @@
SetCreditCards(&creditcards);
}
+
+void PersonalDataManager::SetDataPresenseBits(
+ FormGroup const* profile, uint8* binary_data_mask) {
+ DCHECK(profile);
+ DCHECK(binary_data_mask);
+ for (uint32 i = EMPTY_TYPE; i < MAX_VALID_FIELD_TYPE; ++i) {
+ if (CREDIT_CARD_VERIFICATION_CODE == i)
+ continue; // We do not support CREDIT_CARD_VERIFICATION_CODE
Ilya Sherman 2011/01/11 23:17:37 nit: I think it would be better to remove the NOTR
GeorgeY 2011/01/13 23:22:28 Code removed
+ if (!profile->GetFieldText(
+ AutoFillType(static_cast<AutoFillFieldType>(i))).empty())
+ binary_data_mask[i >> 3] |= (0x80 >> (i & 7));
Ilya Sherman 2011/01/11 23:17:37 nit: A comment explaining this line would make for
GeorgeY 2011/01/13 23:22:28 Added
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698