// Copyright 2013 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_DATA_MODEL_PHONE_NUMBER_H_ #define COMPONENTS_AUTOFILL_CORE_BROWSER_DATA_MODEL_PHONE_NUMBER_H_ #include <stddef.h> #include <string> #include "base/memory/raw_ptr.h" #include "components/autofill/core/browser/data_model/form_group.h" #include "components/autofill/core/browser/geo/phone_number_i18n.h" namespace autofill { class AutofillProfile; // A form group that stores phone number information. // // The behavior of PhoneNumber is quite complex because of different // representations of phone numbers (national and international formats) and the // number of field types. See components/autofill/core/browser/field_types.h for // an introduction to the semantic field types. // // The PhoneNumber/PhoneImportAndGetTest.TestSettingAndParsing unittests may be // best to see the exact behavior of learning phone numbers from submitted forms // and filling phone numbers into new forms. // // If no country code is submitted (as a separate PHONE_HOME_COUNTRY_CODE field // or as part of a PHONE_HOME_WHOLE_NUMBER or PHONE_HOME_CITY_AND_NUMBER) at // form submission time, no attempt is made to save one. As a consequence, we // cannot fill country code fields nor international phone number fields with // the country code. See b/322330285. // // Phone numbers of form submissions are validated by libphonenumber for // plausibility before getting saved (in the context of the country, which is // the first of 1) country in the form, 2) country of GeoIP, 3) country of // locale). Phone numbers from form submissions are stored in a formatted way // unless they were submitted in a PHONE_HOME_WHOLE_NUMBER field and already // contained formatting characters (whitespaces, parentheses, slashes, hyphens, // ...). // // At filling time, the stored number is interpreted and, if successful, the // relevant pieces are returned. The values used for filling consist only of // [+0123456789]. Whitespaces, parentheses, slashes, hyphens, ... are stripped. // International numbers filled as PHONE_HOME_WHOLE_NUMBER start with a + in all // countries but the US, where the + is dropped. class PhoneNumber : public FormGroup { … }; } // namespace autofill #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_DATA_MODEL_PHONE_NUMBER_H_