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

Side by Side Diff: components/autofill/browser/phone_number.h

Issue 13973004: Convert string16 -> base::string16 in components/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 COMPONENTS_AUTOFILL_BROWSER_PHONE_NUMBER_H_ 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_PHONE_NUMBER_H_
6 #define COMPONENTS_AUTOFILL_BROWSER_PHONE_NUMBER_H_ 6 #define COMPONENTS_AUTOFILL_BROWSER_PHONE_NUMBER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 10 matching lines...) Expand all
21 public: 21 public:
22 explicit PhoneNumber(AutofillProfile* profile); 22 explicit PhoneNumber(AutofillProfile* profile);
23 PhoneNumber(const PhoneNumber& number); 23 PhoneNumber(const PhoneNumber& number);
24 virtual ~PhoneNumber(); 24 virtual ~PhoneNumber();
25 25
26 PhoneNumber& operator=(const PhoneNumber& number); 26 PhoneNumber& operator=(const PhoneNumber& number);
27 27
28 void set_profile(AutofillProfile* profile) { profile_ = profile; } 28 void set_profile(AutofillProfile* profile) { profile_ = profile; }
29 29
30 // FormGroup implementation: 30 // FormGroup implementation:
31 virtual void GetMatchingTypes(const string16& text, 31 virtual void GetMatchingTypes(const base::string16& text,
32 const std::string& app_locale, 32 const std::string& app_locale,
33 FieldTypeSet* matching_types) const OVERRIDE; 33 FieldTypeSet* matching_types) const OVERRIDE;
34 virtual string16 GetRawInfo(AutofillFieldType type) const OVERRIDE; 34 virtual base::string16 GetRawInfo(AutofillFieldType type) const OVERRIDE;
35 virtual void SetRawInfo(AutofillFieldType type, 35 virtual void SetRawInfo(AutofillFieldType type,
36 const string16& value) OVERRIDE; 36 const base::string16& value) OVERRIDE;
37 virtual string16 GetInfo(AutofillFieldType type, 37 virtual base::string16 GetInfo(AutofillFieldType type,
38 const std::string& app_locale) const OVERRIDE; 38 const std::string& app_locale) const OVERRIDE;
39 virtual bool SetInfo(AutofillFieldType type, 39 virtual bool SetInfo(AutofillFieldType type,
40 const string16& value, 40 const base::string16& value,
41 const std::string& app_locale) OVERRIDE; 41 const std::string& app_locale) OVERRIDE;
42 42
43 // Size and offset of the prefix and suffix portions of phone numbers. 43 // Size and offset of the prefix and suffix portions of phone numbers.
44 static const size_t kPrefixOffset = 0; 44 static const size_t kPrefixOffset = 0;
45 static const size_t kPrefixLength = 3; 45 static const size_t kPrefixLength = 3;
46 static const size_t kSuffixOffset = 3; 46 static const size_t kSuffixOffset = 3;
47 static const size_t kSuffixLength = 4; 47 static const size_t kSuffixLength = 4;
48 48
49 // The class used to combine home phone parts into a whole number. 49 // The class used to combine home phone parts into a whole number.
50 class PhoneCombineHelper { 50 class PhoneCombineHelper {
51 public: 51 public:
52 PhoneCombineHelper(); 52 PhoneCombineHelper();
53 ~PhoneCombineHelper(); 53 ~PhoneCombineHelper();
54 54
55 // If |type| is a phone field type, saves the |value| accordingly and 55 // If |type| is a phone field type, saves the |value| accordingly and
56 // returns true. For all other field types returs false. 56 // returns true. For all other field types returs false.
57 bool SetInfo(AutofillFieldType type, const string16& value); 57 bool SetInfo(AutofillFieldType type, const base::string16& value);
58 58
59 // Parses the number built up from pieces stored via SetInfo() according to 59 // Parses the number built up from pieces stored via SetInfo() according to
60 // the specified |profile|'s country code, falling back to the given 60 // the specified |profile|'s country code, falling back to the given
61 // |app_locale| if the |profile| has no associated country code. Returns 61 // |app_locale| if the |profile| has no associated country code. Returns
62 // true if parsing was successful, false otherwise. 62 // true if parsing was successful, false otherwise.
63 bool ParseNumber(const AutofillProfile& profile, 63 bool ParseNumber(const AutofillProfile& profile,
64 const std::string& app_locale, 64 const std::string& app_locale,
65 string16* value); 65 base::string16* value);
66 66
67 // Returns true if both |phone_| and |whole_number_| are empty. 67 // Returns true if both |phone_| and |whole_number_| are empty.
68 bool IsEmpty() const; 68 bool IsEmpty() const;
69 69
70 private: 70 private:
71 string16 country_; 71 base::string16 country_;
72 string16 city_; 72 base::string16 city_;
73 string16 phone_; 73 base::string16 phone_;
74 string16 whole_number_; 74 base::string16 whole_number_;
75 }; 75 };
76 76
77 private: 77 private:
78 // FormGroup: 78 // FormGroup:
79 virtual void GetSupportedTypes(FieldTypeSet* supported_types) const OVERRIDE; 79 virtual void GetSupportedTypes(FieldTypeSet* supported_types) const OVERRIDE;
80 80
81 // Updates the cached parsed number if the profile's region has changed 81 // Updates the cached parsed number if the profile's region has changed
82 // since the last time the cache was updated. 82 // since the last time the cache was updated.
83 void UpdateCacheIfNeeded(const std::string& app_locale) const; 83 void UpdateCacheIfNeeded(const std::string& app_locale) const;
84 84
85 // The phone number. 85 // The phone number.
86 string16 number_; 86 base::string16 number_;
87 // Profile which stores the region used as hint when normalizing the number. 87 // Profile which stores the region used as hint when normalizing the number.
88 const AutofillProfile* profile_; // WEAK 88 const AutofillProfile* profile_; // WEAK
89 89
90 // Cached number. 90 // Cached number.
91 mutable autofill_i18n::PhoneObject cached_parsed_phone_; 91 mutable autofill_i18n::PhoneObject cached_parsed_phone_;
92 }; 92 };
93 93
94 #endif // COMPONENTS_AUTOFILL_BROWSER_PHONE_NUMBER_H_ 94 #endif // COMPONENTS_AUTOFILL_BROWSER_PHONE_NUMBER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698