1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/autofill/form_group.h"
string16 FormGroup::GetPreviewText(const AutoFillType& type) const {
return GetFieldText(type);
}
const string16& FormGroup::Label() const { return EmptyString16(); }
bool FormGroup::operator!=(const FormGroup& form_group) const {
FieldTypeSet a, b, symmetric_difference;
GetAvailableFieldTypes(&a);
form_group.GetAvailableFieldTypes(&b);
std::set_symmetric_difference(
a.begin(), a.end(),
b.begin(), b.end(),
std::inserter(symmetric_difference, symmetric_difference.begin()));
if (!symmetric_difference.empty())
return true;
return (!IntersectionOfTypesHasEqualValues(form_group));
}
bool FormGroup::IsSubsetOf(const FormGroup& form_group) const {
FieldTypeSet types;
GetAvailableFieldTypes(&types);
for (FieldTypeSet::const_iterator iter = types.begin(); iter != types.end();
++iter) {
AutoFillType type(*iter);
if (GetFieldText(type) != form_group.GetFieldText(type))
return false;
}
return true;
}
bool FormGroup::IntersectionOfTypesHasEqualValues(
const FormGroup& form_group) const {
FieldTypeSet a, b, intersection;
GetAvailableFieldTypes(&a);
form_group.GetAvailableFieldTypes(&b);
std::set_intersection(a.begin(), a.end(),
b.begin(), b.end(),
std::inserter(intersection, intersection.begin()));
// An empty intersection can't have equal values.
if (intersection.empty())
return false;
for (FieldTypeSet::const_iterator iter = intersection.begin();
iter != intersection.end(); ++iter) {
AutoFillType type(*iter);
if (GetFieldText(type) != form_group.GetFieldText(type))
return false;
}
return true;
}
void FormGroup::MergeWith(const FormGroup& form_group) {
FieldTypeSet a, b, intersection;
GetAvailableFieldTypes(&a);
form_group.GetAvailableFieldTypes(&b);
std::set_difference(b.begin(), b.end(),
a.begin(), a.end(),
std::inserter(intersection, intersection.begin()));
for (FieldTypeSet::const_iterator iter = intersection.begin();
iter != intersection.end(); ++iter) {
AutoFillType type(*iter);
SetInfo(type, form_group.GetFieldText(type));
}
}
|