Chromium Code Reviews| Index: chrome/browser/autofill/personal_data_manager.cc |
| =================================================================== |
| --- chrome/browser/autofill/personal_data_manager.cc (revision 71100) |
| +++ 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; |
| + 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()); |
| + } |
| + 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); |
|
dhollowa
2011/01/11 23:29:29
Use of ";" as loop body causes compiler warning on
GeorgeY
2011/01/13 23:22:28
Code moved and fixed in the process :)
|
| + 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,17 @@ |
| 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 |
| + if (!profile->GetFieldText( |
| + AutoFillType(static_cast<AutoFillFieldType>(i))).empty()) |
| + binary_data_mask[i >> 3] |= (0x80 >> (i & 7)); |
| + } |
| +} |
| + |