OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/autofill/core/browser/phone_number_i18n.h" | 5 #include "components/autofill/core/browser/phone_number_i18n.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 } else { | 246 } else { |
247 // Parsing failed. Store passed phone "as is" into |whole_number_|. | 247 // Parsing failed. Store passed phone "as is" into |whole_number_|. |
248 whole_number_ = number; | 248 whole_number_ = number; |
249 } | 249 } |
250 } | 250 } |
251 | 251 |
252 PhoneObject::PhoneObject(const PhoneObject& other) { *this = other; } | 252 PhoneObject::PhoneObject(const PhoneObject& other) { *this = other; } |
253 | 253 |
254 PhoneObject::PhoneObject() {} | 254 PhoneObject::PhoneObject() {} |
255 | 255 |
256 PhoneObject::~PhoneObject() { | 256 PhoneObject::~PhoneObject() {} |
257 } | |
258 | 257 |
259 base::string16 PhoneObject::GetFormattedNumber() const { | 258 base::string16 PhoneObject::GetFormattedNumber() const { |
260 if (i18n_number_ && formatted_number_.empty()) { | 259 if (i18n_number_ && formatted_number_.empty()) { |
261 FormatValidatedNumber(*i18n_number_, country_code_, &formatted_number_, | 260 FormatValidatedNumber(*i18n_number_, country_code_, &formatted_number_, |
262 &whole_number_); | 261 &whole_number_); |
263 } | 262 } |
264 | 263 |
265 return formatted_number_; | 264 return formatted_number_; |
266 } | 265 } |
267 | 266 |
| 267 base::string16 PhoneObject::GetNationallyFormattedNumber() const { |
| 268 base::string16 formatted = whole_number_; |
| 269 if (i18n_number_) |
| 270 FormatValidatedNumber(*i18n_number_, base::string16(), &formatted, NULL); |
| 271 |
| 272 return formatted; |
| 273 } |
| 274 |
268 base::string16 PhoneObject::GetWholeNumber() const { | 275 base::string16 PhoneObject::GetWholeNumber() const { |
269 if (i18n_number_ && whole_number_.empty()) { | 276 if (i18n_number_ && whole_number_.empty()) { |
270 FormatValidatedNumber(*i18n_number_, country_code_, &formatted_number_, | 277 FormatValidatedNumber(*i18n_number_, country_code_, &formatted_number_, |
271 &whole_number_); | 278 &whole_number_); |
272 } | 279 } |
273 | 280 |
274 return whole_number_; | 281 return whole_number_; |
275 } | 282 } |
276 | 283 |
277 PhoneObject& PhoneObject::operator=(const PhoneObject& other) { | 284 PhoneObject& PhoneObject::operator=(const PhoneObject& other) { |
(...skipping 12 matching lines...) Expand all Loading... |
290 number_ = other.number_; | 297 number_ = other.number_; |
291 | 298 |
292 formatted_number_ = other.formatted_number_; | 299 formatted_number_ = other.formatted_number_; |
293 whole_number_ = other.whole_number_; | 300 whole_number_ = other.whole_number_; |
294 | 301 |
295 return *this; | 302 return *this; |
296 } | 303 } |
297 | 304 |
298 } // namespace i18n | 305 } // namespace i18n |
299 } // namespace autofill | 306 } // namespace autofill |
OLD | NEW |