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

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

Issue 2818033: AutoFill: Aggregate profile data. Remove the AutoFill InfoBar. (Closed)
Patch Set: Comment. 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
« no previous file with comments | « chrome/browser/autofill/address.h ('k') | chrome/browser/autofill/autofill_common_unittest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/autofill/address.h" 5 #include "chrome/browser/autofill/address.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/browser/autofill/autofill_type.h" 9 #include "chrome/browser/autofill/autofill_type.h"
10 #include "chrome/browser/autofill/field_types.h" 10 #include "chrome/browser/autofill/field_types.h"
(...skipping 12 matching lines...) Expand all
23 AutoFillType::ADDRESS_COUNTRY, 23 AutoFillType::ADDRESS_COUNTRY,
24 }; 24 };
25 25
26 const int kAutoFillAddressLength = arraysize(kAutoFillAddressTypes); 26 const int kAutoFillAddressLength = arraysize(kAutoFillAddressTypes);
27 27
28 } // namespace 28 } // namespace
29 29
30 void Address::GetPossibleFieldTypes(const string16& text, 30 void Address::GetPossibleFieldTypes(const string16& text,
31 FieldTypeSet* possible_types) const { 31 FieldTypeSet* possible_types) const {
32 DCHECK(possible_types); 32 DCHECK(possible_types);
33 if (!possible_types)
34 return;
35 33
36 // If the text to match against the field types is empty, then no results will 34 // If the text to match against the field types is empty, then no results will
37 // match. 35 // match.
38 if (text.empty()) 36 if (text.empty())
39 return; 37 return;
40 38
41 if (IsLine1(text)) 39 if (IsLine1(text))
42 possible_types->insert(GetLine1Type()); 40 possible_types->insert(GetLine1Type());
43 41
44 if (IsLine2(text)) 42 if (IsLine2(text))
45 possible_types->insert(GetLine2Type()); 43 possible_types->insert(GetLine2Type());
46 44
47 if (IsAptNum(text)) 45 if (IsAptNum(text))
48 possible_types->insert(GetAptNumType()); 46 possible_types->insert(GetAptNumType());
49 47
50 if (IsCity(text)) 48 if (IsCity(text))
51 possible_types->insert(GetCityType()); 49 possible_types->insert(GetCityType());
52 50
53 if (IsState(text)) 51 if (IsState(text))
54 possible_types->insert(GetStateType()); 52 possible_types->insert(GetStateType());
55 53
56 if (IsZipCode(text)) 54 if (IsZipCode(text))
57 possible_types->insert(GetZipCodeType()); 55 possible_types->insert(GetZipCodeType());
58 56
59 if (IsCountry(text)) 57 if (IsCountry(text))
60 possible_types->insert(GetCountryType()); 58 possible_types->insert(GetCountryType());
61 } 59 }
62 60
61 void Address::GetAvailableFieldTypes(FieldTypeSet* available_types) const {
62 DCHECK(available_types);
63
64 if (!line1().empty())
65 available_types->insert(GetLine1Type());
66
67 if (!line2().empty())
68 available_types->insert(GetLine2Type());
69
70 if (!apt_num().empty())
71 available_types->insert(GetAptNumType());
72
73 if (!city().empty())
74 available_types->insert(GetCityType());
75
76 if (!state().empty())
77 available_types->insert(GetStateType());
78
79 if (!zip_code().empty())
80 available_types->insert(GetZipCodeType());
81
82 if (!country().empty())
83 available_types->insert(GetCountryType());
84 }
85
63 void Address::FindInfoMatches(const AutoFillType& type, 86 void Address::FindInfoMatches(const AutoFillType& type,
64 const string16& info, 87 const string16& info,
65 std::vector<string16>* matched_text) const { 88 std::vector<string16>* matched_text) const {
66 DCHECK(matched_text); 89 DCHECK(matched_text);
67 if (!matched_text)
68 return;
69 90
70 string16 match; 91 string16 match;
71 if (type.field_type() == UNKNOWN_TYPE) { 92 if (type.field_type() == UNKNOWN_TYPE) {
72 for (int i = 0; i < kAutoFillAddressLength; ++i) { 93 for (int i = 0; i < kAutoFillAddressLength; ++i) {
73 if (FindInfoMatchesHelper(kAutoFillAddressTypes[i], info, &match)) 94 if (FindInfoMatchesHelper(kAutoFillAddressTypes[i], info, &match))
74 matched_text->push_back(match); 95 matched_text->push_back(match);
75 } 96 }
76 } else { 97 } else {
77 if (FindInfoMatchesHelper(type.subgroup(), info, &match)) 98 if (FindInfoMatchesHelper(type.subgroup(), info, &match))
78 matched_text->push_back(match); 99 matched_text->push_back(match);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 bool Address::IsWordInLine(const string16& word, 288 bool Address::IsWordInLine(const string16& word,
268 const LineTokens& line_tokens) const { 289 const LineTokens& line_tokens) const {
269 LineTokens::const_iterator iter; 290 LineTokens::const_iterator iter;
270 for (iter = line_tokens.begin(); iter != line_tokens.end(); ++iter) { 291 for (iter = line_tokens.begin(); iter != line_tokens.end(); ++iter) {
271 if (StringToLowerASCII(word) == *iter) 292 if (StringToLowerASCII(word) == *iter)
272 return true; 293 return true;
273 } 294 }
274 295
275 return false; 296 return false;
276 } 297 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/address.h ('k') | chrome/browser/autofill/autofill_common_unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698