| OLD | NEW |
| 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "chrome/browser/autofill/form_group.h" | 7 #include "chrome/browser/autofill/form_group.h" |
| 8 | 8 |
| 9 #include <iterator> | 9 #include <iterator> |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 return (!IntersectionOfTypesHasEqualValues(form_group)); | 25 return (!IntersectionOfTypesHasEqualValues(form_group)); |
| 26 } | 26 } |
| 27 | 27 |
| 28 bool FormGroup::IsSubsetOf(const FormGroup& form_group) const { | 28 bool FormGroup::IsSubsetOf(const FormGroup& form_group) const { |
| 29 FieldTypeSet types; | 29 FieldTypeSet types; |
| 30 GetAvailableFieldTypes(&types); | 30 GetAvailableFieldTypes(&types); |
| 31 | 31 |
| 32 for (FieldTypeSet::const_iterator iter = types.begin(); iter != types.end(); | 32 for (FieldTypeSet::const_iterator iter = types.begin(); iter != types.end(); |
| 33 ++iter) { | 33 ++iter) { |
| 34 if (GetInfo(*iter) != form_group.GetInfo(*iter)) | 34 if (StringToLowerASCII(GetInfo(*iter)) != |
| 35 StringToLowerASCII(form_group.GetInfo(*iter))) |
| 35 return false; | 36 return false; |
| 36 } | 37 } |
| 37 | 38 |
| 38 return true; | 39 return true; |
| 39 } | 40 } |
| 40 | 41 |
| 41 bool FormGroup::IntersectionOfTypesHasEqualValues( | 42 bool FormGroup::IntersectionOfTypesHasEqualValues( |
| 42 const FormGroup& form_group) const { | 43 const FormGroup& form_group) const { |
| 43 FieldTypeSet a, b, intersection; | 44 FieldTypeSet a, b, intersection; |
| 44 GetAvailableFieldTypes(&a); | 45 GetAvailableFieldTypes(&a); |
| 45 form_group.GetAvailableFieldTypes(&b); | 46 form_group.GetAvailableFieldTypes(&b); |
| 46 std::set_intersection(a.begin(), a.end(), | 47 std::set_intersection(a.begin(), a.end(), |
| 47 b.begin(), b.end(), | 48 b.begin(), b.end(), |
| 48 std::inserter(intersection, intersection.begin())); | 49 std::inserter(intersection, intersection.begin())); |
| 49 | 50 |
| 50 // An empty intersection can't have equal values. | 51 // An empty intersection can't have equal values. |
| 51 if (intersection.empty()) | 52 if (intersection.empty()) |
| 52 return false; | 53 return false; |
| 53 | 54 |
| 54 for (FieldTypeSet::const_iterator iter = intersection.begin(); | 55 for (FieldTypeSet::const_iterator iter = intersection.begin(); |
| 55 iter != intersection.end(); ++iter) { | 56 iter != intersection.end(); ++iter) { |
| 56 if (GetInfo(*iter) != form_group.GetInfo(*iter)) | 57 if (StringToLowerASCII(GetInfo(*iter)) != |
| 58 StringToLowerASCII(form_group.GetInfo(*iter))) |
| 57 return false; | 59 return false; |
| 58 } | 60 } |
| 59 | 61 |
| 60 return true; | 62 return true; |
| 61 } | 63 } |
| 62 | 64 |
| 63 void FormGroup::MergeWith(const FormGroup& form_group) { | 65 void FormGroup::MergeWith(const FormGroup& form_group) { |
| 64 FieldTypeSet a, b, intersection; | 66 FieldTypeSet a, b, intersection; |
| 65 GetAvailableFieldTypes(&a); | 67 GetAvailableFieldTypes(&a); |
| 66 form_group.GetAvailableFieldTypes(&b); | 68 form_group.GetAvailableFieldTypes(&b); |
| 67 std::set_difference(b.begin(), b.end(), | 69 std::set_difference(b.begin(), b.end(), |
| 68 a.begin(), a.end(), | 70 a.begin(), a.end(), |
| 69 std::inserter(intersection, intersection.begin())); | 71 std::inserter(intersection, intersection.begin())); |
| 70 | 72 |
| 71 for (FieldTypeSet::const_iterator iter = intersection.begin(); | 73 for (FieldTypeSet::const_iterator iter = intersection.begin(); |
| 72 iter != intersection.end(); ++iter) { | 74 iter != intersection.end(); ++iter) { |
| 73 SetInfo(*iter, form_group.GetInfo(*iter)); | 75 SetInfo(*iter, form_group.GetInfo(*iter)); |
| 74 } | 76 } |
| 75 } | 77 } |
| 76 | 78 |
| 77 void FormGroup::OverwriteWith(const FormGroup& form_group) { | 79 void FormGroup::OverwriteWith(const FormGroup& form_group) { |
| 78 FieldTypeSet a;; | 80 FieldTypeSet a;; |
| 79 form_group.GetAvailableFieldTypes(&a); | 81 form_group.GetAvailableFieldTypes(&a); |
| 80 | 82 |
| 81 for (FieldTypeSet::const_iterator iter = a.begin(); iter != a.end(); ++iter) { | 83 for (FieldTypeSet::const_iterator iter = a.begin(); iter != a.end(); ++iter) { |
| 82 SetInfo(*iter, form_group.GetInfo(*iter)); | 84 SetInfo(*iter, form_group.GetInfo(*iter)); |
| 83 } | 85 } |
| 84 } | 86 } |
| OLD | NEW |