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

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

Issue 448143008: Move StringToUpperASCII and LowerCaseEqualsASCII to the base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 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/state_names.h" 5 #include "components/autofill/core/browser/state_names.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 10
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 { "west virginia", "wv" }, 73 { "west virginia", "wv" },
74 { "wisconsin", "wi" }, 74 { "wisconsin", "wi" },
75 { "wyoming", "wy" }, 75 { "wyoming", "wy" },
76 }; 76 };
77 77
78 } // namespace 78 } // namespace
79 79
80 base::string16 GetAbbreviationForName(const base::string16& name) { 80 base::string16 GetAbbreviationForName(const base::string16& name) {
81 for (size_t i = 0; i < arraysize(kStateData); ++i) { 81 for (size_t i = 0; i < arraysize(kStateData); ++i) {
82 const StateData& state = kStateData[i]; 82 const StateData& state = kStateData[i];
83 if (LowerCaseEqualsASCII(name, state.name)) 83 if (base::LowerCaseEqualsASCII(name, state.name))
84 return base::ASCIIToUTF16(state.abbreviation); 84 return base::ASCIIToUTF16(state.abbreviation);
85 } 85 }
86 return base::string16(); 86 return base::string16();
87 } 87 }
88 88
89 base::string16 GetNameForAbbreviation(const base::string16& abbreviation) { 89 base::string16 GetNameForAbbreviation(const base::string16& abbreviation) {
90 for (size_t i = 0; i < arraysize(kStateData); ++i) { 90 for (size_t i = 0; i < arraysize(kStateData); ++i) {
91 const StateData& state = kStateData[i]; 91 const StateData& state = kStateData[i];
92 if (LowerCaseEqualsASCII(abbreviation, state.abbreviation)) 92 if (base::LowerCaseEqualsASCII(abbreviation, state.abbreviation))
93 return base::ASCIIToUTF16(state.name); 93 return base::ASCIIToUTF16(state.name);
94 } 94 }
95 return base::string16(); 95 return base::string16();
96 } 96 }
97 97
98 void GetNameAndAbbreviation(const base::string16& value, 98 void GetNameAndAbbreviation(const base::string16& value,
99 base::string16* name, 99 base::string16* name,
100 base::string16* abbreviation) { 100 base::string16* abbreviation) {
101 base::string16 full = GetNameForAbbreviation(value); 101 base::string16 full = GetNameForAbbreviation(value);
102 base::string16 abbr = value; 102 base::string16 abbr = value;
103 if (full.empty()) { 103 if (full.empty()) {
104 abbr = GetAbbreviationForName(value); 104 abbr = GetAbbreviationForName(value);
105 full = value; 105 full = value;
106 } 106 }
107 107
108 if (name) 108 if (name)
109 name->swap(full); 109 name->swap(full);
110 if (abbreviation) 110 if (abbreviation)
111 abbreviation->swap(abbr); 111 abbreviation->swap(abbr);
112 } 112 }
113 113
114 } // namespace state_names 114 } // namespace state_names
115 } // namespace autofill 115 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698