| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/common/android/address_parser.h" | 5 #include "content/common/android/address_parser.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "content/common/android/address_parser_internal.h" | 9 #include "content/common/android/address_parser_internal.h" |
| 10 | 10 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 &tokenizer, &state_index)) { | 164 &tokenizer, &state_index)) { |
| 165 | 165 |
| 166 // A location name should have been found at this point. | 166 // A location name should have been found at this point. |
| 167 if (!found_location_name) | 167 if (!found_location_name) |
| 168 break; | 168 break; |
| 169 | 169 |
| 170 // Explicitly exclude "et al", as "al" is a valid state code. | 170 // Explicitly exclude "et al", as "al" is a valid state code. |
| 171 if (current_word_length == 2 && words.size() > 2) { | 171 if (current_word_length == 2 && words.size() > 2) { |
| 172 const Word& previous_word = words[state_first_word - 1]; | 172 const Word& previous_word = words[state_first_word - 1]; |
| 173 if (previous_word.end - previous_word.begin == 2 && | 173 if (previous_word.end - previous_word.begin == 2 && |
| 174 LowerCaseEqualsASCII(previous_word.begin, previous_word.end, | 174 base::LowerCaseEqualsASCII(previous_word.begin, |
| 175 "et") && | 175 previous_word.end, |
| 176 LowerCaseEqualsASCII(current_word.begin, current_word.end, | 176 "et") && |
| 177 "al")) | 177 base::LowerCaseEqualsASCII(current_word.begin, |
| 178 current_word.end, |
| 179 "al")) |
| 178 break; | 180 break; |
| 179 } | 181 } |
| 180 | 182 |
| 181 // Extract one more word from the tokenizer if not already available. | 183 // Extract one more word from the tokenizer if not already available. |
| 182 size_t zip_word = state_last_word + 1; | 184 size_t zip_word = state_last_word + 1; |
| 183 if (zip_word == words.size()) { | 185 if (zip_word == words.size()) { |
| 184 do { | 186 do { |
| 185 if (!tokenizer.GetNext()) { | 187 if (!tokenizer.GetNext()) { |
| 186 // The address ends with a state name without a zip code. This | 188 // The address ends with a state name without a zip code. This |
| 187 // is legal according to WebView#findAddress public | 189 // is legal according to WebView#findAddress public |
| (...skipping 29 matching lines...) Expand all Loading... |
| 217 it = words[next_word].end; | 219 it = words[next_word].end; |
| 218 } | 220 } |
| 219 } | 221 } |
| 220 | 222 |
| 221 return false; | 223 return false; |
| 222 } | 224 } |
| 223 | 225 |
| 224 } // namespace address_parser | 226 } // namespace address_parser |
| 225 | 227 |
| 226 } // namespace content | 228 } // namespace content |
| OLD | NEW |