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

Side by Side Diff: chrome/browser/autofill/autofill_profile.h

Issue 2835026: Added inferred labels implementation. Label inferred from the person name + d... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_PROFILE_H_ 5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_PROFILE_H_
6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_PROFILE_H_ 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_PROFILE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // Profile summary string for UI. 49 // Profile summary string for UI.
50 // Constructs a summary string based on NAME_FIRST, NAME_LAST, and 50 // Constructs a summary string based on NAME_FIRST, NAME_LAST, and
51 // ADDRESS_HOME_LINE1 fields of the profile. The summary string is of the 51 // ADDRESS_HOME_LINE1 fields of the profile. The summary string is of the
52 // form: 52 // form:
53 // L"<first_name> <last_name>, <address_line_1>" 53 // L"<first_name> <last_name>, <address_line_1>"
54 // but may omit any or all of the fields if they are not present in the 54 // but may omit any or all of the fields if they are not present in the
55 // profile. 55 // profile.
56 // The form of the string is governed by generated resources. 56 // The form of the string is governed by generated resources.
57 string16 PreviewSummary() const; 57 string16 PreviewSummary() const;
58 58
59 // Adjusts the labels according to profile data.
60 // Labels contain minimal different combination of:
61 // 1. Full name.
62 // 2. Address.
63 // 3. E-mail.
64 // 4. Phone.
65 // 5. Fax.
66 // 6. Company name.
67 // Profile labels are changed accordingly to these rules.
68 // Returns true if any of the profiles were updated.
69 // This function is useful if you want to adjust unique labels for all
70 // profiles. For non permanent situations (selection of profile, when user
71 // started typing in the field, for example) use CreateInferredLabels().
72 static bool AdjustInferredLabels(std::vector<AutoFillProfile*>* profiles);
73
74 // Created inferred labels for |profiles|, according to the rules above and
75 // stores them in |created_labels|. |minimal_fields_shown| minimal number of
76 // fields that need to be shown for the label. |exclude_field| is excluded
77 // from the label.
78 static void CreateInferredLabels(
79 const std::vector<AutoFillProfile*>* profiles,
80 std::vector<string16>* created_labels,
81 size_t minimal_fields_shown,
82 AutoFillFieldType exclude_field);
59 // For use in STL containers. 83 // For use in STL containers.
60 void operator=(const AutoFillProfile&); 84 void operator=(const AutoFillProfile&);
61 85
62 // For WebData and Sync. 86 // For WebData and Sync.
63 bool operator==(const AutoFillProfile& profile) const; 87 bool operator==(const AutoFillProfile& profile) const;
64 virtual bool operator!=(const AutoFillProfile& profile) const; 88 virtual bool operator!=(const AutoFillProfile& profile) const;
65 void set_label(const string16& label) { label_ = label; } 89 void set_label(const string16& label) { label_ = label; }
66 90
67 private: 91 private:
68 Address* GetHomeAddress(); 92 Address* GetHomeAddress();
69 93
94 // Builds inferred label, includes first non-empty field at the beginning,
95 // even if it matches for all.
96 // |included_fields| - array of the fields, that needs to be included in this
97 // label.
98 string16 ConstructInferredLabel(
99 const std::vector<AutoFillFieldType>* included_fields) const;
100
70 // The label presented to the user when selecting a profile. 101 // The label presented to the user when selecting a profile.
71 string16 label_; 102 string16 label_;
72 103
73 // The unique ID of this profile. 104 // The unique ID of this profile.
74 int unique_id_; 105 int unique_id_;
75 106
76 // Personal information for this profile. 107 // Personal information for this profile.
77 FormGroupMap personal_info_; 108 FormGroupMap personal_info_;
78 }; 109 };
79 110
80 // So we can compare AutoFillProfiles with EXPECT_EQ(). 111 // So we can compare AutoFillProfiles with EXPECT_EQ().
81 std::ostream& operator<<(std::ostream& os, const AutoFillProfile& profile); 112 std::ostream& operator<<(std::ostream& os, const AutoFillProfile& profile);
82 113
83 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_PROFILE_H_ 114 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_PROFILE_H_
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_manager_unittest.cc ('k') | chrome/browser/autofill/autofill_profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698