Chromium Code Reviews

Side by Side Diff: chrome/browser/autofill/phone_number.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.
Jump to:
View unified diff |
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/phone_number.h" 5 #include "chrome/browser/autofill/phone_number.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_profile.h" 9 #include "chrome/browser/autofill/autofill_profile.h"
10 #include "chrome/browser/autofill/autofill_type.h" 10 #include "chrome/browser/autofill/autofill_type.h"
(...skipping 37 matching lines...)
48 if (IsCountryCode(stripped_text)) 48 if (IsCountryCode(stripped_text))
49 possible_types->insert(GetCountryCodeType()); 49 possible_types->insert(GetCountryCodeType());
50 50
51 if (IsCityAndNumber(stripped_text)) 51 if (IsCityAndNumber(stripped_text))
52 possible_types->insert(GetCityAndNumberType()); 52 possible_types->insert(GetCityAndNumberType());
53 53
54 if (IsWholeNumber(stripped_text)) 54 if (IsWholeNumber(stripped_text))
55 possible_types->insert(GetWholeNumberType()); 55 possible_types->insert(GetWholeNumberType());
56 } 56 }
57 57
58 void PhoneNumber::GetAvailableFieldTypes(FieldTypeSet* available_types) const {
59 DCHECK(available_types);
60
61 if (!number().empty())
62 available_types->insert(GetNumberType());
63
64 if (!city_code().empty())
65 available_types->insert(GetCityCodeType());
66
67 if (!country_code().empty())
68 available_types->insert(GetCountryCodeType());
69
70 if (!CityAndNumber().empty())
71 available_types->insert(GetCityAndNumberType());
72
73 if (!WholeNumber().empty())
74 available_types->insert(GetWholeNumberType());
75 }
76
58 string16 PhoneNumber::GetFieldText(const AutoFillType& type) const { 77 string16 PhoneNumber::GetFieldText(const AutoFillType& type) const {
59 AutoFillFieldType field_type = type.field_type(); 78 AutoFillFieldType field_type = type.field_type();
60 if (field_type == GetNumberType()) 79 if (field_type == GetNumberType())
61 return number(); 80 return number();
62 81
63 if (field_type == GetCityCodeType()) 82 if (field_type == GetCityCodeType())
64 return city_code(); 83 return city_code();
65 84
66 if (field_type == GetCountryCodeType()) 85 if (field_type == GetCountryCodeType())
67 return country_code(); 86 return country_code();
68 87
69 if (field_type == GetCityAndNumberType()) 88 if (field_type == GetCityAndNumberType())
70 return CityAndNumber(); 89 return CityAndNumber();
71 90
72 if (field_type == GetWholeNumberType()) 91 if (field_type == GetWholeNumberType())
73 return WholeNumber(); 92 return WholeNumber();
74 93
75 return EmptyString16(); 94 return string16();
76 } 95 }
77 96
78 void PhoneNumber::FindInfoMatches(const AutoFillType& type, 97 void PhoneNumber::FindInfoMatches(const AutoFillType& type,
79 const string16& info, 98 const string16& info,
80 std::vector<string16>* matched_text) const { 99 std::vector<string16>* matched_text) const {
81 if (matched_text == NULL) { 100 if (matched_text == NULL) {
82 DLOG(ERROR) << "NULL matched vector passed in"; 101 DLOG(ERROR) << "NULL matched vector passed in";
83 return; 102 return;
84 } 103 }
85 104
(...skipping 20 matching lines...)
106 if (!Validate(number)) 125 if (!Validate(number))
107 return; 126 return;
108 127
109 FieldTypeSubGroup subgroup = type.subgroup(); 128 FieldTypeSubGroup subgroup = type.subgroup();
110 if (subgroup == AutoFillType::PHONE_NUMBER) 129 if (subgroup == AutoFillType::PHONE_NUMBER)
111 set_number(number); 130 set_number(number);
112 else if (subgroup == AutoFillType::PHONE_CITY_CODE) 131 else if (subgroup == AutoFillType::PHONE_CITY_CODE)
113 set_city_code(number); 132 set_city_code(number);
114 else if (subgroup == AutoFillType::PHONE_COUNTRY_CODE) 133 else if (subgroup == AutoFillType::PHONE_COUNTRY_CODE)
115 set_country_code(number); 134 set_country_code(number);
116 else if (subgroup == AutoFillType::PHONE_WHOLE_NUMBER) 135 else if (subgroup == AutoFillType::PHONE_CITY_AND_NUMBER ||
136 subgroup == AutoFillType::PHONE_WHOLE_NUMBER)
117 set_whole_number(number); 137 set_whole_number(number);
118 else 138 else
119 NOTREACHED(); 139 NOTREACHED();
120 } 140 }
121 141
122 // Static. 142 // Static.
123 bool PhoneNumber::ParsePhoneNumber(const string16& value, 143 bool PhoneNumber::ParsePhoneNumber(const string16& value,
124 string16* number, 144 string16* number,
125 string16* city_code, 145 string16* city_code,
126 string16* country_code) { 146 string16* country_code) {
(...skipping 141 matching lines...)
268 return false; 288 return false;
269 } 289 }
270 290
271 return true; 291 return true;
272 } 292 }
273 293
274 // Static. 294 // Static.
275 void PhoneNumber::StripPunctuation(string16* number) { 295 void PhoneNumber::StripPunctuation(string16* number) {
276 RemoveChars(*number, kPhoneNumberSeparators, number); 296 RemoveChars(*number, kPhoneNumberSeparators, number);
277 } 297 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/phone_number.h ('k') | chrome/browser/sync/glue/synchronized_preferences.h » ('j') | no next file with comments »

Powered by Google App Engine