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

Side by Side Diff: components/autofill/browser/personal_data_manager.cc

Issue 14564003: Make PersonalDataManager use GetCreditCards() (rather than using credit_cards_ directly) so Autofill (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 if (is_credit_card) 487 if (is_credit_card)
488 autofill_data->RemoveCreditCard(guid); 488 autofill_data->RemoveCreditCard(guid);
489 else 489 else
490 autofill_data->RemoveAutofillProfile(guid); 490 autofill_data->RemoveAutofillProfile(guid);
491 491
492 // Refresh our local cache and send notifications to observers. 492 // Refresh our local cache and send notifications to observers.
493 Refresh(); 493 Refresh();
494 } 494 }
495 495
496 CreditCard* PersonalDataManager::GetCreditCardByGUID(const std::string& guid) { 496 CreditCard* PersonalDataManager::GetCreditCardByGUID(const std::string& guid) {
497 for (std::vector<CreditCard*>::iterator iter = credit_cards_.begin(); 497 const std::vector<CreditCard*>& credit_cards = GetCreditCards();
498 iter != credit_cards_.end(); ++iter) { 498 for (std::vector<CreditCard*>::const_iterator iter = credit_cards.begin();
499 iter != credit_cards.end(); ++iter) {
499 if ((*iter)->guid() == guid) 500 if ((*iter)->guid() == guid)
500 return *iter; 501 return *iter;
501 } 502 }
502 return NULL; 503 return NULL;
503 } 504 }
504 505
505 void PersonalDataManager::GetNonEmptyTypes( 506 void PersonalDataManager::GetNonEmptyTypes(
506 FieldTypeSet* non_empty_types) { 507 FieldTypeSet* non_empty_types) {
507 const std::vector<AutofillProfile*>& profiles = GetProfiles(); 508 const std::vector<AutofillProfile*>& profiles = GetProfiles();
508 for (std::vector<AutofillProfile*>::const_iterator iter = profiles.begin(); 509 for (std::vector<AutofillProfile*>::const_iterator iter = profiles.begin();
(...skipping 25 matching lines...) Expand all
534 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end()); 535 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end());
535 profiles_.insert(profiles_.end(), 536 profiles_.insert(profiles_.end(),
536 auxiliary_profiles_.begin(), auxiliary_profiles_.end()); 537 auxiliary_profiles_.begin(), auxiliary_profiles_.end());
537 return profiles_; 538 return profiles_;
538 } 539 }
539 540
540 const std::vector<AutofillProfile*>& PersonalDataManager::web_profiles() const { 541 const std::vector<AutofillProfile*>& PersonalDataManager::web_profiles() const {
541 return web_profiles_.get(); 542 return web_profiles_.get();
542 } 543 }
543 544
544 const std::vector<CreditCard*>& PersonalDataManager::credit_cards() const { 545 const std::vector<CreditCard*>& PersonalDataManager::GetCreditCards() const {
545 return credit_cards_.get(); 546 return credit_cards_.get();
546 } 547 }
547 548
548 void PersonalDataManager::Refresh() { 549 void PersonalDataManager::Refresh() {
549 LoadProfiles(); 550 LoadProfiles();
550 LoadCreditCards(); 551 LoadCreditCards();
551 } 552 }
552 553
553 void PersonalDataManager::GetProfileSuggestions( 554 void PersonalDataManager::GetProfileSuggestions(
554 AutofillFieldType type, 555 AutofillFieldType type,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 const base::string16& field_contents, 637 const base::string16& field_contents,
637 std::vector<base::string16>* values, 638 std::vector<base::string16>* values,
638 std::vector<base::string16>* labels, 639 std::vector<base::string16>* labels,
639 std::vector<base::string16>* icons, 640 std::vector<base::string16>* icons,
640 std::vector<GUIDPair>* guid_pairs) { 641 std::vector<GUIDPair>* guid_pairs) {
641 values->clear(); 642 values->clear();
642 labels->clear(); 643 labels->clear();
643 icons->clear(); 644 icons->clear();
644 guid_pairs->clear(); 645 guid_pairs->clear();
645 646
646 for (std::vector<CreditCard*>::const_iterator iter = credit_cards().begin(); 647 for (std::vector<CreditCard*>::const_iterator iter = credit_cards_.begin();
Ilya Sherman 2013/04/30 08:20:29 Why not use GetCreditCards() for this method as we
Dan Beam 2013/05/01 03:46:44 Done.
647 iter != credit_cards().end(); ++iter) { 648 iter != credit_cards_.end(); ++iter) {
648 CreditCard* credit_card = *iter; 649 CreditCard* credit_card = *iter;
649 650
650 // The value of the stored data for this field type in the |credit_card|. 651 // The value of the stored data for this field type in the |credit_card|.
651 base::string16 creditcard_field_value = 652 base::string16 creditcard_field_value =
652 credit_card->GetInfo(type, app_locale_); 653 credit_card->GetInfo(type, app_locale_);
653 if (!creditcard_field_value.empty() && 654 if (!creditcard_field_value.empty() &&
654 StartsWith(creditcard_field_value, field_contents, false)) { 655 StartsWith(creditcard_field_value, field_contents, false)) {
655 if (type == CREDIT_CARD_NUMBER) 656 if (type == CREDIT_CARD_NUMBER)
656 creditcard_field_value = credit_card->ObfuscatedNumber(); 657 creditcard_field_value = credit_card->ObfuscatedNumber();
657 658
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 const AutofillMetrics* metric_logger) { 999 const AutofillMetrics* metric_logger) {
999 metric_logger_.reset(metric_logger); 1000 metric_logger_.reset(metric_logger);
1000 } 1001 }
1001 1002
1002 void PersonalDataManager::set_browser_context( 1003 void PersonalDataManager::set_browser_context(
1003 content::BrowserContext* context) { 1004 content::BrowserContext* context) {
1004 browser_context_ = context; 1005 browser_context_ = context;
1005 } 1006 }
1006 1007
1007 } // namespace autofill 1008 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698