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

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

Issue 8143007: Move a bunch of non-shared methods out of the FormGroup class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/autofill/personal_data_manager.h" 5 #include "chrome/browser/autofill/personal_data_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 return false; 596 return false;
597 597
598 return true; 598 return true;
599 } 599 }
600 600
601 // static 601 // static
602 bool PersonalDataManager::MergeProfile( 602 bool PersonalDataManager::MergeProfile(
603 const AutofillProfile& profile, 603 const AutofillProfile& profile,
604 const std::vector<AutofillProfile*>& existing_profiles, 604 const std::vector<AutofillProfile*>& existing_profiles,
605 std::vector<AutofillProfile>* merged_profiles) { 605 std::vector<AutofillProfile>* merged_profiles) {
606 DCHECK(merged_profiles);
607 merged_profiles->clear(); 606 merged_profiles->clear();
608 607
609 // Set to true if |profile| is merged into |existing_profiles|. 608 // Set to true if |profile| is merged into |existing_profiles|.
610 bool merged = false; 609 bool merged = false;
611 610
612 // First preference is to add missing values to an existing profile. 611 // If we have already saved this address, merge in any missing values.
613 // Only merge with the first match. 612 // Only merge with the first match.
614 for (std::vector<AutofillProfile*>::const_iterator iter = 613 for (std::vector<AutofillProfile*>::const_iterator iter =
615 existing_profiles.begin(); 614 existing_profiles.begin();
616 iter != existing_profiles.end(); ++iter) { 615 iter != existing_profiles.end(); ++iter) {
617 if (!merged) { 616 if (!merged) {
618 if (profile.IsSubsetOf(**iter)) { 617 if (!profile.PrimaryValue().empty() &&
619 // In this case, the existing profile already contains all of the data 618 StringToLowerASCII((*iter)->PrimaryValue()) ==
620 // in |profile|, so consider the profiles already merged. 619 StringToLowerASCII(profile.PrimaryValue())) {
621 merged = true; 620 merged = true;
622 } else if ((*iter)->IntersectionOfTypesHasEqualValues(profile)) { 621 (*iter)->OverwriteWithOrAddTo(profile);
623 // |profile| contains all of the data in this profile, plus more.
624 merged = true;
625 (*iter)->MergeWith(profile);
626 } 622 }
627 } 623 }
628 merged_profiles->push_back(**iter); 624 merged_profiles->push_back(**iter);
629 } 625 }
630 626
631 // The second preference, if not merged above, is to alter non-primary values 627 // If the new profile was not merged with an existing one, add it to the list.
632 // where the primary values match.
633 // Again, only merge with the first match.
634 if (!merged) {
635 merged_profiles->clear();
636 for (std::vector<AutofillProfile*>::const_iterator iter =
637 existing_profiles.begin();
638 iter != existing_profiles.end(); ++iter) {
639 if (!merged) {
640 if (!profile.PrimaryValue().empty() &&
641 StringToLowerASCII((*iter)->PrimaryValue()) ==
642 StringToLowerASCII(profile.PrimaryValue())) {
643 merged = true;
644 (*iter)->OverwriteWithOrAddTo(profile);
645 }
646 }
647 merged_profiles->push_back(**iter);
648 }
649 }
650
651 // Finally, if the new profile was not merged with an existing profile then
652 // add the new profile to the list.
653 if (!merged) 628 if (!merged)
654 merged_profiles->push_back(profile); 629 merged_profiles->push_back(profile);
655 630
656 return merged; 631 return merged;
657 } 632 }
658 633
659 void PersonalDataManager::SetProfiles(std::vector<AutofillProfile>* profiles) { 634 void PersonalDataManager::SetProfiles(std::vector<AutofillProfile>* profiles) {
660 if (profile_->IsOffTheRecord()) 635 if (profile_->IsOffTheRecord())
661 return; 636 return;
662 637
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 } 912 }
938 913
939 const AutofillMetrics* PersonalDataManager::metric_logger() const { 914 const AutofillMetrics* PersonalDataManager::metric_logger() const {
940 return metric_logger_.get(); 915 return metric_logger_.get();
941 } 916 }
942 917
943 void PersonalDataManager::set_metric_logger( 918 void PersonalDataManager::set_metric_logger(
944 const AutofillMetrics* metric_logger) { 919 const AutofillMetrics* metric_logger) {
945 metric_logger_.reset(metric_logger); 920 metric_logger_.reset(metric_logger);
946 } 921 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698