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

Side by Side Diff: chrome/browser/autofill/autofill_country.cc

Issue 6484022: Autofill i18n: Set postal code and state field labels based on the selected country. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: I see you, ICU Created 9 years, 10 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 (c) 2011 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 "chrome/browser/autofill/autofill_country.h"
6
7 #include <map>
8 #include <utility>
9
10 #include "base/logging.h"
11 #include "base/singleton.h"
12 #include "base/utf_string_conversions.h"
James Hawkins 2011/02/12 20:32:45 Is this header used?
Ilya Sherman 2011/02/16 10:27:18 It was, then it wasn't, and now it is again. Well
13 #include "chrome/browser/browser_process.h"
14 #include "grit/generated_resources.h"
15 #include "ui/base/l10n/l10n_util.h"
16 #include "third_party/icu/public/common/unicode/locid.h"
James Hawkins 2011/02/12 20:32:45 't' before 'u'.
Ilya Sherman 2011/02/16 10:27:18 Done.
17
18 namespace {
19
20 struct AutoFillCountryData {
21 std::string country_code;
22 int postal_code_label_id;
23 int state_label_id;
24 };
25
26 const AutoFillCountryData kCountryData[] = {
27 {
28 "AD",
29 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
30 IDS_AUTOFILL_DIALOG_PARISH
31 },
32 {
33 "AE",
34 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
35 IDS_AUTOFILL_DIALOG_EMIRATE
36 },
37 {
38 "AF",
39 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
40 IDS_AUTOFILL_DIALOG_PROVINCE
41 },
42 {
43 "AG",
44 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
45 IDS_AUTOFILL_DIALOG_PROVINCE
46 },
47 {
48 "AI",
49 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
50 IDS_AUTOFILL_DIALOG_PROVINCE
51 },
52 {
53 "AL",
54 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
55 IDS_AUTOFILL_DIALOG_PROVINCE
56 },
57 {
58 "AM",
59 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
60 IDS_AUTOFILL_DIALOG_PROVINCE
61 },
62 {
63 "AN",
64 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
65 IDS_AUTOFILL_DIALOG_PROVINCE
66 },
67 {
68 "AO",
69 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
70 IDS_AUTOFILL_DIALOG_PROVINCE
71 },
72 {
73 "AQ",
74 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
75 IDS_AUTOFILL_DIALOG_PROVINCE
76 },
77 {
78 "AR",
79 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
80 IDS_AUTOFILL_DIALOG_STATE
81 },
82 {
83 "AS",
84 IDS_AUTOFILL_DIALOG_ZIP_CODE,
85 IDS_AUTOFILL_DIALOG_STATE
86 },
87 {
88 "AT",
89 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
90 IDS_AUTOFILL_DIALOG_PROVINCE
91 },
92 {
93 "AU",
94 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
95 IDS_AUTOFILL_DIALOG_STATE
96 },
97 {
98 "AW",
99 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
100 IDS_AUTOFILL_DIALOG_PROVINCE
101 },
102 {
103 "AX",
104 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
105 IDS_AUTOFILL_DIALOG_PROVINCE
106 },
107 {
108 "AZ",
109 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
110 IDS_AUTOFILL_DIALOG_PROVINCE
111 },
112 {
113 "BA",
114 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
115 IDS_AUTOFILL_DIALOG_PROVINCE
116 },
117 {
118 "BB",
119 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
120 IDS_AUTOFILL_DIALOG_PARISH
121 },
122 {
123 "BD",
124 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
125 IDS_AUTOFILL_DIALOG_PROVINCE
126 },
127 {
128 "BE",
129 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
130 IDS_AUTOFILL_DIALOG_PROVINCE
131 },
132 {
133 "BF",
134 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
135 IDS_AUTOFILL_DIALOG_PROVINCE
136 },
137 {
138 "BG",
139 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
140 IDS_AUTOFILL_DIALOG_PROVINCE
141 },
142 {
143 "BH",
144 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
145 IDS_AUTOFILL_DIALOG_PROVINCE
146 },
147 {
148 "BI",
149 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
150 IDS_AUTOFILL_DIALOG_PROVINCE
151 },
152 {
153 "BJ",
154 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
155 IDS_AUTOFILL_DIALOG_PROVINCE
156 },
157 {
158 "BL",
159 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
160 IDS_AUTOFILL_DIALOG_PROVINCE
161 },
162 {
163 "BM",
164 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
165 IDS_AUTOFILL_DIALOG_PROVINCE
166 },
167 {
168 "BN",
169 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
170 IDS_AUTOFILL_DIALOG_PROVINCE
171 },
172 {
173 "BO",
174 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
175 IDS_AUTOFILL_DIALOG_PROVINCE
176 },
177 {
178 "BR",
179 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
180 IDS_AUTOFILL_DIALOG_STATE
181 },
182 {
183 "BS",
184 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
185 IDS_AUTOFILL_DIALOG_ISLAND
186 },
187 {
188 "BT",
189 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
190 IDS_AUTOFILL_DIALOG_PROVINCE
191 },
192 {
193 "BV",
194 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
195 IDS_AUTOFILL_DIALOG_PROVINCE
196 },
197 {
198 "BW",
199 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
200 IDS_AUTOFILL_DIALOG_PROVINCE
201 },
202 {
203 "BY",
204 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
205 IDS_AUTOFILL_DIALOG_PROVINCE
206 },
207 {
208 "BZ",
209 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
210 IDS_AUTOFILL_DIALOG_PROVINCE
211 },
212 {
213 "CA",
214 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
215 IDS_AUTOFILL_DIALOG_PROVINCE
216 },
217 {
218 "CC",
219 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
220 IDS_AUTOFILL_DIALOG_PROVINCE
221 },
222 {
223 "CD",
224 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
225 IDS_AUTOFILL_DIALOG_PROVINCE
226 },
227 {
228 "CF",
229 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
230 IDS_AUTOFILL_DIALOG_PROVINCE
231 },
232 {
233 "CG",
234 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
235 IDS_AUTOFILL_DIALOG_PROVINCE
236 },
237 {
238 "CH",
239 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
240 IDS_AUTOFILL_DIALOG_PROVINCE
241 },
242 {
243 "CI",
244 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
245 IDS_AUTOFILL_DIALOG_PROVINCE
246 },
247 {
248 "CK",
249 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
250 IDS_AUTOFILL_DIALOG_PROVINCE
251 },
252 {
253 "CL",
254 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
255 IDS_AUTOFILL_DIALOG_STATE
256 },
257 {
258 "CM",
259 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
260 IDS_AUTOFILL_DIALOG_PROVINCE
261 },
262 {
263 "CN",
264 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
265 IDS_AUTOFILL_DIALOG_PROVINCE
266 },
267 {
268 "CO",
269 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
270 IDS_AUTOFILL_DIALOG_PROVINCE
271 },
272 {
273 "CR",
274 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
275 IDS_AUTOFILL_DIALOG_PROVINCE
276 },
277 {
278 "CV",
279 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
280 IDS_AUTOFILL_DIALOG_ISLAND
281 },
282 {
283 "CX",
284 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
285 IDS_AUTOFILL_DIALOG_PROVINCE
286 },
287 {
288 "CY",
289 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
290 IDS_AUTOFILL_DIALOG_PROVINCE
291 },
292 {
293 "CZ",
294 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
295 IDS_AUTOFILL_DIALOG_PROVINCE
296 },
297 {
298 "DE",
299 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
300 IDS_AUTOFILL_DIALOG_PROVINCE
301 },
302 {
303 "DJ",
304 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
305 IDS_AUTOFILL_DIALOG_PROVINCE
306 },
307 {
308 "DK",
309 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
310 IDS_AUTOFILL_DIALOG_PROVINCE
311 },
312 {
313 "DM",
314 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
315 IDS_AUTOFILL_DIALOG_PROVINCE
316 },
317 {
318 "DO",
319 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
320 IDS_AUTOFILL_DIALOG_PROVINCE
321 },
322 {
323 "DZ",
324 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
325 IDS_AUTOFILL_DIALOG_PROVINCE
326 },
327 {
328 "EC",
329 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
330 IDS_AUTOFILL_DIALOG_PROVINCE
331 },
332 {
333 "EE",
334 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
335 IDS_AUTOFILL_DIALOG_PROVINCE
336 },
337 {
338 "EG",
339 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
340 IDS_AUTOFILL_DIALOG_PROVINCE
341 },
342 {
343 "EH",
344 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
345 IDS_AUTOFILL_DIALOG_PROVINCE
346 },
347 {
348 "ER",
349 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
350 IDS_AUTOFILL_DIALOG_PROVINCE
351 },
352 {
353 "ES",
354 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
355 IDS_AUTOFILL_DIALOG_PROVINCE
356 },
357 {
358 "ET",
359 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
360 IDS_AUTOFILL_DIALOG_PROVINCE
361 },
362 {
363 "FI",
364 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
365 IDS_AUTOFILL_DIALOG_PROVINCE
366 },
367 {
368 "FJ",
369 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
370 IDS_AUTOFILL_DIALOG_PROVINCE
371 },
372 {
373 "FK",
374 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
375 IDS_AUTOFILL_DIALOG_PROVINCE
376 },
377 {
378 "FM",
379 IDS_AUTOFILL_DIALOG_ZIP_CODE,
380 IDS_AUTOFILL_DIALOG_STATE
381 },
382 {
383 "FO",
384 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
385 IDS_AUTOFILL_DIALOG_PROVINCE
386 },
387 {
388 "FR",
389 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
390 IDS_AUTOFILL_DIALOG_PROVINCE
391 },
392 {
393 "GA",
394 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
395 IDS_AUTOFILL_DIALOG_PROVINCE
396 },
397 {
398 "GB",
399 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
400 IDS_AUTOFILL_DIALOG_COUNTY
401 },
402 {
403 "GD",
404 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
405 IDS_AUTOFILL_DIALOG_PROVINCE
406 },
407 {
408 "GE",
409 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
410 IDS_AUTOFILL_DIALOG_PROVINCE
411 },
412 {
413 "GF",
414 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
415 IDS_AUTOFILL_DIALOG_PROVINCE
416 },
417 {
418 "GG",
419 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
420 IDS_AUTOFILL_DIALOG_PROVINCE
421 },
422 {
423 "GH",
424 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
425 IDS_AUTOFILL_DIALOG_PROVINCE
426 },
427 {
428 "GI",
429 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
430 IDS_AUTOFILL_DIALOG_PROVINCE
431 },
432 {
433 "GL",
434 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
435 IDS_AUTOFILL_DIALOG_PROVINCE
436 },
437 {
438 "GM",
439 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
440 IDS_AUTOFILL_DIALOG_PROVINCE
441 },
442 {
443 "GN",
444 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
445 IDS_AUTOFILL_DIALOG_PROVINCE
446 },
447 {
448 "GP",
449 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
450 IDS_AUTOFILL_DIALOG_PROVINCE
451 },
452 {
453 "GQ",
454 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
455 IDS_AUTOFILL_DIALOG_PROVINCE
456 },
457 {
458 "GR",
459 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
460 IDS_AUTOFILL_DIALOG_PROVINCE
461 },
462 {
463 "GS",
464 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
465 IDS_AUTOFILL_DIALOG_PROVINCE
466 },
467 {
468 "GT",
469 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
470 IDS_AUTOFILL_DIALOG_PROVINCE
471 },
472 {
473 "GU",
474 IDS_AUTOFILL_DIALOG_ZIP_CODE,
475 IDS_AUTOFILL_DIALOG_STATE
476 },
477 {
478 "GW",
479 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
480 IDS_AUTOFILL_DIALOG_PROVINCE
481 },
482 {
483 "GY",
484 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
485 IDS_AUTOFILL_DIALOG_PROVINCE
486 },
487 {
488 "HK",
489 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
490 IDS_AUTOFILL_DIALOG_AREA
491 },
492 {
493 "HM",
494 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
495 IDS_AUTOFILL_DIALOG_PROVINCE
496 },
497 {
498 "HN",
499 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
500 IDS_AUTOFILL_DIALOG_PROVINCE
501 },
502 {
503 "HR",
504 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
505 IDS_AUTOFILL_DIALOG_PROVINCE
506 },
507 {
508 "HT",
509 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
510 IDS_AUTOFILL_DIALOG_PROVINCE
511 },
512 {
513 "HU",
514 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
515 IDS_AUTOFILL_DIALOG_PROVINCE
516 },
517 {
518 "ID",
519 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
520 IDS_AUTOFILL_DIALOG_PROVINCE
521 },
522 {
523 "IE",
524 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
525 IDS_AUTOFILL_DIALOG_COUNTY
526 },
527 {
528 "IL",
529 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
530 IDS_AUTOFILL_DIALOG_PROVINCE
531 },
532 {
533 "IM",
534 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
535 IDS_AUTOFILL_DIALOG_PROVINCE
536 },
537 {
538 "IN",
539 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
540 IDS_AUTOFILL_DIALOG_STATE
541 },
542 {
543 "IO",
544 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
545 IDS_AUTOFILL_DIALOG_PROVINCE
546 },
547 {
548 "IQ",
549 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
550 IDS_AUTOFILL_DIALOG_PROVINCE
551 },
552 {
553 "IS",
554 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
555 IDS_AUTOFILL_DIALOG_PROVINCE
556 },
557 {
558 "IT",
559 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
560 IDS_AUTOFILL_DIALOG_PROVINCE
561 },
562 {
563 "JE",
564 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
565 IDS_AUTOFILL_DIALOG_PROVINCE
566 },
567 {
568 "JM",
569 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
570 IDS_AUTOFILL_DIALOG_PARISH
571 },
572 {
573 "JO",
574 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
575 IDS_AUTOFILL_DIALOG_PROVINCE
576 },
577 {
578 "JP",
579 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
580 IDS_AUTOFILL_DIALOG_PREFECTURE
581 },
582 {
583 "KE",
584 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
585 IDS_AUTOFILL_DIALOG_PROVINCE
586 },
587 {
588 "KG",
589 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
590 IDS_AUTOFILL_DIALOG_PROVINCE
591 },
592 {
593 "KH",
594 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
595 IDS_AUTOFILL_DIALOG_PROVINCE
596 },
597 {
598 "KI",
599 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
600 IDS_AUTOFILL_DIALOG_ISLAND
601 },
602 {
603 "KM",
604 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
605 IDS_AUTOFILL_DIALOG_PROVINCE
606 },
607 {
608 "KN",
609 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
610 IDS_AUTOFILL_DIALOG_ISLAND
611 },
612 {
613 "KP",
614 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
615 IDS_AUTOFILL_DIALOG_PROVINCE
616 },
617 {
618 "KR",
619 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
620 IDS_AUTOFILL_DIALOG_PROVINCE
621 },
622 {
623 "KW",
624 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
625 IDS_AUTOFILL_DIALOG_PROVINCE
626 },
627 {
628 "KY",
629 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
630 IDS_AUTOFILL_DIALOG_ISLAND
631 },
632 {
633 "KZ",
634 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
635 IDS_AUTOFILL_DIALOG_PROVINCE
636 },
637 {
638 "LA",
639 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
640 IDS_AUTOFILL_DIALOG_PROVINCE
641 },
642 {
643 "LB",
644 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
645 IDS_AUTOFILL_DIALOG_PROVINCE
646 },
647 {
648 "LC",
649 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
650 IDS_AUTOFILL_DIALOG_PROVINCE
651 },
652 {
653 "LI",
654 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
655 IDS_AUTOFILL_DIALOG_PROVINCE
656 },
657 {
658 "LK",
659 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
660 IDS_AUTOFILL_DIALOG_PROVINCE
661 },
662 {
663 "LR",
664 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
665 IDS_AUTOFILL_DIALOG_PROVINCE
666 },
667 {
668 "LS",
669 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
670 IDS_AUTOFILL_DIALOG_PROVINCE
671 },
672 {
673 "LT",
674 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
675 IDS_AUTOFILL_DIALOG_PROVINCE
676 },
677 {
678 "LU",
679 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
680 IDS_AUTOFILL_DIALOG_PROVINCE
681 },
682 {
683 "LV",
684 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
685 IDS_AUTOFILL_DIALOG_PROVINCE
686 },
687 {
688 "LY",
689 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
690 IDS_AUTOFILL_DIALOG_PROVINCE
691 },
692 {
693 "MA",
694 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
695 IDS_AUTOFILL_DIALOG_PROVINCE
696 },
697 {
698 "MC",
699 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
700 IDS_AUTOFILL_DIALOG_PROVINCE
701 },
702 {
703 "MD",
704 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
705 IDS_AUTOFILL_DIALOG_PROVINCE
706 },
707 {
708 "ME",
709 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
710 IDS_AUTOFILL_DIALOG_PROVINCE
711 },
712 {
713 "MF",
714 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
715 IDS_AUTOFILL_DIALOG_PROVINCE
716 },
717 {
718 "MG",
719 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
720 IDS_AUTOFILL_DIALOG_PROVINCE
721 },
722 {
723 "MH",
724 IDS_AUTOFILL_DIALOG_ZIP_CODE,
725 IDS_AUTOFILL_DIALOG_STATE
726 },
727 {
728 "MK",
729 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
730 IDS_AUTOFILL_DIALOG_PROVINCE
731 },
732 {
733 "ML",
734 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
735 IDS_AUTOFILL_DIALOG_PROVINCE
736 },
737 {
738 "MN",
739 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
740 IDS_AUTOFILL_DIALOG_PROVINCE
741 },
742 {
743 "MO",
744 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
745 IDS_AUTOFILL_DIALOG_PROVINCE
746 },
747 {
748 "MP",
749 IDS_AUTOFILL_DIALOG_ZIP_CODE,
750 IDS_AUTOFILL_DIALOG_STATE
751 },
752 {
753 "MQ",
754 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
755 IDS_AUTOFILL_DIALOG_PROVINCE
756 },
757 {
758 "MR",
759 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
760 IDS_AUTOFILL_DIALOG_PROVINCE
761 },
762 {
763 "MS",
764 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
765 IDS_AUTOFILL_DIALOG_PROVINCE
766 },
767 {
768 "MT",
769 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
770 IDS_AUTOFILL_DIALOG_PROVINCE
771 },
772 {
773 "MU",
774 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
775 IDS_AUTOFILL_DIALOG_PROVINCE
776 },
777 {
778 "MV",
779 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
780 IDS_AUTOFILL_DIALOG_PROVINCE
781 },
782 {
783 "MW",
784 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
785 IDS_AUTOFILL_DIALOG_PROVINCE
786 },
787 {
788 "MX",
789 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
790 IDS_AUTOFILL_DIALOG_STATE
791 },
792 {
793 "MY",
794 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
795 IDS_AUTOFILL_DIALOG_STATE
796 },
797 {
798 "MZ",
799 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
800 IDS_AUTOFILL_DIALOG_PROVINCE
801 },
802 {
803 "NA",
804 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
805 IDS_AUTOFILL_DIALOG_PROVINCE
806 },
807 {
808 "NC",
809 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
810 IDS_AUTOFILL_DIALOG_PROVINCE
811 },
812 {
813 "NE",
814 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
815 IDS_AUTOFILL_DIALOG_PROVINCE
816 },
817 {
818 "NF",
819 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
820 IDS_AUTOFILL_DIALOG_PROVINCE
821 },
822 {
823 "NG",
824 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
825 IDS_AUTOFILL_DIALOG_STATE
826 },
827 {
828 "NI",
829 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
830 IDS_AUTOFILL_DIALOG_DEPARTMENT
831 },
832 {
833 "NL",
834 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
835 IDS_AUTOFILL_DIALOG_PROVINCE
836 },
837 {
838 "NO",
839 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
840 IDS_AUTOFILL_DIALOG_PROVINCE
841 },
842 {
843 "NP",
844 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
845 IDS_AUTOFILL_DIALOG_PROVINCE
846 },
847 {
848 "NR",
849 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
850 IDS_AUTOFILL_DIALOG_DISTRICT
851 },
852 {
853 "NU",
854 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
855 IDS_AUTOFILL_DIALOG_PROVINCE
856 },
857 {
858 "NZ",
859 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
860 IDS_AUTOFILL_DIALOG_PROVINCE
861 },
862 {
863 "OM",
864 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
865 IDS_AUTOFILL_DIALOG_PROVINCE
866 },
867 {
868 "PA",
869 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
870 IDS_AUTOFILL_DIALOG_PROVINCE
871 },
872 {
873 "PE",
874 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
875 IDS_AUTOFILL_DIALOG_PROVINCE
876 },
877 {
878 "PF",
879 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
880 IDS_AUTOFILL_DIALOG_ISLAND
881 },
882 {
883 "PG",
884 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
885 IDS_AUTOFILL_DIALOG_PROVINCE
886 },
887 {
888 "PH",
889 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
890 IDS_AUTOFILL_DIALOG_PROVINCE
891 },
892 {
893 "PK",
894 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
895 IDS_AUTOFILL_DIALOG_PROVINCE
896 },
897 {
898 "PL",
899 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
900 IDS_AUTOFILL_DIALOG_PROVINCE
901 },
902 {
903 "PM",
904 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
905 IDS_AUTOFILL_DIALOG_PROVINCE
906 },
907 {
908 "PN",
909 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
910 IDS_AUTOFILL_DIALOG_PROVINCE
911 },
912 {
913 "PR",
914 IDS_AUTOFILL_DIALOG_ZIP_CODE,
915 IDS_AUTOFILL_DIALOG_PROVINCE
916 },
917 {
918 "PS",
919 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
920 IDS_AUTOFILL_DIALOG_PROVINCE
921 },
922 {
923 "PT",
924 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
925 IDS_AUTOFILL_DIALOG_PROVINCE
926 },
927 {
928 "PW",
929 IDS_AUTOFILL_DIALOG_ZIP_CODE,
930 IDS_AUTOFILL_DIALOG_STATE
931 },
932 {
933 "PY",
934 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
935 IDS_AUTOFILL_DIALOG_PROVINCE
936 },
937 {
938 "QA",
939 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
940 IDS_AUTOFILL_DIALOG_PROVINCE
941 },
942 {
943 "RE",
944 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
945 IDS_AUTOFILL_DIALOG_PROVINCE
946 },
947 {
948 "RO",
949 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
950 IDS_AUTOFILL_DIALOG_PROVINCE
951 },
952 {
953 "RS",
954 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
955 IDS_AUTOFILL_DIALOG_PROVINCE
956 },
957 {
958 "RU",
959 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
960 IDS_AUTOFILL_DIALOG_PROVINCE
961 },
962 {
963 "RW",
964 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
965 IDS_AUTOFILL_DIALOG_PROVINCE
966 },
967 {
968 "SA",
969 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
970 IDS_AUTOFILL_DIALOG_PROVINCE
971 },
972 {
973 "SB",
974 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
975 IDS_AUTOFILL_DIALOG_PROVINCE
976 },
977 {
978 "SC",
979 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
980 IDS_AUTOFILL_DIALOG_ISLAND
981 },
982 {
983 "SE",
984 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
985 IDS_AUTOFILL_DIALOG_PROVINCE
986 },
987 {
988 "SG",
989 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
990 IDS_AUTOFILL_DIALOG_PROVINCE
991 },
992 {
993 "SH",
994 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
995 IDS_AUTOFILL_DIALOG_PROVINCE
996 },
997 {
998 "SI",
999 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1000 IDS_AUTOFILL_DIALOG_PROVINCE
1001 },
1002 {
1003 "SJ",
1004 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1005 IDS_AUTOFILL_DIALOG_PROVINCE
1006 },
1007 {
1008 "SK",
1009 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1010 IDS_AUTOFILL_DIALOG_PROVINCE
1011 },
1012 {
1013 "SL",
1014 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1015 IDS_AUTOFILL_DIALOG_PROVINCE
1016 },
1017 {
1018 "SM",
1019 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1020 IDS_AUTOFILL_DIALOG_PROVINCE
1021 },
1022 {
1023 "SN",
1024 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1025 IDS_AUTOFILL_DIALOG_PROVINCE
1026 },
1027 {
1028 "SO",
1029 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1030 IDS_AUTOFILL_DIALOG_PROVINCE
1031 },
1032 {
1033 "SR",
1034 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1035 IDS_AUTOFILL_DIALOG_PROVINCE
1036 },
1037 {
1038 "ST",
1039 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1040 IDS_AUTOFILL_DIALOG_PROVINCE
1041 },
1042 {
1043 "SV",
1044 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1045 IDS_AUTOFILL_DIALOG_PROVINCE
1046 },
1047 {
1048 "SZ",
1049 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1050 IDS_AUTOFILL_DIALOG_PROVINCE
1051 },
1052 {
1053 "TC",
1054 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1055 IDS_AUTOFILL_DIALOG_PROVINCE
1056 },
1057 {
1058 "TD",
1059 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1060 IDS_AUTOFILL_DIALOG_PROVINCE
1061 },
1062 {
1063 "TF",
1064 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1065 IDS_AUTOFILL_DIALOG_PROVINCE
1066 },
1067 {
1068 "TG",
1069 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1070 IDS_AUTOFILL_DIALOG_PROVINCE
1071 },
1072 {
1073 "TH",
1074 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1075 IDS_AUTOFILL_DIALOG_PROVINCE
1076 },
1077 {
1078 "TJ",
1079 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1080 IDS_AUTOFILL_DIALOG_PROVINCE
1081 },
1082 {
1083 "TK",
1084 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1085 IDS_AUTOFILL_DIALOG_PROVINCE
1086 },
1087 {
1088 "TL",
1089 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1090 IDS_AUTOFILL_DIALOG_PROVINCE
1091 },
1092 {
1093 "TM",
1094 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1095 IDS_AUTOFILL_DIALOG_PROVINCE
1096 },
1097 {
1098 "TN",
1099 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1100 IDS_AUTOFILL_DIALOG_PROVINCE
1101 },
1102 {
1103 "TO",
1104 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1105 IDS_AUTOFILL_DIALOG_PROVINCE
1106 },
1107 {
1108 "TR",
1109 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1110 IDS_AUTOFILL_DIALOG_PROVINCE
1111 },
1112 {
1113 "TT",
1114 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1115 IDS_AUTOFILL_DIALOG_PROVINCE
1116 },
1117 {
1118 "TV",
1119 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1120 IDS_AUTOFILL_DIALOG_ISLAND
1121 },
1122 {
1123 "TW",
1124 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1125 IDS_AUTOFILL_DIALOG_COUNTY
1126 },
1127 {
1128 "TZ",
1129 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1130 IDS_AUTOFILL_DIALOG_PROVINCE
1131 },
1132 {
1133 "UA",
1134 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1135 IDS_AUTOFILL_DIALOG_PROVINCE
1136 },
1137 {
1138 "UG",
1139 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1140 IDS_AUTOFILL_DIALOG_PROVINCE
1141 },
1142 {
1143 "UM",
1144 IDS_AUTOFILL_DIALOG_ZIP_CODE,
1145 IDS_AUTOFILL_DIALOG_STATE
1146 },
1147 {
1148 "US",
1149 IDS_AUTOFILL_DIALOG_ZIP_CODE,
1150 IDS_AUTOFILL_DIALOG_STATE
1151 },
1152 {
1153 "UY",
1154 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1155 IDS_AUTOFILL_DIALOG_PROVINCE
1156 },
1157 {
1158 "UZ",
1159 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1160 IDS_AUTOFILL_DIALOG_PROVINCE
1161 },
1162 {
1163 "VA",
1164 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1165 IDS_AUTOFILL_DIALOG_PROVINCE
1166 },
1167 {
1168 "VC",
1169 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1170 IDS_AUTOFILL_DIALOG_PROVINCE
1171 },
1172 {
1173 "VE",
1174 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1175 IDS_AUTOFILL_DIALOG_PROVINCE
1176 },
1177 {
1178 "VG",
1179 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1180 IDS_AUTOFILL_DIALOG_PROVINCE
1181 },
1182 {
1183 "VI",
1184 IDS_AUTOFILL_DIALOG_ZIP_CODE,
1185 IDS_AUTOFILL_DIALOG_STATE
1186 },
1187 {
1188 "VN",
1189 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1190 IDS_AUTOFILL_DIALOG_PROVINCE
1191 },
1192 {
1193 "VU",
1194 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1195 IDS_AUTOFILL_DIALOG_PROVINCE
1196 },
1197 {
1198 "WF",
1199 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1200 IDS_AUTOFILL_DIALOG_PROVINCE
1201 },
1202 {
1203 "WS",
1204 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1205 IDS_AUTOFILL_DIALOG_PROVINCE
1206 },
1207 {
1208 "YE",
1209 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1210 IDS_AUTOFILL_DIALOG_PROVINCE
1211 },
1212 {
1213 "YT",
1214 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1215 IDS_AUTOFILL_DIALOG_PROVINCE
1216 },
1217 {
1218 "ZA",
1219 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1220 IDS_AUTOFILL_DIALOG_PROVINCE
1221 },
1222 {
1223 "ZM",
1224 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1225 IDS_AUTOFILL_DIALOG_PROVINCE
1226 },
1227 {
1228 "ZW",
1229 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1230 IDS_AUTOFILL_DIALOG_PROVINCE
1231 },
1232 };
1233
1234 // A singleton class that encapsulates a map from country codes to country data.
1235 class AutoFillCountries {
1236 public:
1237 typedef std::map<std::string, AutoFillCountryData> MapType;
James Hawkins 2011/02/12 20:32:45 Document this type.
Ilya Sherman 2011/02/16 10:27:18 Done, though not sure how much value-add the comme
1238
1239 static AutoFillCountries* GetInstance();
1240 static const MapType& countries();
1241
1242 private:
1243 AutoFillCountries();
1244 friend struct DefaultSingletonTraits<AutoFillCountries>;
James Hawkins 2011/02/12 20:32:45 friend declarations should be first in the section
Ilya Sherman 2011/02/16 10:27:18 That doesn't seem to be the style used elsewhere -
1245
1246 MapType countries_;
1247
1248 DISALLOW_COPY_AND_ASSIGN(AutoFillCountries);
1249 };
1250
1251 // static
1252 AutoFillCountries* AutoFillCountries::GetInstance() {
1253 return Singleton<AutoFillCountries>::get();
1254 }
1255
1256 AutoFillCountries::AutoFillCountries() {
1257 // Add all the countries we have explicit data for.
1258 for (size_t i = 0; i < arraysize(kCountryData); ++i) {
1259 const AutoFillCountryData& data = kCountryData[i];
1260 countries_.insert(std::make_pair(data.country_code, data));
1261 }
1262
1263 // Add any other countries that ICU knows about, falling back to default data
1264 // values.
1265 for (const char* const* country_pointer = Locale::getISOCountries();
1266 *country_pointer;
1267 ++country_pointer) {
1268 std::string country_code = *country_pointer;
1269 if (!countries_.count(country_code)) {
1270 AutoFillCountryData data = {
1271 country_code,
1272 IDS_AUTOFILL_DIALOG_POSTAL_CODE,
1273 IDS_AUTOFILL_DIALOG_PROVINCE
1274 };
1275 countries_.insert(std::make_pair(country_code, data));
1276 }
1277 }
1278 }
1279
1280 const AutoFillCountries::MapType& AutoFillCountries::countries() {
1281 return GetInstance()->countries_;
1282 }
1283
1284 } // namespace
1285
1286 // static
1287 AutoFillCountry AutoFillCountry::CountryForCountryCode(
1288 const std::string& country_code) {
1289 const AutoFillCountries::MapType& countries = AutoFillCountries::countries();
1290 DCHECK(countries.count(country_code));
1291 const AutoFillCountryData& data = countries.find(country_code)->second;
1292
1293 // Get the localized country name appropriate for the app locale.
1294 icu::Locale country_locale(NULL, country_code.c_str());
1295 icu::Locale app_locale(g_browser_process->GetApplicationLocale().c_str());
1296 icu::UnicodeString icu_name;
1297 country_locale.getDisplayName(app_locale, icu_name);
1298 DCHECK_GT(icu_name.length(), 0);
1299
1300 string16 name(icu_name.getBuffer(), icu_name.length());
1301 return AutoFillCountry(country_code,
1302 name,
1303 l10n_util::GetStringUTF16(data.postal_code_label_id),
1304 l10n_util::GetStringUTF16(data.state_label_id));
1305 }
1306
1307 // static
1308 AutoFillCountry AutoFillCountry::CountryForLocale(const std::string& locale) {
1309 std::string country_code = icu::Locale(locale.c_str()).getCountry();
1310 return CountryForCountryCode(country_code);
1311 }
1312
1313 // static
1314 void AutoFillCountry::GetAvailableCountries(
1315 std::vector<AutoFillCountry>* countries) {
1316 DCHECK(countries);
1317
1318 const AutoFillCountries::MapType& country_data =
1319 AutoFillCountries::countries();
1320 for (AutoFillCountries::MapType::const_iterator it = country_data.begin();
1321 it != country_data.end();
1322 ++it) {
1323 countries->push_back(CountryForCountryCode(it->first));
1324 }
1325 }
1326
1327 AutoFillCountry::AutoFillCountry(const std::string& country_code,
1328 const string16& name,
1329 const string16& postal_code_label,
1330 const string16& state_label)
1331 : country_code_(country_code),
1332 name_(name),
1333 postal_code_label_(postal_code_label),
1334 state_label_(state_label) {
1335 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698