OLD | NEW |
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 CHROME_BROWSER_AUTOFILL_ADDRESS_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_ADDRESS_H_ |
6 #define CHROME_BROWSER_AUTOFILL_ADDRESS_H_ | 6 #define CHROME_BROWSER_AUTOFILL_ADDRESS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include <string> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/string16.h" | 12 #include "base/string16.h" |
12 #include "chrome/browser/autofill/form_group.h" | 13 #include "chrome/browser/autofill/form_group.h" |
13 | 14 |
14 // A form group that stores address information. | 15 // A form group that stores address information. |
15 class Address : public FormGroup { | 16 class Address : public FormGroup { |
16 public: | 17 public: |
17 Address(); | 18 Address(); |
18 virtual ~Address(); | 19 virtual ~Address(); |
19 | 20 |
20 // FormGroup: | 21 // FormGroup: |
21 virtual FormGroup* Clone() const; | 22 virtual FormGroup* Clone() const; |
22 virtual void GetPossibleFieldTypes(const string16& text, | 23 virtual void GetPossibleFieldTypes(const string16& text, |
23 FieldTypeSet* possible_types) const; | 24 FieldTypeSet* possible_types) const; |
24 virtual void GetAvailableFieldTypes(FieldTypeSet* available_types) const; | 25 virtual void GetAvailableFieldTypes(FieldTypeSet* available_types) const; |
25 virtual void FindInfoMatches(const AutoFillType& type, | 26 virtual void FindInfoMatches(const AutoFillType& type, |
26 const string16& info, | 27 const string16& info, |
27 std::vector<string16>* matched_text) const; | 28 std::vector<string16>* matched_text) const; |
28 virtual string16 GetFieldText(const AutoFillType& type) const; | 29 virtual string16 GetFieldText(const AutoFillType& type) const; |
29 virtual void SetInfo(const AutoFillType& type, const string16& value); | 30 virtual void SetInfo(const AutoFillType& type, const string16& value); |
30 | 31 |
| 32 const std::string& country_code() const { return country_code_; } |
| 33 void set_country_code(const std::string& country_code) { |
| 34 country_code_ = country_code; |
| 35 } |
| 36 |
31 // Sets all of the fields to the empty string. | 37 // Sets all of the fields to the empty string. |
32 void Clear(); | 38 void Clear(); |
33 | 39 |
34 private: | 40 private: |
35 // Vector of tokens in an address line. | 41 // Vector of tokens in an address line. |
36 typedef std::vector<string16> LineTokens; | 42 typedef std::vector<string16> LineTokens; |
37 | 43 |
38 explicit Address(const Address& address); | 44 explicit Address(const Address& address); |
39 | 45 |
40 void operator=(const Address& address); | 46 void operator=(const Address& address); |
41 | 47 |
| 48 // Returns the localized country name corresponding to |country_code_|. |
| 49 string16 Country() const; |
| 50 |
42 void set_line1(const string16& line1); | 51 void set_line1(const string16& line1); |
43 void set_line2(const string16& line2); | 52 void set_line2(const string16& line2); |
44 | 53 |
| 54 // Sets the |country_code_| based on |country|, which should be a localized |
| 55 // country name. |
| 56 void SetCountry(const string16& country); |
| 57 |
45 // The following functions match |text| against the various values of the | 58 // The following functions match |text| against the various values of the |
46 // address, returning true on match. | 59 // address, returning true on match. |
47 virtual bool IsLine1(const string16& text) const; | 60 virtual bool IsLine1(const string16& text) const; |
48 virtual bool IsLine2(const string16& text) const; | 61 virtual bool IsLine2(const string16& text) const; |
49 virtual bool IsCity(const string16& text) const; | 62 virtual bool IsCity(const string16& text) const; |
50 virtual bool IsState(const string16& text) const; | 63 virtual bool IsState(const string16& text) const; |
51 virtual bool IsCountry(const string16& text) const; | 64 virtual bool IsCountry(const string16& text) const; |
52 virtual bool IsZipCode(const string16& text) const; | 65 virtual bool IsZipCode(const string16& text) const; |
53 | 66 |
54 // A helper function for FindInfoMatches that only handles matching |info| | 67 // A helper function for FindInfoMatches that only handles matching |info| |
(...skipping 11 matching lines...) Expand all Loading... |
66 | 79 |
67 // List of tokens in each part of |line1_| and |line2_|. | 80 // List of tokens in each part of |line1_| and |line2_|. |
68 LineTokens line1_tokens_; | 81 LineTokens line1_tokens_; |
69 LineTokens line2_tokens_; | 82 LineTokens line2_tokens_; |
70 | 83 |
71 // The address. | 84 // The address. |
72 string16 line1_; | 85 string16 line1_; |
73 string16 line2_; | 86 string16 line2_; |
74 string16 city_; | 87 string16 city_; |
75 string16 state_; | 88 string16 state_; |
76 string16 country_; | 89 std::string country_code_; |
77 string16 zip_code_; | 90 string16 zip_code_; |
78 }; | 91 }; |
79 | 92 |
80 #endif // CHROME_BROWSER_AUTOFILL_ADDRESS_H_ | 93 #endif // CHROME_BROWSER_AUTOFILL_ADDRESS_H_ |
OLD | NEW |