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

Side by Side Diff: components/autofill/browser/state_names.cc

Issue 17392006: In components/autofill, move browser/ to core/browser/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to fix conflicts Created 7 years, 6 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/autofill/browser/state_names.h"
6
7 #include "base/basictypes.h"
8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h"
10
11 namespace autofill {
12 namespace state_names {
13
14 namespace {
15
16 // TODO(jhawkins): Add more states/provinces. See http://crbug.com/45039.
17
18 struct StateData {
19 const char* const name;
20 const char abbreviation[3];
21 };
22
23 StateData kStateData[] = {
24 { "alabama", "al" },
25 { "alaska", "ak" },
26 { "arizona", "az" },
27 { "arkansas", "ar" },
28 { "california", "ca" },
29 { "colorado", "co" },
30 { "connecticut", "ct" },
31 { "delaware", "de" },
32 { "district of columbia", "dc" },
33 { "florida", "fl" },
34 { "georgia", "ga" },
35 { "hawaii", "hi" },
36 { "idaho", "id" },
37 { "illinois", "il" },
38 { "indiana", "in" },
39 { "iowa", "ia" },
40 { "kansas", "ks" },
41 { "kentucky", "ky" },
42 { "louisiana", "la" },
43 { "maine", "me" },
44 { "maryland", "md" },
45 { "massachusetts", "ma" },
46 { "michigan", "mi" },
47 { "minnesota", "mv" },
48 { "mississippi", "ms" },
49 { "missouri", "mo" },
50 { "montana", "mt" },
51 { "nebraska", "ne" },
52 { "nevada", "nv" },
53 { "new hampshire", "nh" },
54 { "new jersey", "nj" },
55 { "new mexico", "nm" },
56 { "new york", "ny" },
57 { "north carolina", "nc" },
58 { "north dakota", "nd" },
59 { "ohio", "oh" },
60 { "oklahoma", "ok" },
61 { "oregon", "or" },
62 { "pennsylvania", "pa" },
63 { "puerto rico", "pr" },
64 { "rhode island", "ri" },
65 { "south carolina", "sc" },
66 { "south dakota", "sd" },
67 { "tennessee", "tn" },
68 { "texas", "tx" },
69 { "utah", "ut" },
70 { "vermont", "vt" },
71 { "virginia", "va" },
72 { "washington", "wa" },
73 { "west virginia", "wv" },
74 { "wisconsin", "wi" },
75 { "wyoming", "wy" },
76 };
77
78 } // namespace
79
80 base::string16 GetAbbreviationForName(const base::string16& name) {
81 for (size_t i = 0; i < arraysize(kStateData); ++i) {
82 const StateData& state = kStateData[i];
83 if (LowerCaseEqualsASCII(name, state.name))
84 return ASCIIToUTF16(state.abbreviation);
85 }
86 return base::string16();
87 }
88
89 base::string16 GetNameForAbbreviation(const base::string16& abbreviation) {
90 for (size_t i = 0; i < arraysize(kStateData); ++i) {
91 const StateData& state = kStateData[i];
92 if (LowerCaseEqualsASCII(abbreviation, state.abbreviation))
93 return ASCIIToUTF16(state.name);
94 }
95 return base::string16();
96 }
97
98 void GetNameAndAbbreviation(const base::string16& value,
99 base::string16* name,
100 base::string16* abbreviation) {
101 base::string16 full = GetNameForAbbreviation(value);
102 base::string16 abbr = value;
103 if (full.empty()) {
104 abbr = GetAbbreviationForName(value);
105 full = value;
106 }
107
108 if (name)
109 name->swap(full);
110 if (abbreviation)
111 abbreviation->swap(abbr);
112 }
113
114 } // namespace state_names
115 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/browser/state_names.h ('k') | components/autofill/browser/test_autofill_driver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698