| 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 "components/autofill/browser/personal_data_manager.h" | 5 #include "components/autofill/browser/personal_data_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <iterator> | 9 #include <iterator> |
| 10 | 10 |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 if (is_credit_card) | 500 if (is_credit_card) |
| 501 autofill_data->RemoveCreditCard(guid); | 501 autofill_data->RemoveCreditCard(guid); |
| 502 else | 502 else |
| 503 autofill_data->RemoveAutofillProfile(guid); | 503 autofill_data->RemoveAutofillProfile(guid); |
| 504 | 504 |
| 505 // Refresh our local cache and send notifications to observers. | 505 // Refresh our local cache and send notifications to observers. |
| 506 Refresh(); | 506 Refresh(); |
| 507 } | 507 } |
| 508 | 508 |
| 509 CreditCard* PersonalDataManager::GetCreditCardByGUID(const std::string& guid) { | 509 CreditCard* PersonalDataManager::GetCreditCardByGUID(const std::string& guid) { |
| 510 for (std::vector<CreditCard*>::iterator iter = credit_cards_.begin(); | 510 const std::vector<CreditCard*>& credit_cards = GetCreditCards(); |
| 511 iter != credit_cards_.end(); ++iter) { | 511 for (std::vector<CreditCard*>::const_iterator iter = credit_cards.begin(); |
| 512 iter != credit_cards.end(); ++iter) { |
| 512 if ((*iter)->guid() == guid) | 513 if ((*iter)->guid() == guid) |
| 513 return *iter; | 514 return *iter; |
| 514 } | 515 } |
| 515 return NULL; | 516 return NULL; |
| 516 } | 517 } |
| 517 | 518 |
| 518 void PersonalDataManager::GetNonEmptyTypes( | 519 void PersonalDataManager::GetNonEmptyTypes( |
| 519 FieldTypeSet* non_empty_types) { | 520 FieldTypeSet* non_empty_types) { |
| 520 const std::vector<AutofillProfile*>& profiles = GetProfiles(); | 521 const std::vector<AutofillProfile*>& profiles = GetProfiles(); |
| 521 for (std::vector<AutofillProfile*>::const_iterator iter = profiles.begin(); | 522 for (std::vector<AutofillProfile*>::const_iterator iter = profiles.begin(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 547 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end()); | 548 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end()); |
| 548 profiles_.insert(profiles_.end(), | 549 profiles_.insert(profiles_.end(), |
| 549 auxiliary_profiles_.begin(), auxiliary_profiles_.end()); | 550 auxiliary_profiles_.begin(), auxiliary_profiles_.end()); |
| 550 return profiles_; | 551 return profiles_; |
| 551 } | 552 } |
| 552 | 553 |
| 553 const std::vector<AutofillProfile*>& PersonalDataManager::web_profiles() const { | 554 const std::vector<AutofillProfile*>& PersonalDataManager::web_profiles() const { |
| 554 return web_profiles_.get(); | 555 return web_profiles_.get(); |
| 555 } | 556 } |
| 556 | 557 |
| 557 const std::vector<CreditCard*>& PersonalDataManager::credit_cards() const { | 558 const std::vector<CreditCard*>& PersonalDataManager::GetCreditCards() const { |
| 558 return credit_cards_.get(); | 559 return credit_cards_.get(); |
| 559 } | 560 } |
| 560 | 561 |
| 561 void PersonalDataManager::Refresh() { | 562 void PersonalDataManager::Refresh() { |
| 562 LoadProfiles(); | 563 LoadProfiles(); |
| 563 LoadCreditCards(); | 564 LoadCreditCards(); |
| 564 } | 565 } |
| 565 | 566 |
| 566 void PersonalDataManager::GetProfileSuggestions( | 567 void PersonalDataManager::GetProfileSuggestions( |
| 567 AutofillFieldType type, | 568 AutofillFieldType type, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 const base::string16& field_contents, | 650 const base::string16& field_contents, |
| 650 std::vector<base::string16>* values, | 651 std::vector<base::string16>* values, |
| 651 std::vector<base::string16>* labels, | 652 std::vector<base::string16>* labels, |
| 652 std::vector<base::string16>* icons, | 653 std::vector<base::string16>* icons, |
| 653 std::vector<GUIDPair>* guid_pairs) { | 654 std::vector<GUIDPair>* guid_pairs) { |
| 654 values->clear(); | 655 values->clear(); |
| 655 labels->clear(); | 656 labels->clear(); |
| 656 icons->clear(); | 657 icons->clear(); |
| 657 guid_pairs->clear(); | 658 guid_pairs->clear(); |
| 658 | 659 |
| 659 for (std::vector<CreditCard*>::const_iterator iter = credit_cards().begin(); | 660 const std::vector<CreditCard*>& credit_cards = GetCreditCards(); |
| 660 iter != credit_cards().end(); ++iter) { | 661 for (std::vector<CreditCard*>::const_iterator iter = credit_cards.begin(); |
| 662 iter != credit_cards.end(); ++iter) { |
| 661 CreditCard* credit_card = *iter; | 663 CreditCard* credit_card = *iter; |
| 662 | 664 |
| 663 // The value of the stored data for this field type in the |credit_card|. | 665 // The value of the stored data for this field type in the |credit_card|. |
| 664 base::string16 creditcard_field_value = | 666 base::string16 creditcard_field_value = |
| 665 credit_card->GetInfo(type, app_locale_); | 667 credit_card->GetInfo(type, app_locale_); |
| 666 if (!creditcard_field_value.empty() && | 668 if (!creditcard_field_value.empty() && |
| 667 StartsWith(creditcard_field_value, field_contents, false)) { | 669 StartsWith(creditcard_field_value, field_contents, false)) { |
| 668 if (type == CREDIT_CARD_NUMBER) | 670 if (type == CREDIT_CARD_NUMBER) |
| 669 creditcard_field_value = credit_card->ObfuscatedNumber(); | 671 creditcard_field_value = credit_card->ObfuscatedNumber(); |
| 670 | 672 |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 const AutofillMetrics* metric_logger) { | 1018 const AutofillMetrics* metric_logger) { |
| 1017 metric_logger_.reset(metric_logger); | 1019 metric_logger_.reset(metric_logger); |
| 1018 } | 1020 } |
| 1019 | 1021 |
| 1020 void PersonalDataManager::set_browser_context( | 1022 void PersonalDataManager::set_browser_context( |
| 1021 content::BrowserContext* context) { | 1023 content::BrowserContext* context) { |
| 1022 browser_context_ = context; | 1024 browser_context_ = context; |
| 1023 } | 1025 } |
| 1024 | 1026 |
| 1025 } // namespace autofill | 1027 } // namespace autofill |
| OLD | NEW |