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/search_engines/template_url_prepopulate_data.h"
6
7#if defined(OS_POSIX) && !defined(OS_MACOSX)
8#include <locale.h>
9#endif
10
11#include "base/command_line.h"
12#include "base/memory/scoped_vector.h"
13#include "base/string16.h"
14#include "base/string_util.h"
15#include "base/stl_util-inl.h"
16#include "base/utf_string_conversions.h"
17#include "chrome/browser/prefs/pref_service.h"
18#include "chrome/browser/search_engines/search_engine_type.h"
19#include "chrome/browser/search_engines/search_terms_data.h"
20#include "chrome/browser/search_engines/template_url.h"
21#include "chrome/browser/search_engines/template_url_model.h"
22#include "chrome/common/chrome_switches.h"
23#include "chrome/common/pref_names.h"
24#include "googleurl/src/gurl.h"
25#include "grit/theme_resources.h"
26
27#if defined(OS_WIN)
28#undef IN  // On Windows, windef.h defines this, which screws up "India" cases.
29#elif defined(OS_MACOSX)
30#include "base/mac/scoped_cftyperef.h"
31#endif
32
33using base::Time;
34
35namespace {
36
37// NOTE: See comments in GetDataVersion() below!  You should probably not change
38// the data in this file without changing the result of that function!
39
40// Engine definitions //////////////////////////////////////////////////////////
41
42struct PrepopulatedEngine {
43  const wchar_t* const name;
44  // If NULL, we'll autogenerate a keyword based on the search_url every time
45  // someone asks.  Only entries which need keywords to auto-track a dynamically
46  // generated search URL should use this.
47  // If the empty string, the engine has no keyword.
48  const wchar_t* const keyword;
49  const char* const favicon_url;  // If NULL, there is no favicon.
50  const wchar_t* const search_url;
51  const char* const encoding;
52  const wchar_t* const suggest_url;  // If NULL, this engine does not support
53                                     // suggestions.
54  const wchar_t* const instant_url;  // If NULL, this engine does not support
55                                     // instant.
56  // SEARCH_ENGINE_OTHER if no logo is available.
57  const SearchEngineType search_engine_type;
58  const int logo_id;  // Id for logo image in search engine dialog.
59  // Unique id for this prepopulate engine (corresponds to
60  // TemplateURL::prepopulate_id). This ID must be greater than zero and must
61  // remain the same for a particular site regardless of how the url changes;
62  // the ID is used when modifying engine data in subsequent versions, so that
63  // we can find the "old" entry to update even when the name or URL changes.
64  //
65  // This ID must be "unique" within one country's prepopulated data, but two
66  // entries can share an ID if they represent the "same" engine (e.g. Yahoo! US
67  // vs. Yahoo! UK) and will not appear in the same user-visible data set.  This
68  // facilitates changes like adding more specific per-country data in the
69  // future; in such a case the localized engines will transparently replace the
70  // previous, non-localized versions.  For engines where we need two instances
71  // to appear for one country (e.g. Bing Search U.S. English and Spanish), we
72  // must use two different unique IDs (and different keywords).
73  //
74  // The following unique IDs are available:
75  //    33, 34, 36, 39, 42, 43, 47, 48, 49, 50, 52, 53, 56, 58, 60, 61, 64, 65,
76  //    66, 70, 74, 78, 79, 80, 81, 84, 86, 88, 91, 92, 93, 94, 95, 96, 97, 98,
77  //    102+
78  //
79  // IDs > 1000 are reserved for distribution custom engines.
80  //
81  // NOTE: CHANGE THE ABOVE NUMBERS IF YOU ADD A NEW ENGINE; ID conflicts = bad!
82  const int id;
83};
84
85const PrepopulatedEngine abcsok = {
86  L"ABC S\x00f8k",
87  L"abcsok.no",
88  "http://abcsok.no/favicon.ico",
89  L"http://abcsok.no/index.html?q={searchTerms}",
90  "UTF-8",
91  NULL,
92  NULL,
93  SEARCH_ENGINE_ABCSOK,
94  IDR_SEARCH_ENGINE_LOGO_ABCSOK,
95  72,
96};
97
98const PrepopulatedEngine altavista = {
99  L"AltaVista",
100  L"altavista.com",
101  "http://www.altavista.com/favicon.ico",
102  L"http://www.altavista.com/web/results?q={searchTerms}",
103  "UTF-8",
104  NULL,
105  NULL,
106  SEARCH_ENGINE_ALTAVISTA,
107  IDR_SEARCH_ENGINE_LOGO_ALTAVISTA,
108  89,
109};
110
111const PrepopulatedEngine altavista_ar = {
112  L"AltaVista",
113  L"ar.altavista.com",
114  "http://ar.altavista.com/favicon.ico",
115  L"http://ar.altavista.com/web/results?q={searchTerms}",
116  "UTF-8",
117  NULL,
118  NULL,
119  SEARCH_ENGINE_ALTAVISTA,
120  IDR_SEARCH_ENGINE_LOGO_ALTAVISTA,
121  89,
122};
123
124const PrepopulatedEngine altavista_se = {
125  L"AltaVista",
126  L"se.altavista.com",
127  "http://se.altavista.com/favicon.ico",
128  L"http://se.altavista.com/web/results?q={searchTerms}",
129  "UTF-8",
130  NULL,
131  NULL,
132  SEARCH_ENGINE_ALTAVISTA,
133  IDR_SEARCH_ENGINE_LOGO_ALTAVISTA,
134  89,
135};
136
137const PrepopulatedEngine aol = {
138  L"AOL",
139  L"aol.com",
140  "http://search.aol.com/favicon.ico",
141  L"http://search.aol.com/aol/search?query={searchTerms}",
142  "UTF-8",
143  NULL,
144  NULL,
145  SEARCH_ENGINE_OTHER,
146  IDR_SEARCH_ENGINE_LOGO_AOL,
147  35,
148};
149
150const PrepopulatedEngine araby = {
151  L"\x0639\x0631\x0628\x064a",
152  L"araby.com",
153  "http://araby.com/favicon.ico",
154  L"http://araby.com/?q={searchTerms}",
155  "UTF-8",
156  NULL,
157  NULL,
158  SEARCH_ENGINE_OTHER,
159  kNoSearchEngineLogo,
160  12,
161};
162
163const PrepopulatedEngine ask = {
164  L"Ask",
165  L"ask.com",
166  "http://www.ask.com/favicon.ico",
167  L"http://www.ask.com/web?q={searchTerms}",
168  "UTF-8",
169  L"http://ss.ask.com/query?q={searchTerms}&li=ff",
170  NULL,
171  SEARCH_ENGINE_ASK,
172  IDR_SEARCH_ENGINE_LOGO_ASK,
173  4,
174};
175
176const PrepopulatedEngine ask_de = {
177  L"Ask.com Deutschland",
178  L"de.ask.com",
179  "http://de.ask.com/favicon.ico",
180  L"http://de.ask.com/web?q={searchTerms}",
181  "UTF-8",
182  L"http://ss.de.ask.com/query?q={searchTerms}&li=ff",
183  NULL,
184  SEARCH_ENGINE_ASK,
185  IDR_SEARCH_ENGINE_LOGO_ASK,
186  4,
187};
188
189const PrepopulatedEngine ask_es = {
190  L"Ask.com Espa" L"\x00f1" L"a",
191  L"es.ask.com",
192  "http://es.ask.com/favicon.ico",
193  L"http://es.ask.com/web?q={searchTerms}",
194  "UTF-8",
195  L"http://ss.es.ask.com/query?q={searchTerms}&li=ff",
196  NULL,
197  SEARCH_ENGINE_ASK,
198  IDR_SEARCH_ENGINE_LOGO_ASK,
199  4,
200};
201
202const PrepopulatedEngine ask_it = {
203  L"Ask.com Italia",
204  L"it.ask.com",
205  "http://it.ask.com/favicon.ico",
206  L"http://it.ask.com/web?q={searchTerms}",
207  "UTF-8",
208  L"http://ss.it.ask.com/query?q={searchTerms}&li=ff",
209  NULL,
210  SEARCH_ENGINE_ASK,
211  IDR_SEARCH_ENGINE_LOGO_ASK,
212  4,
213};
214
215const PrepopulatedEngine ask_nl = {
216  L"Ask.com Nederland",
217  L"nl.ask.com",
218  "http://nl.ask.com/favicon.ico",
219  L"http://nl.ask.com/web?q={searchTerms}",
220  "UTF-8",
221  L"http://ss.nl.ask.com/query?q={searchTerms}&li=ff",
222  NULL,
223  SEARCH_ENGINE_ASK,
224  IDR_SEARCH_ENGINE_LOGO_ASK,
225  4,
226};
227
228const PrepopulatedEngine ask_uk = {
229  L"Ask Jeeves",
230  L"uk.ask.com",
231  "http://uk.ask.com/favicon.ico",
232  L"http://uk.ask.com/web?q={searchTerms}",
233  "UTF-8",
234  L"http://ss.uk.ask.com/query?q={searchTerms}&li=ff",
235  NULL,
236  SEARCH_ENGINE_ASK,
237  IDR_SEARCH_ENGINE_LOGO_ASK,
238  4,
239};
240
241const PrepopulatedEngine atlas_cz = {
242  L"Atlas",
243  L"atlas.cz",
244  "http://img.atlas.cz/favicon.ico",
245  L"http://search.atlas.cz/?q={searchTerms}",
246  "windows-1250",
247  NULL,
248  NULL,
249  SEARCH_ENGINE_OTHER,
250  kNoSearchEngineLogo,
251  27,
252};
253
254const PrepopulatedEngine atlas_sk = {
255  L"ATLAS.SK",
256  L"atlas.sk",
257  "http://www.atlas.sk/images/favicon.ico",
258  L"http://hladaj.atlas.sk/fulltext/?phrase={searchTerms}",
259  "UTF-8",
260  NULL,
261  NULL,
262  SEARCH_ENGINE_OTHER,
263  kNoSearchEngineLogo,
264  27,
265};
266
267const PrepopulatedEngine baidu = {
268  L"\x767e\x5ea6",
269  L"baidu.com",
270  "http://www.baidu.com/favicon.ico",
271  L"http://www.baidu.com/s?wd={searchTerms}",
272  "GB2312",
273  NULL,
274  NULL,
275  SEARCH_ENGINE_BAIDU,
276  IDR_SEARCH_ENGINE_LOGO_BAIDU,
277  21,
278};
279
280const PrepopulatedEngine bing = {
281  L"Bing",
282  L"bing.com",
283  "http://www.bing.com/s/wlflag.ico",
284  L"http://www.bing.com/search?q={searchTerms}",
285  "UTF-8",
286  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
287  NULL,
288  SEARCH_ENGINE_BING,
289  IDR_SEARCH_ENGINE_LOGO_BING,
290  3,
291};
292
293const PrepopulatedEngine bing_ar_XA = {
294  L"Bing",
295  L"",  // bing.com is taken by bing_en_XA.
296  "http://www.bing.com/s/wlflag.ico",
297  L"http://www.bing.com/search?setmkt=ar-XA&q={searchTerms}",
298  "UTF-8",
299  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
300  NULL,
301  SEARCH_ENGINE_BING,
302  IDR_SEARCH_ENGINE_LOGO_BING,
303  7,  // Can't be 3 as this has to appear in the Arabian countries' lists
304      // alongside bing_en_XA.
305};
306
307const PrepopulatedEngine bing_bg_BG = {
308  L"Bing",
309  L"bing.com",
310  "http://www.bing.com/s/wlflag.ico",
311  L"http://www.bing.com/search?setmkt=bg-BG&q={searchTerms}",
312  "UTF-8",
313  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
314  NULL,
315  SEARCH_ENGINE_BING,
316  IDR_SEARCH_ENGINE_LOGO_BING,
317  3,
318};
319
320const PrepopulatedEngine bing_cs_CZ = {
321  L"Bing",
322  L"bing.com",
323  "http://www.bing.com/s/wlflag.ico",
324  L"http://www.bing.com/search?setmkt=cs-CZ&q={searchTerms}",
325  "UTF-8",
326  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
327  NULL,
328  SEARCH_ENGINE_BING,
329  IDR_SEARCH_ENGINE_LOGO_BING,
330  3,
331};
332
333const PrepopulatedEngine bing_da_DK = {
334  L"Bing",
335  L"bing.com",
336  "http://www.bing.com/s/wlflag.ico",
337  L"http://www.bing.com/search?setmkt=da-DK&q={searchTerms}",
338  "UTF-8",
339  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
340  NULL,
341  SEARCH_ENGINE_BING,
342  IDR_SEARCH_ENGINE_LOGO_BING,
343  3,
344};
345
346const PrepopulatedEngine bing_de_AT = {
347  L"Bing",
348  L"bing.com",
349  "http://www.bing.com/s/wlflag.ico",
350  L"http://www.bing.com/search?setmkt=de-AT&q={searchTerms}",
351  "UTF-8",
352  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
353  NULL,
354  SEARCH_ENGINE_BING,
355  IDR_SEARCH_ENGINE_LOGO_BING,
356  3,
357};
358
359const PrepopulatedEngine bing_de_CH = {
360  L"Bing",
361  L"bing.com",
362  "http://www.bing.com/s/wlflag.ico",
363  L"http://www.bing.com/search?setmkt=de-CH&q={searchTerms}",
364  "UTF-8",
365  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
366  NULL,
367  SEARCH_ENGINE_BING,
368  IDR_SEARCH_ENGINE_LOGO_BING,
369  3,
370};
371
372const PrepopulatedEngine bing_de_DE = {
373  L"Bing",
374  L"bing.com",
375  "http://www.bing.com/s/wlflag.ico",
376  L"http://www.bing.com/search?setmkt=de-DE&q={searchTerms}",
377  "UTF-8",
378  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
379  NULL,
380  SEARCH_ENGINE_BING,
381  IDR_SEARCH_ENGINE_LOGO_BING,
382  3,
383};
384
385const PrepopulatedEngine bing_el_GR = {
386  L"Bing",
387  L"bing.com",
388  "http://www.bing.com/s/wlflag.ico",
389  L"http://www.bing.com/search?setmkt=el-GR&q={searchTerms}",
390  "UTF-8",
391  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
392  NULL,
393  SEARCH_ENGINE_BING,
394  IDR_SEARCH_ENGINE_LOGO_BING,
395  3,
396};
397
398const PrepopulatedEngine bing_en_AU = {
399  L"Bing",
400  L"bing.com",
401  "http://www.bing.com/s/wlflag.ico",
402  L"http://www.bing.com/search?setmkt=en-AU&q={searchTerms}",
403  "UTF-8",
404  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
405  NULL,
406  SEARCH_ENGINE_BING,
407  IDR_SEARCH_ENGINE_LOGO_BING,
408  3,
409};
410
411const PrepopulatedEngine bing_en_CA = {
412  L"Bing",
413  L"bing.com",
414  "http://www.bing.com/s/wlflag.ico",
415  L"http://www.bing.com/search?setmkt=en-CA&q={searchTerms}",
416  "UTF-8",
417  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
418  NULL,
419  SEARCH_ENGINE_BING,
420  IDR_SEARCH_ENGINE_LOGO_BING,
421  3,
422};
423
424const PrepopulatedEngine bing_en_GB = {
425  L"Bing",
426  L"bing.com",
427  "http://www.bing.com/s/wlflag.ico",
428  L"http://www.bing.com/search?setmkt=en-GB&q={searchTerms}",
429  "UTF-8",
430  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
431  NULL,
432  SEARCH_ENGINE_BING,
433  IDR_SEARCH_ENGINE_LOGO_BING,
434  3,
435};
436
437const PrepopulatedEngine bing_en_ID = {
438  L"Bing",
439  L"bing.com",
440  "http://www.bing.com/s/wlflag.ico",
441  L"http://www.bing.com/search?setmkt=en-ID&q={searchTerms}",
442  "UTF-8",
443  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
444  NULL,
445  SEARCH_ENGINE_BING,
446  IDR_SEARCH_ENGINE_LOGO_BING,
447  3,
448};
449
450const PrepopulatedEngine bing_en_IE = {
451  L"Bing",
452  L"bing.com",
453  "http://www.bing.com/s/wlflag.ico",
454  L"http://www.bing.com/search?setmkt=en-IE&q={searchTerms}",
455  "UTF-8",
456  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
457  NULL,
458  SEARCH_ENGINE_BING,
459  IDR_SEARCH_ENGINE_LOGO_BING,
460  3,
461};
462
463const PrepopulatedEngine bing_en_IN = {
464  L"Bing",
465  L"bing.com",
466  "http://www.bing.com/s/wlflag.ico",
467  L"http://www.bing.com/search?setmkt=en-IN&q={searchTerms}",
468  "UTF-8",
469  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
470  NULL,
471  SEARCH_ENGINE_BING,
472  IDR_SEARCH_ENGINE_LOGO_BING,
473  3,
474};
475
476const PrepopulatedEngine bing_en_MY = {
477  L"Bing",
478  L"bing.com",
479  "http://www.bing.com/s/wlflag.ico",
480  L"http://www.bing.com/search?setmkt=en-MY&q={searchTerms}",
481  "UTF-8",
482  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
483  NULL,
484  SEARCH_ENGINE_BING,
485  IDR_SEARCH_ENGINE_LOGO_BING,
486  3,
487};
488
489const PrepopulatedEngine bing_en_NZ = {
490  L"Bing",
491  L"bing.com",
492  "http://www.bing.com/s/wlflag.ico",
493  L"http://www.bing.com/search?setmkt=en-NZ&q={searchTerms}",
494  "UTF-8",
495  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
496  NULL,
497  SEARCH_ENGINE_BING,
498  IDR_SEARCH_ENGINE_LOGO_BING,
499  3,
500};
501
502const PrepopulatedEngine bing_en_PH = {
503  L"Bing",
504  L"bing.com",
505  "http://www.bing.com/s/wlflag.ico",
506  L"http://www.bing.com/search?setmkt=en-PH&q={searchTerms}",
507  "UTF-8",
508  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
509  NULL,
510  SEARCH_ENGINE_BING,
511  IDR_SEARCH_ENGINE_LOGO_BING,
512  3,
513};
514
515const PrepopulatedEngine bing_en_SG = {
516  L"Bing",
517  L"bing.com",
518  "http://www.bing.com/s/wlflag.ico",
519  L"http://www.bing.com/search?setmkt=en-SG&q={searchTerms}",
520  "UTF-8",
521  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
522  NULL,
523  SEARCH_ENGINE_BING,
524  IDR_SEARCH_ENGINE_LOGO_BING,
525  3,
526};
527
528const PrepopulatedEngine bing_en_US = {
529  L"Bing",
530  L"bing.com",
531  "http://www.bing.com/s/wlflag.ico",
532  L"http://www.bing.com/search?setmkt=en-US&q={searchTerms}",
533  "UTF-8",
534  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
535  NULL,
536  SEARCH_ENGINE_BING,
537  IDR_SEARCH_ENGINE_LOGO_BING,
538  3,
539};
540
541const PrepopulatedEngine bing_en_XA = {
542  L"Bing",
543  L"bing.com",
544  "http://www.bing.com/s/wlflag.ico",
545  L"http://www.bing.com/search?setmkt=en-XA&q={searchTerms}",
546  "UTF-8",
547  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
548  NULL,
549  SEARCH_ENGINE_BING,
550  IDR_SEARCH_ENGINE_LOGO_BING,
551  3,
552};
553
554const PrepopulatedEngine bing_en_ZA = {
555  L"Bing",
556  L"bing.com",
557  "http://www.bing.com/s/wlflag.ico",
558  L"http://www.bing.com/search?setmkt=en-ZA&q={searchTerms}",
559  "UTF-8",
560  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
561  NULL,
562  SEARCH_ENGINE_BING,
563  IDR_SEARCH_ENGINE_LOGO_BING,
564  3,
565};
566
567const PrepopulatedEngine bing_es_AR = {
568  L"Bing",
569  L"bing.com",
570  "http://www.bing.com/s/wlflag.ico",
571  L"http://www.bing.com/search?setmkt=es-AR&q={searchTerms}",
572  "UTF-8",
573  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
574  NULL,
575  SEARCH_ENGINE_BING,
576  IDR_SEARCH_ENGINE_LOGO_BING,
577  3,
578};
579
580const PrepopulatedEngine bing_es_CL = {
581  L"Bing",
582  L"bing.com",
583  "http://www.bing.com/s/wlflag.ico",
584  L"http://www.bing.com/search?setmkt=es-CL&q={searchTerms}",
585  "UTF-8",
586  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
587  NULL,
588  SEARCH_ENGINE_BING,
589  IDR_SEARCH_ENGINE_LOGO_BING,
590  3,
591};
592
593const PrepopulatedEngine bing_es_ES = {
594  L"Bing",
595  L"bing.com",
596  "http://www.bing.com/s/wlflag.ico",
597  L"http://www.bing.com/search?setmkt=es-ES&q={searchTerms}",
598  "UTF-8",
599  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
600  NULL,
601  SEARCH_ENGINE_BING,
602  IDR_SEARCH_ENGINE_LOGO_BING,
603  3,
604};
605
606const PrepopulatedEngine bing_es_MX = {
607  L"Bing",
608  L"bing.com",
609  "http://www.bing.com/s/wlflag.ico",
610  L"http://www.bing.com/search?setmkt=es-MX&q={searchTerms}",
611  "UTF-8",
612  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
613  NULL,
614  SEARCH_ENGINE_BING,
615  IDR_SEARCH_ENGINE_LOGO_BING,
616  3,
617};
618
619const PrepopulatedEngine bing_es_XL = {
620  L"Bing",
621  L"bing.com",
622  "http://www.bing.com/s/wlflag.ico",
623  L"http://www.bing.com/search?setmkt=es-XL&q={searchTerms}",
624  "UTF-8",
625  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
626  NULL,
627  SEARCH_ENGINE_BING,
628  IDR_SEARCH_ENGINE_LOGO_BING,
629  3,
630};
631
632const PrepopulatedEngine bing_et_EE = {
633  L"Bing",
634  L"bing.com",
635  "http://www.bing.com/s/wlflag.ico",
636  L"http://www.bing.com/search?setmkt=et-EE&q={searchTerms}",
637  "UTF-8",
638  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
639  NULL,
640  SEARCH_ENGINE_BING,
641  IDR_SEARCH_ENGINE_LOGO_BING,
642  3,
643};
644
645const PrepopulatedEngine bing_fi_FI = {
646  L"Bing",
647  L"bing.com",
648  "http://www.bing.com/s/wlflag.ico",
649  L"http://www.bing.com/search?setmkt=fi-FI&q={searchTerms}",
650  "UTF-8",
651  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
652  NULL,
653  SEARCH_ENGINE_BING,
654  IDR_SEARCH_ENGINE_LOGO_BING,
655  3,
656};
657
658const PrepopulatedEngine bing_fr_BE = {
659  L"Bing",
660  L"",  // bing.com is taken by bing_nl_BE.
661  "http://www.bing.com/s/wlflag.ico",
662  L"http://www.bing.com/search?setmkt=fr-BE&q={searchTerms}",
663  "UTF-8",
664  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
665  NULL,
666  SEARCH_ENGINE_BING,
667  IDR_SEARCH_ENGINE_LOGO_BING,
668  7,
669};
670
671const PrepopulatedEngine bing_fr_CA = {
672  L"Bing",
673  L"",  // bing.com is taken by bing_en_CA.
674  "http://www.bing.com/s/wlflag.ico",
675  L"http://www.bing.com/search?setmkt=fr-CA&q={searchTerms}",
676  "UTF-8",
677  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
678  NULL,
679  SEARCH_ENGINE_BING,
680  IDR_SEARCH_ENGINE_LOGO_BING,
681  7,
682};
683
684const PrepopulatedEngine bing_fr_CH = {
685  L"Bing",
686  L"",  // bing.com is taken by bing_de_CH.
687  "http://www.bing.com/s/wlflag.ico",
688  L"http://www.bing.com/search?setmkt=fr-CH&q={searchTerms}",
689  "UTF-8",
690  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
691  NULL,
692  SEARCH_ENGINE_BING,
693  IDR_SEARCH_ENGINE_LOGO_BING,
694  7,
695};
696
697const PrepopulatedEngine bing_fr_FR = {
698  L"Bing",
699  L"bing.com",
700  "http://www.bing.com/s/wlflag.ico",
701  L"http://www.bing.com/search?setmkt=fr-FR&q={searchTerms}",
702  "UTF-8",
703  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
704  NULL,
705  SEARCH_ENGINE_BING,
706  IDR_SEARCH_ENGINE_LOGO_BING,
707  3,
708};
709
710const PrepopulatedEngine bing_he_IL = {
711  L"Bing",
712  L"bing.com",
713  "http://www.bing.com/s/wlflag.ico",
714  L"http://www.bing.com/search?setmkt=he-IL&q={searchTerms}",
715  "UTF-8",
716  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
717  NULL,
718  SEARCH_ENGINE_BING,
719  IDR_SEARCH_ENGINE_LOGO_BING,
720  3,
721};
722
723const PrepopulatedEngine bing_hr_HR = {
724  L"Bing",
725  L"bing.com",
726  "http://www.bing.com/s/wlflag.ico",
727  L"http://www.bing.com/search?setmkt=hr-HR&q={searchTerms}",
728  "UTF-8",
729  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
730  NULL,
731  SEARCH_ENGINE_BING,
732  IDR_SEARCH_ENGINE_LOGO_BING,
733  3,
734};
735
736const PrepopulatedEngine bing_hu_HU = {
737  L"Bing",
738  L"bing.com",
739  "http://www.bing.com/s/wlflag.ico",
740  L"http://www.bing.com/search?setmkt=hu-HU&q={searchTerms}",
741  "UTF-8",
742  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
743  NULL,
744  SEARCH_ENGINE_BING,
745  IDR_SEARCH_ENGINE_LOGO_BING,
746  3,
747};
748
749const PrepopulatedEngine bing_it_IT = {
750  L"Bing",
751  L"bing.com",
752  "http://www.bing.com/s/wlflag.ico",
753  L"http://www.bing.com/search?setmkt=it-IT&q={searchTerms}",
754  "UTF-8",
755  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
756  NULL,
757  SEARCH_ENGINE_BING,
758  IDR_SEARCH_ENGINE_LOGO_BING,
759  3,
760};
761
762const PrepopulatedEngine bing_ja_JP = {
763  L"Bing",
764  L"bing.com",
765  "http://www.bing.com/s/wlflag.ico",
766  L"http://www.bing.com/search?setmkt=ja-JP&q={searchTerms}",
767  "UTF-8",
768  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
769  NULL,
770  SEARCH_ENGINE_BING,
771  IDR_SEARCH_ENGINE_LOGO_BING,
772  3,
773};
774
775const PrepopulatedEngine bing_ko_KR = {
776  L"Bing",
777  L"bing.com",
778  "http://www.bing.com/s/wlflag.ico",
779  L"http://www.bing.com/search?setmkt=ko-KR&q={searchTerms}",
780  "UTF-8",
781  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
782  NULL,
783  SEARCH_ENGINE_BING,
784  IDR_SEARCH_ENGINE_LOGO_BING,
785  3,
786};
787
788const PrepopulatedEngine bing_lt_LT = {
789  L"Bing",
790  L"bing.com",
791  "http://www.bing.com/s/wlflag.ico",
792  L"http://www.bing.com/search?setmkt=lt-LT&q={searchTerms}",
793  "UTF-8",
794  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
795  NULL,
796  SEARCH_ENGINE_BING,
797  IDR_SEARCH_ENGINE_LOGO_BING,
798  3,
799};
800
801const PrepopulatedEngine bing_lv_LV = {
802  L"Bing",
803  L"bing.com",
804  "http://www.bing.com/s/wlflag.ico",
805  L"http://www.bing.com/search?setmkt=lv-LV&q={searchTerms}",
806  "UTF-8",
807  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
808  NULL,
809  SEARCH_ENGINE_BING,
810  IDR_SEARCH_ENGINE_LOGO_BING,
811  3,
812};
813
814const PrepopulatedEngine bing_nb_NO = {
815  L"Bing",
816  L"bing.com",
817  "http://www.bing.com/s/wlflag.ico",
818  L"http://www.bing.com/search?setmkt=nb-NO&q={searchTerms}",
819  "UTF-8",
820  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
821  NULL,
822  SEARCH_ENGINE_BING,
823  IDR_SEARCH_ENGINE_LOGO_BING,
824  3,
825};
826
827const PrepopulatedEngine bing_nl_BE = {
828  L"Bing",
829  L"bing.com",
830  "http://www.bing.com/s/wlflag.ico",
831  L"http://www.bing.com/search?setmkt=nl-BE&q={searchTerms}",
832  "UTF-8",
833  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
834  NULL,
835  SEARCH_ENGINE_BING,
836  IDR_SEARCH_ENGINE_LOGO_BING,
837  3,
838};
839
840const PrepopulatedEngine bing_nl_NL = {
841  L"Bing",
842  L"bing.com",
843  "http://www.bing.com/s/wlflag.ico",
844  L"http://www.bing.com/search?setmkt=nl-NL&q={searchTerms}",
845  "UTF-8",
846  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
847  NULL,
848  SEARCH_ENGINE_BING,
849  IDR_SEARCH_ENGINE_LOGO_BING,
850  3,
851};
852
853const PrepopulatedEngine bing_pl_PL = {
854  L"Bing",
855  L"bing.com",
856  "http://www.bing.com/s/wlflag.ico",
857  L"http://www.bing.com/search?setmkt=pl-PL&q={searchTerms}",
858  "UTF-8",
859  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
860  NULL,
861  SEARCH_ENGINE_BING,
862  IDR_SEARCH_ENGINE_LOGO_BING,
863  3,
864};
865
866const PrepopulatedEngine bing_pt_BR = {
867  L"Bing",
868  L"bing.com",
869  "http://www.bing.com/s/wlflag.ico",
870  L"http://www.bing.com/search?setmkt=pt-BR&q={searchTerms}",
871  "UTF-8",
872  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
873  NULL,
874  SEARCH_ENGINE_BING,
875  IDR_SEARCH_ENGINE_LOGO_BING,
876  3,
877};
878
879const PrepopulatedEngine bing_pt_PT = {
880  L"Bing",
881  L"bing.com",
882  "http://www.bing.com/s/wlflag.ico",
883  L"http://www.bing.com/search?setmkt=pt-PT&q={searchTerms}",
884  "UTF-8",
885  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
886  NULL,
887  SEARCH_ENGINE_BING,
888  IDR_SEARCH_ENGINE_LOGO_BING,
889  3,
890};
891
892const PrepopulatedEngine bing_ro_RO = {
893  L"Bing",
894  L"bing.com",
895  "http://www.bing.com/s/wlflag.ico",
896  L"http://www.bing.com/search?setmkt=ro-RO&q={searchTerms}",
897  "UTF-8",
898  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
899  NULL,
900  SEARCH_ENGINE_BING,
901  IDR_SEARCH_ENGINE_LOGO_BING,
902  3,
903};
904
905const PrepopulatedEngine bing_ru_RU = {
906  L"Bing",
907  L"bing.com",
908  "http://www.bing.com/s/wlflag.ico",
909  L"http://www.bing.com/search?setmkt=ru-RU&q={searchTerms}",
910  "UTF-8",
911  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
912  NULL,
913  SEARCH_ENGINE_BING,
914  IDR_SEARCH_ENGINE_LOGO_BING,
915  3,
916};
917
918const PrepopulatedEngine bing_sl_SI = {
919  L"Bing",
920  L"bing.com",
921  "http://www.bing.com/s/wlflag.ico",
922  L"http://www.bing.com/search?setmkt=sl-SI&q={searchTerms}",
923  "UTF-8",
924  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
925  NULL,
926  SEARCH_ENGINE_BING,
927  IDR_SEARCH_ENGINE_LOGO_BING,
928  3,
929};
930
931const PrepopulatedEngine bing_sk_SK = {
932  L"Bing",
933  L"bing.com",
934  "http://www.bing.com/s/wlflag.ico",
935  L"http://www.bing.com/search?setmkt=sk-SK&q={searchTerms}",
936  "UTF-8",
937  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
938  NULL,
939  SEARCH_ENGINE_BING,
940  IDR_SEARCH_ENGINE_LOGO_BING,
941  3,
942};
943
944const PrepopulatedEngine bing_sv_SE = {
945  L"Bing",
946  L"bing.com",
947  "http://www.bing.com/s/wlflag.ico",
948  L"http://www.bing.com/search?setmkt=sv-SE&q={searchTerms}",
949  "UTF-8",
950  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
951  NULL,
952  SEARCH_ENGINE_BING,
953  IDR_SEARCH_ENGINE_LOGO_BING,
954  3,
955};
956
957const PrepopulatedEngine bing_th_TH = {
958  L"Bing",
959  L"bing.com",
960  "http://www.bing.com/s/wlflag.ico",
961  L"http://www.bing.com/search?setmkt=th-TH&q={searchTerms}",
962  "UTF-8",
963  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
964  NULL,
965  SEARCH_ENGINE_BING,
966  IDR_SEARCH_ENGINE_LOGO_BING,
967  3,
968};
969
970const PrepopulatedEngine bing_tr_TR = {
971  L"Bing",
972  L"bing.com",
973  "http://www.bing.com/s/wlflag.ico",
974  L"http://www.bing.com/search?setmkt=tr-TR&q={searchTerms}",
975  "UTF-8",
976  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
977  NULL,
978  SEARCH_ENGINE_BING,
979  IDR_SEARCH_ENGINE_LOGO_BING,
980  3,
981};
982
983const PrepopulatedEngine bing_uk_UA = {
984  L"Bing",
985  L"bing.com",
986  "http://www.bing.com/s/wlflag.ico",
987  L"http://www.bing.com/search?setmkt=uk-UA&q={searchTerms}",
988  "UTF-8",
989  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
990  NULL,
991  SEARCH_ENGINE_BING,
992  IDR_SEARCH_ENGINE_LOGO_BING,
993  3,
994};
995
996const PrepopulatedEngine bing_zh_CN = {
997  L"Bing",
998  L"bing.com",
999  "http://www.bing.com/s/wlflag.ico",
1000  L"http://www.bing.com/search?setmkt=zh-CN&q={searchTerms}",
1001  "UTF-8",
1002  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
1003  NULL,
1004  SEARCH_ENGINE_BING,
1005  IDR_SEARCH_ENGINE_LOGO_BING,
1006  3,
1007};
1008
1009const PrepopulatedEngine bing_zh_HK = {
1010  L"Bing",
1011  L"bing.com",
1012  "http://www.bing.com/s/wlflag.ico",
1013  L"http://www.bing.com/search?setmkt=zh-HK&q={searchTerms}",
1014  "UTF-8",
1015  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
1016  NULL,
1017  SEARCH_ENGINE_BING,
1018  IDR_SEARCH_ENGINE_LOGO_BING,
1019  3,
1020};
1021
1022const PrepopulatedEngine bing_zh_TW = {
1023  L"Bing",
1024  L"bing.com",
1025  "http://www.bing.com/s/wlflag.ico",
1026  L"http://www.bing.com/search?setmkt=zh-TW&q={searchTerms}",
1027  "UTF-8",
1028  L"http://api.bing.com/osjson.aspx?query={searchTerms}&language={language}",
1029  NULL,
1030  SEARCH_ENGINE_BING,
1031  IDR_SEARCH_ENGINE_LOGO_BING,
1032  3,
1033};
1034
1035const PrepopulatedEngine centrum_cz = {
1036  L"Centrum.cz",
1037  L"centrum.cz",
1038  "http://img.centrum.cz/6/vy2/o/favicon.ico",
1039  L"http://search.centrum.cz/index.php?charset={inputEncoding}&q={searchTerms}",
1040  "UTF-8",
1041  NULL,
1042  NULL,
1043  SEARCH_ENGINE_CENTRUM,
1044  IDR_SEARCH_ENGINE_LOGO_CENTRUM,
1045  26,
1046};
1047
1048const PrepopulatedEngine centrum_sk = {
1049  L"Centrum.sk",
1050  L"centrum.sk",
1051  "http://img.centrum.sk/4/favicon.ico",
1052  L"http://search.centrum.sk/index.php?charset={inputEncoding}&q={searchTerms}",
1053  "UTF-8",
1054  NULL,
1055  NULL,
1056  SEARCH_ENGINE_CENTRUM,
1057  IDR_SEARCH_ENGINE_LOGO_CENTRUM,
1058  26,
1059};
1060
1061const PrepopulatedEngine daum = {
1062  L"Daum",
1063  L"daum.net",
1064  "http://search.daum.net/favicon.ico",
1065  L"http://search.daum.net/search?q={searchTerms}",
1066  "EUC-KR",
1067  L"http://sug.search.daum.net/search_nsuggest?mod=fxjson&q={searchTerms}",
1068  NULL,
1069  SEARCH_ENGINE_DAUM,
1070  IDR_SEARCH_ENGINE_LOGO_DAUM,
1071  68,
1072};
1073
1074const PrepopulatedEngine delfi_lt = {
1075  L"DELFI",
1076  L"delfi.lt",
1077  "http://search.delfi.lt/img/favicon.png",
1078  L"http://search.delfi.lt/search.php?q={searchTerms}",
1079  "UTF-8",
1080  NULL,
1081  NULL,
1082  SEARCH_ENGINE_DELFI,
1083  IDR_SEARCH_ENGINE_LOGO_DELFI,
1084  45,
1085};
1086
1087const PrepopulatedEngine delfi_lv = {
1088  L"DELFI",
1089  L"delfi.lv",
1090  "http://smart.delfi.lv/img/smart_search.png",
1091  L"http://smart.delfi.lv/i.php?enc={inputEncoding}&q={searchTerms}",
1092  "UTF-8",
1093  NULL,
1094  NULL,
1095  SEARCH_ENGINE_DELFI,
1096  IDR_SEARCH_ENGINE_LOGO_DELFI,
1097  45,
1098};
1099
1100const PrepopulatedEngine diri = {
1101  L"diri",
1102  L"diri.bg",
1103  "http://i.dir.bg/diri/images/favicon.ico",
1104  L"http://diri.bg/search.php?textfield={searchTerms}",
1105  "windows-1251",
1106  NULL,
1107  NULL,
1108  SEARCH_ENGINE_DIRI,
1109  IDR_SEARCH_ENGINE_LOGO_DIRI,
1110  32,
1111};
1112
1113const PrepopulatedEngine eniro_fi = {
1114  L"Eniro",
1115  L"eniro.fi",
1116  "http://eniro.fi/favicon.ico",
1117  L"http://eniro.fi/query?search_word={searchTerms}&what=web_local",
1118  "ISO-8859-1",
1119  NULL,
1120  NULL,
1121  SEARCH_ENGINE_OTHER,
1122  kNoSearchEngineLogo,
1123  29,
1124};
1125
1126const PrepopulatedEngine eniro_se = {
1127  L"Eniro",
1128  L"eniro.se",
1129  "http://eniro.se/favicon.ico",
1130  L"http://eniro.se/query?search_word={searchTerms}&what=web_local",
1131  "ISO-8859-1",
1132  NULL,
1133  NULL,
1134  SEARCH_ENGINE_OTHER,
1135  kNoSearchEngineLogo,
1136  29,
1137};
1138
1139const PrepopulatedEngine fonecta_02_fi = {
1140  L"Fonecta 02.fi",
1141  L"www.fi",
1142  "http://www.02.fi/img/favicon.ico",
1143  L"http://www.02.fi/haku/{searchTerms}",
1144  "UTF-8",
1145  NULL,
1146  NULL,
1147  SEARCH_ENGINE_OTHER,
1148  kNoSearchEngineLogo,
1149  46,
1150};
1151
1152const PrepopulatedEngine go = {
1153  L"GO.com",
1154  L"go.com",
1155  "http://search.yahoo.com/favicon.ico",
1156  L"http://search.yahoo.com/search?ei={inputEncoding}&p={searchTerms}&"
1157      L"fr=hsusgo1",
1158  "ISO-8859-1",
1159  NULL,
1160  NULL,
1161  SEARCH_ENGINE_OTHER,
1162  kNoSearchEngineLogo,
1163  40,
1164};
1165
1166const PrepopulatedEngine goo = {
1167  L"goo",
1168  L"search.goo.ne.jp",
1169  "http://goo.ne.jp/favicon.ico",
1170  L"http://search.goo.ne.jp/web.jsp?MT={searchTerms}&IE={inputEncoding}",
1171  "UTF-8",
1172  NULL,
1173  NULL,
1174  SEARCH_ENGINE_GOO,
1175  IDR_SEARCH_ENGINE_LOGO_GOO,
1176  23,
1177};
1178
1179const PrepopulatedEngine google = {
1180  L"Google",
1181  NULL,
1182  "http://www.google.com/favicon.ico",
1183  L"{google:baseURL}search?{google:RLZ}{google:acceptedSuggestion}"
1184      L"{google:originalQueryForSuggestion}sourceid=chrome&ie={inputEncoding}&"
1185      L"q={searchTerms}",
1186  "UTF-8",
1187  L"{google:baseSuggestURL}search?client=chrome&hl={language}&q={searchTerms}",
1188  L"{google:baseURL}webhp?{google:RLZ}sourceid=chrome-instant"
1189      L"&ie={inputEncoding}&ion=1{searchTerms}&nord=1",
1190  SEARCH_ENGINE_GOOGLE,
1191  IDR_SEARCH_ENGINE_LOGO_GOOGLE,
1192  1,
1193};
1194
1195const PrepopulatedEngine guruji = {
1196  L"guruji",
1197  L"guruji.com",
1198  "http://guruji.com/favicon.ico",
1199  L"http://guruji.com/search?q={searchTerms}",
1200  "UTF-8",
1201  NULL,
1202  NULL,
1203  SEARCH_ENGINE_OTHER,
1204  kNoSearchEngineLogo,
1205  38,
1206};
1207
1208const PrepopulatedEngine hispavista = {
1209  L"hispavista",
1210  L"hispavista.com",
1211  "http://buscar.hispavista.com/favicon.ico",
1212  L"http://buscar.hispavista.com/?cadena={searchTerms}",
1213  "iso-8859-1",
1214  NULL,
1215  NULL,
1216  SEARCH_ENGINE_OTHER,
1217  kNoSearchEngineLogo,
1218  18,
1219};
1220
1221const PrepopulatedEngine in = {
1222  L"in.gr",
1223  L"in.gr",
1224  "http://www.in.gr/favicon.ico",
1225  L"http://find.in.gr/?qs={searchTerms}",
1226  "ISO-8859-7",
1227  NULL,
1228  NULL,
1229  SEARCH_ENGINE_IN,
1230  IDR_SEARCH_ENGINE_LOGO_IN,
1231  54,
1232};
1233
1234const PrepopulatedEngine jabse = {
1235  L"Jabse",
1236  L"jabse.com",
1237  "http://www.jabse.com/favicon.ico",
1238  L"http://www.jabse.com/searchmachine.php?query={searchTerms}",
1239  "UTF-8",
1240  NULL,
1241  NULL,
1242  SEARCH_ENGINE_OTHER,
1243  kNoSearchEngineLogo,
1244  19,
1245};
1246
1247const PrepopulatedEngine jubii = {
1248  L"Jubii",
1249  L"jubii.dk",
1250  "http://search.jubii.dk/favicon_jubii.ico",
1251  L"http://search.jubii.dk/cgi-bin/pursuit?query={searchTerms}",
1252  "ISO-8859-1",
1253  NULL,
1254  NULL,
1255  SEARCH_ENGINE_OTHER,
1256  kNoSearchEngineLogo,
1257  28,
1258};
1259
1260const PrepopulatedEngine kvasir = {
1261  L"Kvasir",
1262  L"kvasir.no",
1263  "http://www.kvasir.no/img/favicon.ico",
1264  L"http://www.kvasir.no/nettsok/searchResult.html?searchExpr={searchTerms}",
1265  "ISO-8859-1",
1266  NULL,
1267  NULL,
1268  SEARCH_ENGINE_OTHER,
1269  kNoSearchEngineLogo,
1270  73,
1271};
1272
1273const PrepopulatedEngine latne = {
1274  L"LATNE",
1275  L"latne.lv",
1276  "http://latne.lv/favicon.ico",
1277  L"http://latne.lv/siets.php?q={searchTerms}",
1278  "UTF-8",
1279  NULL,
1280  NULL,
1281  SEARCH_ENGINE_OTHER,
1282  kNoSearchEngineLogo,
1283  71,
1284};
1285
1286const PrepopulatedEngine leit = {
1287  L"leit.is",
1288  L"leit.is",
1289  "http://leit.is/leit.ico",
1290  L"http://leit.is/query.aspx?qt={searchTerms}",
1291  "ISO-8859-1",
1292  NULL,
1293  NULL,
1294  SEARCH_ENGINE_OTHER,
1295  kNoSearchEngineLogo,
1296  59,
1297};
1298
1299const PrepopulatedEngine libero = {
1300  L"Libero",
1301  L"libero.it",
1302  "http://arianna.libero.it/favicon.ico",
1303  L"http://arianna.libero.it/search/abin/integrata.cgi?query={searchTerms}",
1304  "ISO-8859-1",
1305  NULL,
1306  NULL,
1307  SEARCH_ENGINE_OTHER,
1308  kNoSearchEngineLogo,
1309  63,
1310};
1311
1312const PrepopulatedEngine mail_ru = {
1313  L"@MAIL.RU",
1314  L"mail.ru",
1315  "http://img.go.mail.ru/favicon.ico",
1316  L"http://go.mail.ru/search?q={searchTerms}",
1317  "windows-1251",
1318  NULL,
1319  NULL,
1320  SEARCH_ENGINE_MAILRU,
1321  IDR_SEARCH_ENGINE_LOGO_MAILRU,
1322  83,
1323};
1324
1325const PrepopulatedEngine maktoob = {
1326  L"\x0645\x0643\x062a\x0648\x0628",
1327  L"maktoob.com",
1328  "http://www.maktoob.com/favicon.ico",
1329  L"http://www.maktoob.com/searchResult.php?q={searchTerms}",
1330  "UTF-8",
1331  NULL,
1332  NULL,
1333  SEARCH_ENGINE_OTHER,
1334  kNoSearchEngineLogo,
1335  13,
1336};
1337
1338const PrepopulatedEngine masrawy = {
1339  L"\x0645\x0635\x0631\x0627\x0648\x064a",
1340  L"masrawy.com",
1341  "http://www.masrawy.com/new/images/masrawy.ico",
1342  L"http://masrawy.com/new/search.aspx?sr={searchTerms}",
1343  "windows-1256",
1344  NULL,
1345  NULL,
1346  SEARCH_ENGINE_OTHER,
1347  kNoSearchEngineLogo,
1348  14,
1349};
1350
1351const PrepopulatedEngine mynet = {
1352  L"MYNET",
1353  L"mynet.com",
1354  "http://img.mynet.com/mynetfavori.ico",
1355  L"http://arama.mynet.com/search.aspx?q={searchTerms}&pg=q",
1356  "windows-1254",
1357  NULL,
1358  NULL,
1359  SEARCH_ENGINE_OTHER,
1360  kNoSearchEngineLogo,
1361  101,
1362};
1363
1364const PrepopulatedEngine najdi = {
1365  L"Najdi.si",
1366  L"najdi.si",
1367  "http://www.najdi.si/master/favicon.ico",
1368  L"http://www.najdi.si/search.jsp?q={searchTerms}",
1369  "UTF-8",
1370  NULL,
1371  NULL,
1372  SEARCH_ENGINE_NAJDI,
1373  IDR_SEARCH_ENGINE_LOGO_NAJDI,
1374  87,
1375};
1376
1377const PrepopulatedEngine nate = {
1378  L"\xb124\xc774\xd2b8\xb2f7\xcef4",
1379  L"nate.com",
1380  "http://nate.search.empas.com/favicon.ico",
1381  L"http://nate.search.empas.com/search/all.html?q={searchTerms}",
1382  "EUC-KR",
1383  NULL,
1384  NULL,
1385  SEARCH_ENGINE_OTHER,
1386  kNoSearchEngineLogo,
1387  69,
1388};
1389
1390const PrepopulatedEngine naver = {
1391  L"\xb124\xc774\xbc84",
1392  L"naver.com",
1393  "http://search.naver.com/favicon.ico",
1394  L"http://search.naver.com/search.naver?ie={inputEncoding}"
1395      L"&query={searchTerms}",
1396  "UTF-8",
1397  L"http://ac.search.naver.com/autocompl?m=s&ie={inputEncoding}&oe=utf-8&"
1398      L"q={searchTerms}",
1399  NULL,
1400  SEARCH_ENGINE_NAVER,
1401  IDR_SEARCH_ENGINE_LOGO_NAVER,
1402  67,
1403};
1404
1405const PrepopulatedEngine neti = {
1406  L"NETI",
1407  L"neti.ee",
1408  "http://www.neti.ee/favicon.ico",
1409  L"http://www.neti.ee/cgi-bin/otsing?query={searchTerms}",
1410  "ISO-8859-1",
1411  NULL,
1412  NULL,
1413  SEARCH_ENGINE_NETI,
1414  IDR_SEARCH_ENGINE_LOGO_NETI,
1415  44,
1416};
1417
1418const PrepopulatedEngine netsprint = {
1419  L"NetSprint",
1420  L"netsprint.pl",
1421  "http://netsprint.pl/favicon.ico",
1422  L"http://www.netsprint.pl/serwis/search?q={searchTerms}",
1423  "UTF-8",
1424  NULL,
1425  NULL,
1426  SEARCH_ENGINE_NETSPRINT,
1427  IDR_SEARCH_ENGINE_LOGO_NETSPRINT,
1428  30,
1429};
1430
1431const PrepopulatedEngine nur_kz = {
1432  L"NUR.KZ",
1433  L"nur.kz",
1434  "http://www.nur.kz/favicon_kz.ico",
1435  L"http://search.nur.kz/?encoding={inputEncoding}&query={searchTerms}",
1436  "UTF-8",
1437  NULL,
1438  NULL,
1439  SEARCH_ENGINE_OTHER,
1440  kNoSearchEngineLogo,
1441  20,
1442};
1443
1444const PrepopulatedEngine ok = {
1445  L"OK.hu",
1446  L"ok.hu",
1447  "http://ok.hu/gfx/favicon.ico",
1448  L"http://ok.hu/katalogus?q={searchTerms}",
1449  "ISO-8859-2",
1450  NULL,
1451  NULL,
1452  SEARCH_ENGINE_OK,
1453  IDR_SEARCH_ENGINE_LOGO_OK,
1454  6,
1455};
1456
1457const PrepopulatedEngine onet = {
1458  L"Onet.pl",
1459  L"onet.pl",
1460  "http://szukaj.onet.pl/favicon.ico",
1461  L"http://szukaj.onet.pl/query.html?qt={searchTerms}",
1462  "ISO-8859-2",
1463  NULL,
1464  NULL,
1465  SEARCH_ENGINE_OTHER,
1466  kNoSearchEngineLogo,
1467  75,
1468};
1469
1470const PrepopulatedEngine pogodak_ba = {
1471  L"Pogodak!",
1472  L"pogodak.ba",
1473  "http://www.pogodak.ba/favicon.ico",
1474  L"http://www.pogodak.ba/search.jsp?q={searchTerms}",
1475  "UTF-8",
1476  NULL,
1477  NULL,
1478  SEARCH_ENGINE_POGODAK,
1479  IDR_SEARCH_ENGINE_LOGO_POGODAK,
1480  24,
1481};
1482
1483const PrepopulatedEngine pogodak_hr = {
1484  L"Pogodak!",
1485  L"pogodak.hr",
1486  "http://www.pogodak.hr/favicon.ico",
1487  L"http://www.pogodak.hr/search.jsp?q={searchTerms}",
1488  "UTF-8",
1489  NULL,
1490  NULL,
1491  SEARCH_ENGINE_POGODAK,
1492  IDR_SEARCH_ENGINE_LOGO_POGODAK,
1493  24,
1494};
1495
1496const PrepopulatedEngine pogodak_rs = {
1497  L"Pogodak!",
1498  L"pogodak.rs",
1499  "http://www.pogodak.rs/favicon.ico",
1500  L"http://www.pogodak.rs/search.jsp?q={searchTerms}",
1501  "UTF-8",
1502  NULL,
1503  NULL,
1504  SEARCH_ENGINE_POGODAK,
1505  IDR_SEARCH_ENGINE_LOGO_POGODAK,
1506  24,
1507};
1508
1509const PrepopulatedEngine pogodok = {
1510  L"\x041f\x043e\x0433\x043e\x0434\x043e\x043a!",
1511  L"pogodok.com.mk",
1512  "http://www.pogodok.com.mk/favicon.ico",
1513  L"http://www.pogodok.com.mk/search.jsp?q={searchTerms}",
1514  "UTF-8",
1515  NULL,
1516  NULL,
1517  SEARCH_ENGINE_POGODOK_MK,
1518  IDR_SEARCH_ENGINE_LOGO_POGODOK_MK,
1519  24,  // Really the same engine as Pogodak, just has a small name change.
1520};
1521
1522const PrepopulatedEngine rambler = {
1523  L"Rambler",
1524  L"rambler.ru",
1525  "http://www.rambler.ru/favicon.ico",
1526  L"http://www.rambler.ru/srch?words={searchTerms}",
1527  "windows-1251",
1528  NULL,
1529  NULL,
1530  SEARCH_ENGINE_RAMBLER,
1531  IDR_SEARCH_ENGINE_LOGO_RAMBLER,
1532  16,
1533};
1534
1535const PrepopulatedEngine rediff = {
1536  L"Rediff",
1537  L"rediff.com",
1538  "http://search1.rediff.com/favicon.ico",
1539  L"http://search1.rediff.com/dirsrch/default.asp?MT={searchTerms}",
1540  "UTF-8",
1541  NULL,
1542  NULL,
1543  SEARCH_ENGINE_OTHER,
1544  kNoSearchEngineLogo,
1545  37,
1546};
1547
1548const PrepopulatedEngine rednano = {
1549  L"Rednano",
1550  L"rednano.sg",
1551  "http://rednano.sg/favicon.ico",
1552  L"http://rednano.sg/sfe/lwi.action?querystring={searchTerms}",
1553  "UTF-8",
1554  NULL,
1555  NULL,
1556  SEARCH_ENGINE_OTHER,
1557  kNoSearchEngineLogo,
1558  41,
1559};
1560
1561const PrepopulatedEngine sanook = {
1562  L"\x0e2a\x0e19\x0e38\x0e01!",
1563  L"sanook.com",
1564  "http://search.sanook.com/favicon.ico",
1565  L"http://search.sanook.com/search.php?q={searchTerms}",
1566  "UTF-8",
1567  NULL,
1568  NULL,
1569  SEARCH_ENGINE_SANOOK,
1570  IDR_SEARCH_ENGINE_LOGO_SANOOK,
1571  100,
1572};
1573
1574const PrepopulatedEngine sapo = {
1575  L"SAPO",
1576  L"sapo.pt",
1577  "http://imgs.sapo.pt/images/sapo.ico",
1578  L"http://pesquisa.sapo.pt/?q={searchTerms}",
1579  "UTF-8",
1580  L"http://pesquisa.sapo.pt/livesapo?q={searchTerms}",
1581  NULL,
1582  SEARCH_ENGINE_SAPO,
1583  IDR_SEARCH_ENGINE_LOGO_SAPO,
1584  77,
1585};
1586
1587const PrepopulatedEngine search_de_CH = {
1588  L"search.ch",
1589  L"search.ch",
1590  "http://www.search.ch/favicon.ico",
1591  L"http://www.search.ch/index.de.html?q={searchTerms}",
1592  "ISO-8859-1",
1593  NULL,
1594  NULL,
1595  SEARCH_ENGINE_OTHER,
1596  kNoSearchEngineLogo,
1597  51,
1598};
1599
1600const PrepopulatedEngine search_fr_CH = {
1601  L"search.ch",
1602  L"",  // search.ch is taken by search_de_CH.
1603  "http://www.search.ch/favicon.ico",
1604  L"http://www.search.ch/index.fr.html?q={searchTerms}",
1605  "ISO-8859-1",
1606  NULL,
1607  NULL,
1608  SEARCH_ENGINE_OTHER,
1609  kNoSearchEngineLogo,
1610  22,
1611};
1612
1613const PrepopulatedEngine seznam = {
1614  L"Seznam",
1615  L"seznam.cz",
1616  "http://1.im.cz/szn/img/favicon.ico",
1617  L"http://search.seznam.cz/?q={searchTerms}",
1618  "UTF-8",
1619  L"http:///suggest.fulltext.seznam.cz/?dict=fulltext_ff&phrase={searchTerms}&"
1620      L"encoding={inputEncoding}&response_encoding=utf-8",
1621  NULL,
1622  SEARCH_ENGINE_SEZNAM,
1623  IDR_SEARCH_ENGINE_LOGO_SEZNAM,
1624  25,
1625};
1626
1627const PrepopulatedEngine spray = {
1628  L"Spray",
1629  L"spray.se",
1630  "http://www.eniro.se/favicon.ico",
1631  L"http://www.eniro.se/query?ax=spray&search_word={searchTerms}&what=web",
1632  "ISO-8859-1",
1633  NULL,
1634  NULL,
1635  SEARCH_ENGINE_OTHER,
1636  kNoSearchEngineLogo,
1637  99,
1638};
1639
1640const PrepopulatedEngine terra_ar = {
1641  L"Terra Argentina",
1642  L"terra.com.ar",
1643  "http://buscar.terra.com.ar/favicon.ico",
1644  L"http://buscar.terra.com.ar/Default.aspx?query={searchTerms}&source=Search",
1645  "ISO-8859-1",
1646  NULL,
1647  NULL,
1648  SEARCH_ENGINE_OTHER,
1649  kNoSearchEngineLogo,
1650  90,
1651};
1652
1653const PrepopulatedEngine terra_es = {
1654  L"Terra",
1655  L"terra.es",
1656  "http://buscador.terra.es/favicon.ico",
1657  L"http://buscador.terra.es/Default.aspx?query={searchTerms}&source=Search",
1658  "ISO-8859-1",
1659  NULL,
1660  NULL,
1661  SEARCH_ENGINE_OTHER,
1662  kNoSearchEngineLogo,
1663  90,
1664};
1665
1666const PrepopulatedEngine tut = {
1667  L"TUT.BY",
1668  L"tut.by",
1669  "http://www.tut.by/favicon.ico",
1670  L"http://search.tut.by/?query={searchTerms}",
1671  "windows-1251",
1672  NULL,
1673  NULL,
1674  SEARCH_ENGINE_TUT,
1675  IDR_SEARCH_ENGINE_LOGO_TUT,
1676  17,
1677};
1678
1679const PrepopulatedEngine uol = {
1680  L"UOL Busca",
1681  L"busca.uol.com.br",
1682  "http://busca.uol.com.br/favicon.ico",
1683  L"http://busca.uol.com.br/www/index.html?q={searchTerms}",
1684  "ISO-8859-1",
1685  NULL,
1686  NULL,
1687  SEARCH_ENGINE_OTHER,
1688  kNoSearchEngineLogo,
1689  82,
1690};
1691
1692const PrepopulatedEngine virgilio = {
1693  L"Virgilio",
1694  L"virgilio.it",
1695  "http://ricerca.alice.it/favicon.ico",
1696  L"http://ricerca.alice.it/ricerca?qs={searchTerms}",
1697  "ISO-8859-1",
1698  NULL,
1699  NULL,
1700  SEARCH_ENGINE_VIRGILIO,
1701  IDR_SEARCH_ENGINE_LOGO_VIRGILIO,
1702  62,
1703};
1704
1705const PrepopulatedEngine walla = {
1706  L"\x05d5\x05d5\x05d0\x05dc\x05d4!",
1707  L"walla.co.il",
1708  "http://www.walla.co.il/favicon.ico",
1709  L"http://search.walla.co.il/?e=hew&q={searchTerms}",
1710  "windows-1255",
1711  NULL,
1712  NULL,
1713  SEARCH_ENGINE_WALLA,
1714  IDR_SEARCH_ENGINE_LOGO_WALLA,
1715  55,
1716};
1717
1718const PrepopulatedEngine wp = {
1719  L"Wirtualna Polska",
1720  L"wp.pl",
1721  "http://szukaj.wp.pl/favicon.ico",
1722  L"http://szukaj.wp.pl/szukaj.html?szukaj={searchTerms}",
1723  "ISO-8859-2",
1724  NULL,
1725  NULL,
1726  SEARCH_ENGINE_OTHER,
1727  kNoSearchEngineLogo,
1728  76,
1729};
1730
1731const PrepopulatedEngine yahoo = {
1732  L"Yahoo!",
1733  L"yahoo.com",
1734  "http://search.yahoo.com/favicon.ico",
1735  L"http://search.yahoo.com/search?ei={inputEncoding}&fr=crmas&p={searchTerms}",
1736  "UTF-8",
1737  L"http://ff.search.yahoo.com/gossip?output=fxjson&command={searchTerms}",
1738  NULL,
1739  SEARCH_ENGINE_YAHOO,
1740  IDR_SEARCH_ENGINE_LOGO_YAHOO,
1741  2,
1742};
1743
1744// For regional Yahoo variants without region-specific suggestion service,
1745// suggestion is disabled. For some of them, we might consider
1746// using a fallback (e.g. de for at/ch, ca or fr for qc, en for nl, no, hk).
1747const PrepopulatedEngine yahoo_ar = {
1748  L"Yahoo! Argentina",
1749  L"ar.yahoo.com",
1750  "http://ar.search.yahoo.com/favicon.ico",
1751  L"http://ar.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
1752      L"p={searchTerms}",
1753  "UTF-8",
1754  L"http://ar-sayt.ff.search.yahoo.com/gossip-ar-sayt?output=fxjson&"
1755      L"command={searchTerms}",
1756  NULL,
1757  SEARCH_ENGINE_YAHOO,
1758  IDR_SEARCH_ENGINE_LOGO_YAHOO,
1759  2,
1760};
1761
1762const PrepopulatedEngine yahoo_at = {
1763  L"Yahoo! Suche",
1764  L"at.yahoo.com",
1765  "http://at.search.yahoo.com/favicon.ico",
1766  L"http://at.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
1767      L"p={searchTerms}",
1768  "UTF-8",
1769  NULL,
1770  NULL,
1771  SEARCH_ENGINE_YAHOO,
1772  IDR_SEARCH_ENGINE_LOGO_YAHOO,
1773  2,
1774};
1775
1776const PrepopulatedEngine yahoo_au = {
1777  L"Yahoo!7",
1778  L"au.yahoo.com",
1779  "http://au.search.yahoo.com/favicon.ico",
1780  L"http://au.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
1781      L"p={searchTerms}",
1782  "UTF-8",
1783  L"http://aue-sayt.ff.search.yahoo.com/gossip-au-sayt?output=fxjson&"
1784      L"command={searchTerms}",
1785  NULL,
1786  SEARCH_ENGINE_YAHOO,
1787  IDR_SEARCH_ENGINE_LOGO_YAHOO,
1788  2,
1789};
1790
1791const PrepopulatedEngine yahoo_br = {
1792  L"Yahoo! Brasil",
1793  L"br.yahoo.com",
1794  "http://br.search.yahoo.com/favicon.ico",
1795  L"http://br.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
1796      L"p={searchTerms}",
1797  "UTF-8",
1798  L"http://br-sayt.ff.search.yahoo.com/gossip-br-sayt?output=fxjson&"
1799      L"command={searchTerms}",
1800  NULL,
1801  SEARCH_ENGINE_YAHOO,
1802  IDR_SEARCH_ENGINE_LOGO_YAHOO,
1803  2,
1804};
1805
1806const PrepopulatedEngine yahoo_ca = {
1807  L"Yahoo! Canada",
1808  L"ca.yahoo.com",
1809  "http://ca.search.yahoo.com/favicon.ico",
1810  L"http://ca.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
1811      L"p={searchTerms}",
1812  "UTF-8",
1813  L"http://gossip.ca.yahoo.com/gossip-ca-sayt?output=fxjsonp&"
1814      L"command={searchTerms}",
1815  NULL,
1816  SEARCH_ENGINE_YAHOO,
1817  IDR_SEARCH_ENGINE_LOGO_YAHOO,
1818  2,
1819};
1820
1821const PrepopulatedEngine yahoo_ch = {
1822  L"Yahoo! Suche",
1823  L"ch.yahoo.com",
1824  "http://ch.search.yahoo.com/favicon.ico",
1825  L"http://ch.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
1826      L"p={searchTerms}",
1827  "UTF-8",
1828  NULL,
1829  NULL,
1830  SEARCH_ENGINE_YAHOO,
1831  IDR_SEARCH_ENGINE_LOGO_YAHOO,
1832  2,
1833};
1834
1835const PrepopulatedEngine yahoo_cl = {
1836  L"Yahoo! Chile",
1837  L"cl.yahoo.com",
1838  "http://cl.search.yahoo.com/favicon.ico",
1839  L"http://cl.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
1840      L"p={searchTerms}",
1841  "UTF-8",
1842  L"http://gossip.telemundo.yahoo.com/gossip-e1-sayt?output=fxjson&"
1843      L"command={searchTerms}",
1844  NULL,
1845  SEARCH_ENGINE_YAHOO,
1846  IDR_SEARCH_ENGINE_LOGO_YAHOO,
1847  2,
1848};
1849
1850const PrepopulatedEngine yahoo_cn = {
1851  L"\x4e2d\x56fd\x96c5\x864e",
1852  L"cn.yahoo.com",
1853  "http://search.cn.yahoo.com/favicon.ico",
1854  L"http://search.cn.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
1855      L"p={searchTerms}",
1856  "GB2312",
1857  // http://cn.yahoo.com/cnsuggestion/suggestion.inc.php?of=fxjson&query=
1858  // returns in a proprietary format ('|' delimeted word list).
1859  NULL,
1860  NULL,
1861  SEARCH_ENGINE_YAHOO,
1862  IDR_SEARCH_ENGINE_LOGO_YAHOO,
1863  2,
1864};
1865
1866const PrepopulatedEngine yahoo_co = {
1867  L"Yahoo! Colombia",
1868  L"co.yahoo.com",
1869  "http://co.search.yahoo.com/favicon.ico",
1870  L"http://co.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
1871      L"p={searchTerms}",
1872  "UTF-8",
1873  L"http://gossip.telemundo.yahoo.com/gossip-e1-sayt?output=fxjson&"
1874      L"command={searchTerms}",
1875  NULL,
1876  SEARCH_ENGINE_YAHOO,
1877  IDR_SEARCH_ENGINE_LOGO_YAHOO,
1878  2,
1879};
1880
1881const PrepopulatedEngine yahoo_de = {
1882  L"Yahoo! Deutschland",
1883  L"de.yahoo.com",
1884  "http://de.search.yahoo.com/favicon.ico",
1885  L"http://de.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
1886      L"p={searchTerms}",
1887  "UTF-8",
1888  L"http://de-sayt.ff.search.yahoo.com/gossip-de-sayt?output=fxjson&"
1889      L"command={searchTerms}",
1890  NULL,
1891  SEARCH_ENGINE_YAHOO,
1892  IDR_SEARCH_ENGINE_LOGO_YAHOO,
1893  2,
1894};
1895
1896const PrepopulatedEngine yahoo_dk = {
1897  L"Yahoo! Danmark",
1898  L"dk.yahoo.com",
1899  "http://dk.search.yahoo.com/favicon.ico",
1900  L"http://dk.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
1901      L"p={searchTerms}",
1902  "UTF-8",
1903  NULL,
1904  NULL,
1905  SEARCH_ENGINE_YAHOO,
1906  IDR_SEARCH_ENGINE_LOGO_YAHOO,
1907  2,
1908};
1909
1910const PrepopulatedEngine yahoo_es = {
1911  L"Yahoo! Espa" L"\x00f1" L"a",
1912  L"es.yahoo.com",
1913  "http://es.search.yahoo.com/favicon.ico",
1914  L"http://es.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
1915      L"p={searchTerms}",
1916  "UTF-8",
1917  L"http://es-sayt.ff.search.yahoo.com/gossip-es-sayt?output=fxjson&"
1918      L"command={searchTerms}",
1919  NULL,
1920  SEARCH_ENGINE_YAHOO,
1921  IDR_SEARCH_ENGINE_LOGO_YAHOO,
1922  2,
1923};
1924
1925const PrepopulatedEngine yahoo_fi = {
1926  L"Yahoo!-haku",
1927  L"fi.yahoo.com",
1928  "http://fi.search.yahoo.com/favicon.ico",
1929  L"http://fi.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
1930      L"p={searchTerms}",
1931  "UTF-8",
1932  NULL,
1933  NULL,
1934  SEARCH_ENGINE_YAHOO,
1935  IDR_SEARCH_ENGINE_LOGO_YAHOO,
1936  2,
1937};
1938
1939const PrepopulatedEngine yahoo_fr = {
1940  L"Yahoo! France",
1941  L"fr.yahoo.com",
1942  "http://fr.search.yahoo.com/favicon.ico",
1943  L"http://fr.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
1944      L"p={searchTerms}",
1945  "UTF-8",
1946  L"http://fr-sayt.ff.search.yahoo.com/gossip-fr-sayt?output=fxjson&"
1947      L"command={searchTerms}",
1948  NULL,
1949  SEARCH_ENGINE_YAHOO,
1950  IDR_SEARCH_ENGINE_LOGO_YAHOO,
1951  2,
1952};
1953
1954const PrepopulatedEngine yahoo_hk = {
1955  L"Yahoo! Hong Kong",
1956  L"hk.yahoo.com",
1957  "http://hk.search.yahoo.com/favicon.ico",
1958  L"http://hk.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
1959      L"p={searchTerms}",
1960  "UTF-8",
1961  // http://history.hk.search.yahoo.com/ac/ac_msearch.php?query={searchTerms}
1962  // returns a JSON with key-value pairs. Setting parameters (ot, of, output)
1963  // to fxjson, json, or js doesn't help.
1964  NULL,
1965  NULL,
1966  SEARCH_ENGINE_YAHOO,
1967  IDR_SEARCH_ENGINE_LOGO_YAHOO,
1968  2,
1969};
1970
1971const PrepopulatedEngine yahoo_id = {
1972  L"Yahoo! Indonesia",
1973  L"id.yahoo.com",
1974  "http://id.search.yahoo.com/favicon.ico",
1975  L"http://id.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
1976      L"p={searchTerms}",
1977  "UTF-8",
1978  L"http://id-sayt.ff.search.yahoo.com/gossip-id-sayt?output=fxjson&"
1979      L"command={searchTerms}",
1980  NULL,
1981  SEARCH_ENGINE_YAHOO,
1982  IDR_SEARCH_ENGINE_LOGO_YAHOO,
1983  2,
1984};
1985
1986const PrepopulatedEngine yahoo_in = {
1987  L"Yahoo! India",
1988  L"in.yahoo.com",
1989  "http://in.search.yahoo.com/favicon.ico",
1990  L"http://in.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
1991      L"p={searchTerms}",
1992  "UTF-8",
1993  L"http://in-sayt.ff.search.yahoo.com/gossip-in-sayt?output=fxjson&"
1994      L"command={searchTerms}",
1995  NULL,
1996  SEARCH_ENGINE_YAHOO,
1997  IDR_SEARCH_ENGINE_LOGO_YAHOO,
1998  2,
1999};
2000
2001const PrepopulatedEngine yahoo_it = {
2002  L"Yahoo! Italia",
2003  L"it.yahoo.com",
2004  "http://it.search.yahoo.com/favicon.ico",
2005  L"http://it.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
2006      L"p={searchTerms}",
2007  "UTF-8",
2008  L"http://it-sayt.ff.search.yahoo.com/gossip-it-sayt?output=fxjson&"
2009      L"command={searchTerms}",
2010  NULL,
2011  SEARCH_ENGINE_YAHOO,
2012  IDR_SEARCH_ENGINE_LOGO_YAHOO,
2013  2,
2014};
2015
2016const PrepopulatedEngine yahoo_jp = {
2017  L"Yahoo! JAPAN",
2018  L"yahoo.co.jp",
2019  "http://search.yahoo.co.jp/favicon.ico",
2020  L"http://search.yahoo.co.jp/search?ei={inputEncoding}&fr=crmas&"
2021      L"p={searchTerms}",
2022  "UTF-8",
2023  NULL,
2024  NULL,
2025  SEARCH_ENGINE_YAHOOJP,
2026  IDR_SEARCH_ENGINE_LOGO_YAHOOJP,
2027  2,
2028};
2029
2030const PrepopulatedEngine yahoo_kr = {
2031  L"\xc57c\xd6c4! \xcf54\xb9ac\xc544",
2032  L"kr.yahoo.com",
2033  "http://kr.search.yahoo.com/favicon.ico",
2034  L"http://kr.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
2035      L"p={searchTerms}",
2036  "UTF-8",
2037  L"http://kr.atc.search.yahoo.com/atcx.php?property=main&ot=fxjson&"
2038     L"ei=utf8&eo=utf8&command={searchTerms}",
2039  NULL,
2040  SEARCH_ENGINE_YAHOO,
2041  IDR_SEARCH_ENGINE_LOGO_YAHOO,
2042  2,
2043};
2044
2045const PrepopulatedEngine yahoo_malaysia = {
2046  L"Yahoo! Malaysia",
2047  L"malaysia.yahoo.com",
2048  "http://malaysia.search.yahoo.com/favicon.ico",
2049  L"http://malaysia.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
2050      L"p={searchTerms}",
2051  "UTF-8",
2052  L"http://my-sayt.ff.search.yahoo.com/gossip-my-sayt?output=fxjson&"
2053      L"command={searchTerms}",
2054  NULL,
2055  SEARCH_ENGINE_YAHOO,
2056  IDR_SEARCH_ENGINE_LOGO_YAHOO,
2057  2,
2058};
2059
2060const PrepopulatedEngine yahoo_mx = {
2061  L"Yahoo! M\x00e9xico",
2062  L"mx.yahoo.com",
2063  "http://mx.search.yahoo.com/favicon.ico",
2064  L"http://mx.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
2065      L"p={searchTerms}",
2066  "UTF-8",
2067  L"http://gossip.mx.yahoo.com/gossip-mx-sayt?output=fxjsonp&"
2068      L"command={searchTerms}",
2069  NULL,
2070  SEARCH_ENGINE_YAHOO,
2071  IDR_SEARCH_ENGINE_LOGO_YAHOO,
2072  2,
2073};
2074
2075const PrepopulatedEngine yahoo_nl = {
2076  L"Yahoo! Nederland",
2077  L"nl.yahoo.com",
2078  "http://nl.search.yahoo.com/favicon.ico",
2079  L"http://nl.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
2080      L"p={searchTerms}",
2081  "UTF-8",
2082  NULL,
2083  NULL,
2084  SEARCH_ENGINE_YAHOO,
2085  IDR_SEARCH_ENGINE_LOGO_YAHOO,
2086  2,
2087};
2088
2089const PrepopulatedEngine yahoo_no = {
2090  L"Yahoo! Norge",
2091  L"no.yahoo.com",
2092  "http://no.search.yahoo.com/favicon.ico",
2093  L"http://no.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
2094      L"p={searchTerms}",
2095  "UTF-8",
2096  NULL,
2097  NULL,
2098  SEARCH_ENGINE_YAHOO,
2099  IDR_SEARCH_ENGINE_LOGO_YAHOO,
2100  2,
2101};
2102
2103const PrepopulatedEngine yahoo_nz = {
2104  L"Yahoo!Xtra",
2105  L"nz.yahoo.com",
2106  "http://nz.search.yahoo.com/favicon.ico",
2107  L"http://nz.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
2108      L"p={searchTerms}",
2109  "UTF-8",
2110  L"http://aue-sayt.ff.search.yahoo.com/gossip-nz-sayt?output=fxjson&"
2111      L"command={searchTerms}",
2112  NULL,
2113  SEARCH_ENGINE_YAHOO,
2114  IDR_SEARCH_ENGINE_LOGO_YAHOO,
2115  2,
2116};
2117
2118const PrepopulatedEngine yahoo_pe = {
2119  L"Yahoo! Per\x00fa",
2120  L"pe.yahoo.com",
2121  "http://pe.search.yahoo.com/favicon.ico",
2122  L"http://pe.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
2123      L"p={searchTerms}",
2124  "UTF-8",
2125  L"http://gossip.telemundo.yahoo.com/gossip-e1-sayt?output=fxjson&"
2126      L"command={searchTerms}",
2127  NULL,
2128  SEARCH_ENGINE_YAHOO,
2129  IDR_SEARCH_ENGINE_LOGO_YAHOO,
2130  2,
2131};
2132
2133const PrepopulatedEngine yahoo_ph = {
2134  L"Yahoo! Philippines",
2135  L"ph.yahoo.com",
2136  "http://ph.search.yahoo.com/favicon.ico",
2137  L"http://ph.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
2138      L"p={searchTerms}",
2139  "UTF-8",
2140  L"http://ph-sayt.ff.search.yahoo.com/gossip-ph-sayt?output=fxjson&"
2141      L"command={searchTerms}",
2142  NULL,
2143  SEARCH_ENGINE_YAHOO,
2144  IDR_SEARCH_ENGINE_LOGO_YAHOO,
2145  2,
2146};
2147
2148const PrepopulatedEngine yahoo_qc = {
2149  L"Yahoo! Qu" L"\x00e9" L"bec",
2150  L"qc.yahoo.com",
2151  "http://qc.search.yahoo.com/favicon.ico",
2152  L"http://qc.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
2153      L"p={searchTerms}",
2154  "UTF-8",
2155  NULL,
2156  NULL,
2157  SEARCH_ENGINE_YAHOOQC,
2158  IDR_SEARCH_ENGINE_LOGO_YAHOOQC,
2159  5,  // Can't be 2 as this has to appear in the Canada list alongside yahoo_ca.
2160};
2161
2162const PrepopulatedEngine yahoo_ru = {
2163  L"Yahoo! \x043f\x043e-\x0440\x0443\x0441\x0441\x043a\x0438",
2164  L"ru.yahoo.com",
2165  "http://ru.search.yahoo.com/favicon.ico",
2166  L"http://ru.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
2167      L"p={searchTerms}",
2168  "UTF-8",
2169  NULL,
2170  NULL,
2171  SEARCH_ENGINE_YAHOO,
2172  IDR_SEARCH_ENGINE_LOGO_YAHOO,
2173  2,
2174};
2175
2176const PrepopulatedEngine yahoo_se = {
2177  L"Yahoo! Sverige",
2178  L"se.yahoo.com",
2179  "http://se.search.yahoo.com/favicon.ico",
2180  L"http://se.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
2181      L"p={searchTerms}",
2182  "UTF-8",
2183  NULL,
2184  NULL,
2185  SEARCH_ENGINE_YAHOO,
2186  IDR_SEARCH_ENGINE_LOGO_YAHOO,
2187  2,
2188};
2189
2190const PrepopulatedEngine yahoo_sg = {
2191  L"Yahoo! Singapore",
2192  L"sg.yahoo.com",
2193  "http://sg.search.yahoo.com/favicon.ico",
2194  L"http://sg.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
2195      L"p={searchTerms}",
2196  "UTF-8",
2197  L"http://sg-sayt.ff.search.yahoo.com/gossip-sg-sayt?output=fxjson&"
2198      L"command={searchTerms}",
2199  NULL,
2200  SEARCH_ENGINE_YAHOO,
2201  IDR_SEARCH_ENGINE_LOGO_YAHOO,
2202  2,
2203};
2204
2205const PrepopulatedEngine yahoo_th = {
2206  L"Yahoo! \x0e1b\x0e23\x0e30\x0e40\x0e17\x0e28\x0e44\x0e17\x0e22",
2207  L"th.yahoo.com",
2208  "http://th.search.yahoo.com/favicon.ico",
2209  L"http://th.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
2210      L"p={searchTerms}",
2211  "UTF-8",
2212  L"http://th-sayt.ff.search.yahoo.com/gossip-th-sayt?output=fxjson&"
2213      L"command={searchTerms}",
2214  NULL,
2215  SEARCH_ENGINE_YAHOO,
2216  IDR_SEARCH_ENGINE_LOGO_YAHOO,
2217  2,
2218};
2219
2220const PrepopulatedEngine yahoo_tw = {
2221  L"Yahoo!\x5947\x6469",
2222  L"tw.yahoo.com",
2223  "http://tw.search.yahoo.com/favicon.ico",
2224  L"http://tw.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
2225      L"p={searchTerms}",
2226  "UTF-8",
2227  // "http://tw.yahoo.com/ac/ac_search.php?eo=utf8&of=js&prop=web&query="
2228  // returns a JSON file prepended with 'fxsearch=('.
2229  NULL,
2230  NULL,
2231  SEARCH_ENGINE_YAHOO,
2232  IDR_SEARCH_ENGINE_LOGO_YAHOO,
2233  2,
2234};
2235
2236const PrepopulatedEngine yahoo_uk = {
2237  L"Yahoo! UK & Ireland",
2238  L"uk.yahoo.com",
2239  "http://uk.search.yahoo.com/favicon.ico",
2240  L"http://uk.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
2241      L"p={searchTerms}",
2242  "UTF-8",
2243  L"http://uk-sayt.ff.search.yahoo.com/gossip-uk-sayt?output=fxjson&"
2244      L"command={searchTerms}",
2245  NULL,
2246  SEARCH_ENGINE_YAHOO,
2247  IDR_SEARCH_ENGINE_LOGO_YAHOO,
2248  2,
2249};
2250
2251const PrepopulatedEngine yahoo_ve = {
2252  L"Yahoo! Venezuela",
2253  L"ve.yahoo.com",
2254  "http://ve.search.yahoo.com/favicon.ico",
2255  L"http://ve.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
2256      L"p={searchTerms}",
2257  "UTF-8",
2258  L"http://gossip.telemundo.yahoo.com/gossip-e1-sayt?output=fxjson&"
2259      L"command={searchTerms}",
2260  NULL,
2261  SEARCH_ENGINE_YAHOO,
2262  IDR_SEARCH_ENGINE_LOGO_YAHOO,
2263  2,
2264};
2265
2266const PrepopulatedEngine yahoo_vn = {
2267  L"Yahoo! Vi\x1ec7t Nam",
2268  L"vn.yahoo.com",
2269  "http://vn.search.yahoo.com/favicon.ico",
2270  L"http://vn.search.yahoo.com/search?ei={inputEncoding}&fr=crmas&"
2271      L"p={searchTerms}",
2272  "UTF-8",
2273  L"http://vn-sayt.ff.search.yahoo.com/gossip-vn-sayt?output=fxjson&"
2274      L"command={searchTerms}",
2275  NULL,
2276  SEARCH_ENGINE_YAHOO,
2277  IDR_SEARCH_ENGINE_LOGO_YAHOO,
2278  2,
2279};
2280
2281const PrepopulatedEngine yamli = {
2282  L"Yamli",
2283  L"yamli.com",
2284  "http://www.yamli.com/favicon.ico",
2285  L"http://www.yamli.com/#q={searchTerms}",
2286  "UTF-8",
2287  NULL,
2288  NULL,
2289  SEARCH_ENGINE_OTHER,
2290  kNoSearchEngineLogo,
2291  11,
2292};
2293
2294const PrepopulatedEngine yandex_ru = {
2295  L"\x042f\x043d\x0434\x0435\x043a\x0441",
2296  L"yandex.ru",
2297  "http://yandex.ru/favicon.ico",
2298  L"http://yandex.ru/yandsearch?text={searchTerms}",
2299  "UTF-8",
2300  L"http://suggest.yandex.net/suggest-ff.cgi?part={searchTerms}",
2301  NULL,
2302  SEARCH_ENGINE_YANDEX,
2303  IDR_SEARCH_ENGINE_LOGO_YANDEX,
2304  15,
2305};
2306
2307const PrepopulatedEngine yandex_ua = {
2308  L"\x042f\x043d\x0434\x0435\x043a\x0441",
2309  L"yandex.ua",
2310  "http://yandex.ua/favicon.ico",
2311  L"http://yandex.ua/yandsearch?text={searchTerms}",
2312  "UTF-8",
2313  L"http://suggest.yandex.net/suggest-ff.cgi?part={searchTerms}",
2314  NULL,
2315  SEARCH_ENGINE_YANDEX,
2316  IDR_SEARCH_ENGINE_LOGO_YANDEX,
2317  15,
2318};
2319
2320const PrepopulatedEngine zoznam = {
2321  L"Zoznam",
2322  L"zoznam.sk",
2323  "http://zoznam.sk/favicon.ico",
2324  L"http://zoznam.sk/hladaj.fcgi?s={searchTerms}",
2325  "windows-1250",
2326  NULL,
2327  NULL,
2328  SEARCH_ENGINE_ZOZNAM,
2329  IDR_SEARCH_ENGINE_LOGO_ZOZNAM,
2330  85,
2331};
2332
2333// Lists of engines per country ////////////////////////////////////////////////
2334
2335// Put these in order with most interesting/important first.  The default will
2336// be the first engine.
2337
2338// Default (for countries with no better engine set)
2339const PrepopulatedEngine* engines_default[] =
2340    { &google, &yahoo, &bing, };
2341
2342// United Arab Emirates
2343const PrepopulatedEngine* engines_AE[] =
2344    { &google, &yahoo, &bing_en_XA, &bing_ar_XA, &araby, &maktoob, };
2345
2346// Albania
2347const PrepopulatedEngine* engines_AL[] =
2348    { &google, &yahoo, &bing_en_XA, };
2349
2350// Argentina
2351const PrepopulatedEngine* engines_AR[] =
2352    { &google, &yahoo_ar, &bing_es_AR, &terra_ar, &altavista_ar, };
2353
2354// Austria
2355const PrepopulatedEngine* engines_AT[] =
2356    { &google, &yahoo_at, &bing_de_AT, };
2357
2358// Australia
2359const PrepopulatedEngine* engines_AU[] =
2360    { &google, &bing_en_AU, &yahoo_au, };
2361
2362// Bosnia and Herzegovina
2363const PrepopulatedEngine* engines_BA[] =
2364    { &google, &pogodak_ba, &yahoo, &bing, };
2365
2366// Belgium
2367const PrepopulatedEngine* engines_BE[] =
2368    { &google, &bing_nl_BE, &yahoo, &bing_fr_BE, };
2369
2370// Bulgaria
2371const PrepopulatedEngine* engines_BG[] =
2372    { &google, &bing_bg_BG, &yahoo, &diri, &jabse, };
2373
2374// Bahrain
2375const PrepopulatedEngine* engines_BH[] =
2376    { &google, &yahoo, &bing_en_XA, &bing_ar_XA, };
2377
2378// Burundi
2379const PrepopulatedEngine* engines_BI[] =
2380    { &google, &yahoo, &bing, };
2381
2382// Brunei
2383const PrepopulatedEngine* engines_BN[] =
2384    { &google, &yahoo_malaysia, &bing_en_MY, };
2385
2386// Bolivia
2387const PrepopulatedEngine* engines_BO[] =
2388    { &google, &altavista, &bing_es_XL, &yahoo, };
2389
2390// Brazil
2391const PrepopulatedEngine* engines_BR[] =
2392    { &google, &bing_pt_BR, &yahoo_br, &uol, };
2393
2394// Belarus
2395const PrepopulatedEngine* engines_BY[] =
2396    { &google, &tut, &yandex_ru, &rambler, &yahoo, };
2397
2398// Belize
2399const PrepopulatedEngine* engines_BZ[] =
2400    { &google, &yahoo, &bing, &aol, };
2401
2402// Canada
2403const PrepopulatedEngine* engines_CA[] =
2404    { &google, &yahoo_ca, &yahoo_qc, &bing_en_CA, &bing_fr_CA, };
2405
2406// Switzerland
2407const PrepopulatedEngine* engines_CH[] =
2408    { &google, &yahoo_ch, &bing_de_CH, &bing_fr_CH, &search_de_CH,
2409      &search_fr_CH, };
2410
2411// Chile
2412const PrepopulatedEngine* engines_CL[] =
2413    { &google, &yahoo_cl, &bing_es_CL, };
2414
2415// China
2416const PrepopulatedEngine* engines_CN[] =
2417    { &google, &baidu, &yahoo_cn, &bing_zh_CN, };
2418
2419// Colombia
2420const PrepopulatedEngine* engines_CO[] =
2421    { &google, &bing_es_XL, &yahoo_co, };
2422
2423// Costa Rica
2424const PrepopulatedEngine* engines_CR[] =
2425    { &google, &bing_es_XL, &yahoo, };
2426
2427// Czech Republic
2428const PrepopulatedEngine* engines_CZ[] =
2429    { &google, &seznam, &bing_cs_CZ, &centrum_cz, &atlas_cz, };
2430
2431// Germany
2432const PrepopulatedEngine* engines_DE[] =
2433    { &google, &ask_de, &bing_de_DE, &yahoo_de };
2434
2435// Denmark
2436const PrepopulatedEngine* engines_DK[] =
2437    { &google, &bing_da_DK, &yahoo_dk, };
2438
2439// Dominican Republic
2440const PrepopulatedEngine* engines_DO[] =
2441    { &google, &bing_es_XL, &yahoo, };
2442
2443// Algeria
2444const PrepopulatedEngine* engines_DZ[] =
2445    { &google, &bing_en_XA, &yahoo, &bing_ar_XA, &maktoob, };
2446
2447// Ecuador
2448const PrepopulatedEngine* engines_EC[] =
2449    { &google, &bing_es_XL, &yahoo, };
2450
2451// Estonia
2452const PrepopulatedEngine* engines_EE[] =
2453    { &google, &bing_et_EE, &neti, &yahoo, };
2454
2455// Egypt
2456const PrepopulatedEngine* engines_EG[] =
2457    { &google, &yahoo, &bing_en_XA, &bing_ar_XA, &masrawy, };
2458
2459// Spain
2460const PrepopulatedEngine* engines_ES[] =
2461    { &google, &ask_es, &bing_es_ES, &yahoo_es, &terra_es, &hispavista, };
2462
2463// Faroe Islands
2464const PrepopulatedEngine* engines_FO[] =
2465    { &google, &bing_da_DK, &yahoo_dk, &jubii };
2466
2467// Finland
2468const PrepopulatedEngine* engines_FI[] =
2469    { &google, &bing_fi_FI, &yahoo_fi, &eniro_fi, &fonecta_02_fi, };
2470
2471// France
2472const PrepopulatedEngine* engines_FR[] =
2473    { &google, &yahoo_fr, &bing_fr_FR, };
2474
2475// United Kingdom
2476const PrepopulatedEngine* engines_GB[] =
2477    { &google, &ask_uk, &yahoo_uk, &bing_en_GB, };
2478
2479// Greece
2480const PrepopulatedEngine* engines_GR[] =
2481    { &google, &yahoo, &in, &bing_el_GR };
2482
2483// Guatemala
2484const PrepopulatedEngine* engines_GT[] =
2485    { &google, &bing_es_XL, &yahoo, &ask_es, };
2486
2487// Hong Kong
2488const PrepopulatedEngine* engines_HK[] =
2489    { &google, &yahoo_hk, &bing_zh_HK, &baidu, };
2490
2491// Honduras
2492const PrepopulatedEngine* engines_HN[] =
2493    { &google, &bing_es_XL, &yahoo, &ask_es, };
2494
2495// Croatia
2496const PrepopulatedEngine* engines_HR[] =
2497    { &google, &yahoo, &pogodak_hr, &bing_hr_HR, };
2498
2499// Hungary
2500const PrepopulatedEngine* engines_HU[] =
2501    { &google, &ok, &bing_hu_HU, };
2502
2503// Indonesia
2504const PrepopulatedEngine* engines_ID[] =
2505    { &google, &yahoo_id, &bing_en_ID, };
2506
2507// Ireland
2508const PrepopulatedEngine* engines_IE[] =
2509    { &google, &yahoo_uk, &bing_en_IE, };
2510
2511// Israel
2512const PrepopulatedEngine* engines_IL[] =
2513    { &google, &walla, &bing_he_IL, };
2514
2515// India
2516const PrepopulatedEngine* engines_IN[] =
2517    { &google, &yahoo_in, &bing_en_IN, &rediff, &guruji, };
2518
2519// Iraq
2520const PrepopulatedEngine* engines_IQ[] =
2521    { &google, &yahoo, &bing_en_XA, &bing_ar_XA, &maktoob, &ask, };
2522
2523// Iran
2524const PrepopulatedEngine* engines_IR[] =
2525    { &google, &yahoo, };
2526
2527// Iceland
2528const PrepopulatedEngine* engines_IS[] =
2529    { &google, &yahoo, &bing, &leit, };
2530
2531// Italy
2532const PrepopulatedEngine* engines_IT[] =
2533    { &google, &ask_it, &virgilio, &bing_it_IT, &yahoo_it, &libero, };
2534
2535// Jamaica
2536const PrepopulatedEngine* engines_JM[] =
2537    { &google, &yahoo, &bing, &go, };
2538
2539// Jordan
2540const PrepopulatedEngine* engines_JO[] =
2541    { &google, &yahoo, &bing_en_XA, &bing_ar_XA, &maktoob, &araby, };
2542
2543// Japan
2544const PrepopulatedEngine* engines_JP[] =
2545    { &google, &yahoo_jp, &bing_ja_JP, &goo, };
2546
2547// Kenya
2548const PrepopulatedEngine* engines_KE[] =
2549    { &google, &yahoo, &bing, };
2550
2551// Kuwait
2552const PrepopulatedEngine* engines_KW[] =
2553    { &google, &bing_en_XA, &yahoo, &bing_ar_XA, &maktoob, &araby, };
2554
2555// South Korea
2556const PrepopulatedEngine* engines_KR[] =
2557    { &google, &naver, &daum, &yahoo_kr, &nate, };
2558
2559// Kazakhstan
2560const PrepopulatedEngine* engines_KZ[] =
2561    { &google, &rambler, &yandex_ru, &nur_kz, };
2562
2563// Lebanon
2564const PrepopulatedEngine* engines_LB[] =
2565    { &google, &yahoo, &bing_en_XA, &bing_ar_XA, &maktoob, &araby, };
2566
2567// Liechtenstein
2568const PrepopulatedEngine* engines_LI[] =
2569    { &google, &bing_de_DE, &yahoo_de, };
2570
2571// Lithuania
2572const PrepopulatedEngine* engines_LT[] =
2573    { &google, &delfi_lt, &yahoo, &bing_lt_LT, };
2574
2575// Luxembourg
2576const PrepopulatedEngine* engines_LU[] =
2577    { &google, &bing_fr_FR, &yahoo_fr, };
2578
2579// Latvia
2580const PrepopulatedEngine* engines_LV[] =
2581    { &google, &bing, &yandex_ru, &yahoo, &latne, };
2582
2583// Libya
2584const PrepopulatedEngine* engines_LY[] =
2585    { &google, &yahoo, &bing_en_XA, &bing_ar_XA, &maktoob, &ask, };
2586
2587// Morocco
2588const PrepopulatedEngine* engines_MA[] =
2589    { &google, &bing_en_XA, &yahoo, &bing_ar_XA, };
2590
2591// Monaco
2592const PrepopulatedEngine* engines_MC[] =
2593    { &google, &bing_fr_FR, &yahoo_fr, };
2594
2595// Moldova
2596const PrepopulatedEngine* engines_MD[] =
2597    { &google, &yandex_ru, &yahoo, &bing, };
2598
2599// Montenegro
2600const PrepopulatedEngine* engines_ME[] =
2601    { &google, &yahoo, &bing };
2602
2603// Macedonia
2604const PrepopulatedEngine* engines_MK[] =
2605    { &google, &pogodok, &yahoo, &bing, };
2606
2607// Mexico
2608const PrepopulatedEngine* engines_MX[] =
2609    { &google, &bing_es_MX, &yahoo_mx, };
2610
2611// Malaysia
2612const PrepopulatedEngine* engines_MY[] =
2613    { &google, &yahoo_malaysia, &bing_en_MY, };
2614
2615// Nicaragua
2616const PrepopulatedEngine* engines_NI[] =
2617    { &google, &bing_es_XL, &yahoo, &ask_es, };
2618
2619// Netherlands
2620const PrepopulatedEngine* engines_NL[] =
2621    { &google, &bing_nl_NL, &yahoo_nl, &ask_nl, };
2622
2623// Norway
2624const PrepopulatedEngine* engines_NO[] =
2625    { &google, &bing_nb_NO, &abcsok, &yahoo_no, &kvasir, };
2626
2627// New Zealand
2628const PrepopulatedEngine* engines_NZ[] =
2629    { &google, &yahoo_nz, &bing_en_NZ, };
2630
2631// Oman
2632const PrepopulatedEngine* engines_OM[] =
2633    { &google, &yahoo, &bing_en_XA, &bing_ar_XA, };
2634
2635// Panama
2636const PrepopulatedEngine* engines_PA[] =
2637    { &google, &bing_es_XL, &yahoo, &ask_es, };
2638
2639// Peru
2640const PrepopulatedEngine* engines_PE[] =
2641    { &google, &bing_es_XL, &yahoo_pe, };
2642
2643// Philippines
2644const PrepopulatedEngine* engines_PH[] =
2645    { &google, &yahoo_ph, &bing_en_PH, };
2646
2647// Pakistan
2648const PrepopulatedEngine* engines_PK[] =
2649    { &google, &yahoo, &bing, };
2650
2651// Puerto Rico
2652const PrepopulatedEngine* engines_PR[] =
2653    { &google, &bing_es_XL, &yahoo, &ask_es, };
2654
2655// Poland
2656const PrepopulatedEngine* engines_PL[] =
2657    { &google, &bing_pl_PL, &netsprint, &yahoo_uk, &onet, &wp,  };
2658
2659// Portugal
2660const PrepopulatedEngine* engines_PT[] =
2661    { &google, &sapo, &bing_pt_PT, &yahoo, };
2662
2663// Paraguay
2664const PrepopulatedEngine* engines_PY[] =
2665    { &google, &bing_es_XL, &yahoo, };
2666
2667// Qatar
2668const PrepopulatedEngine* engines_QA[] =
2669    { &google, &yahoo, &bing_en_XA, &bing_ar_XA, &maktoob, &araby };
2670
2671// Romania
2672const PrepopulatedEngine* engines_RO[] =
2673    { &google, &yahoo_uk, &bing_ro_RO, };
2674
2675// Serbia
2676const PrepopulatedEngine* engines_RS[] =
2677    { &google, &pogodak_rs, &bing, };
2678
2679// Russia
2680const PrepopulatedEngine* engines_RU[] =
2681    { &google, &yandex_ru, &mail_ru, &tut, &rambler, &bing_ru_RU, };
2682
2683// Rwanda
2684const PrepopulatedEngine* engines_RW[] =
2685    { &google, &yahoo, &bing, };
2686
2687// Saudi Arabia
2688const PrepopulatedEngine* engines_SA[] =
2689    { &google, &yahoo, &bing_en_XA, &bing_ar_XA, };
2690
2691// Sweden
2692const PrepopulatedEngine* engines_SE[] =
2693    { &google, &bing_sv_SE, &yahoo_se, &altavista_se, &spray, &eniro_se };
2694
2695// Singapore
2696const PrepopulatedEngine* engines_SG[] =
2697    { &google, &yahoo_sg, &bing_en_SG, &rednano, };
2698
2699// Slovenia
2700const PrepopulatedEngine* engines_SI[] =
2701    { &google, &najdi, &yahoo, &bing_sl_SI, };
2702
2703// Slovakia
2704const PrepopulatedEngine* engines_SK[] =
2705    { &google, &zoznam, &bing_sk_SK, &atlas_sk, &centrum_sk };
2706
2707// El Salvador
2708const PrepopulatedEngine* engines_SV[] =
2709    { &google, &bing_es_XL, &yahoo, };
2710
2711// Syria
2712const PrepopulatedEngine* engines_SY[] =
2713    { &google, &bing_en_XA, &yahoo, &bing_ar_XA, &maktoob, &yamli, };
2714
2715// Thailand
2716const PrepopulatedEngine* engines_TH[] =
2717    { &google, &sanook, &yahoo_th, &bing_th_TH, };
2718
2719// Tunisia
2720const PrepopulatedEngine* engines_TN[] =
2721    { &google, &bing_en_XA, &yahoo, &bing_ar_XA, &maktoob, &yamli };
2722
2723// Turkey
2724const PrepopulatedEngine* engines_TR[] =
2725    { &google, &bing_tr_TR, &yahoo, &mynet, };
2726
2727// Trinidad and Tobago
2728const PrepopulatedEngine* engines_TT[] =
2729    { &google, &bing, &yahoo, &aol, };
2730
2731// Taiwan
2732const PrepopulatedEngine* engines_TW[] =
2733    { &google, &yahoo_tw, &bing_zh_TW, };
2734
2735// Tanzania
2736const PrepopulatedEngine* engines_TZ[] =
2737    { &google, &yahoo, &bing, };
2738
2739// Ukraine
2740const PrepopulatedEngine* engines_UA[] =
2741    { &google, &yandex_ua, &mail_ru, &rambler, };
2742
2743// United States
2744const PrepopulatedEngine* engines_US[] =
2745    { &google, &yahoo, &bing_en_US, };
2746
2747// Uruguay
2748const PrepopulatedEngine* engines_UY[] =
2749    { &google, &bing_es_XL, &yahoo, };
2750
2751// Venezuela
2752const PrepopulatedEngine* engines_VE[] =
2753    { &google, &bing_es_XL, &yahoo_ve, };
2754
2755// Vietnam
2756const PrepopulatedEngine* engines_VN[] =
2757    { &google, &yahoo_vn, };
2758
2759// Yemen
2760const PrepopulatedEngine* engines_YE[] =
2761    { &google, &yahoo, &bing_en_XA, &bing_ar_XA, &maktoob, &araby, };
2762
2763// South Africa
2764const PrepopulatedEngine* engines_ZA[] =
2765    { &google, &yahoo, &bing_en_ZA, };
2766
2767// Zimbabwe
2768const PrepopulatedEngine* engines_ZW[] =
2769    { &google, &yahoo, &bing, };
2770
2771
2772// A list of all the engines that we know about.
2773const PrepopulatedEngine* kAllEngines[] =
2774    { &abcsok, &altavista, &altavista_ar, &altavista_se, &aol, &araby, &ask,
2775      &ask_de, &ask_es, &ask_it, &ask_nl, &ask_uk, &atlas_cz, &atlas_sk, &baidu,
2776      &bing, &bing_ar_XA, &bing_bg_BG, &bing_cs_CZ, &bing_da_DK, &bing_de_AT,
2777      &bing_de_CH, &bing_de_DE, &bing_el_GR, &bing_en_AU, &bing_en_CA,
2778      &bing_en_GB, &bing_en_ID, &bing_en_IE, &bing_en_IN, &bing_en_MY,
2779      &bing_en_NZ, &bing_en_PH, &bing_en_SG, &bing_en_US, &bing_en_XA,
2780      &bing_en_ZA, &bing_es_AR, &bing_es_CL, &bing_es_ES, &bing_es_MX,
2781      &bing_es_XL, &bing_et_EE, &bing_fi_FI, &bing_fr_BE, &bing_fr_CA,
2782      &bing_fr_CH, &bing_fr_FR, &bing_he_IL, &bing_hr_HR, &bing_hu_HU,
2783      &bing_it_IT, &bing_ja_JP, &bing_ko_KR, &bing_lt_LT, &bing_lv_LV,
2784      &bing_nb_NO, &bing_nl_BE, &bing_nl_NL, &bing_pl_PL, &bing_pt_BR,
2785      &bing_pt_PT, &bing_ro_RO, &bing_ru_RU, &bing_sl_SI, &bing_sk_SK,
2786      &bing_sv_SE, &bing_th_TH, &bing_tr_TR, &bing_uk_UA, &bing_zh_CN,
2787      &bing_zh_HK, &bing_zh_TW, &centrum_cz, &centrum_sk, &daum, &delfi_lt,
2788      &delfi_lv, &diri, &eniro_fi, &eniro_se, &fonecta_02_fi, &go, &goo,
2789      &google, &guruji, &hispavista, &in, &jabse, &jubii, &kvasir, &latne,
2790      &leit, &libero, &mail_ru, &maktoob, &masrawy, &mynet, &najdi, &nate,
2791      &naver, &neti, &netsprint, &nur_kz, &ok, &onet, &pogodak_ba, &pogodak_hr,
2792      &pogodak_rs, &pogodok, &rambler, &rediff, &rednano, &sanook, &sapo,
2793      &search_de_CH, &search_fr_CH, &seznam, &spray, &terra_ar, &terra_es, &tut,
2794      &uol, &virgilio, &walla, &wp, &yahoo, &yahoo_ar, &yahoo_at, &yahoo_au,
2795      &yahoo_br, &yahoo_ca, &yahoo_ch, &yahoo_cl, &yahoo_cn, &yahoo_co,
2796      &yahoo_de, &yahoo_dk, &yahoo_es, &yahoo_fi, &yahoo_fr, &yahoo_hk,
2797      &yahoo_id, &yahoo_in, &yahoo_it, &yahoo_jp, &yahoo_kr, &yahoo_malaysia,
2798      &yahoo_mx, &yahoo_nl, &yahoo_no, &yahoo_nz, &yahoo_pe, &yahoo_ph,
2799      &yahoo_qc, &yahoo_ru, &yahoo_se, &yahoo_sg, &yahoo_th, &yahoo_tw,
2800      &yahoo_uk, &yahoo_ve, &yahoo_vn, &yamli, &yandex_ru, &yandex_ua,
2801      &zoznam };
2802
2803
2804// Geographic mappings /////////////////////////////////////////////////////////
2805
2806// Please refer to ISO 3166-1 for information about the two-character country
2807// codes; http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 is useful. In the
2808// following (C++) code, we pack the two letters of the country code into an int
2809// value we call the CountryID.
2810
2811const int kCountryIDUnknown = -1;
2812
2813inline int CountryCharsToCountryID(char c1, char c2) {
2814  return c1 << 8 | c2;
2815}
2816
2817int CountryCharsToCountryIDWithUpdate(char c1, char c2) {
2818  // SPECIAL CASE: In 2003, Yugoslavia renamed itself to Serbia and Montenegro.
2819  // Serbia and Montenegro dissolved their union in June 2006. Yugoslavia was
2820  // ISO 'YU' and Serbia and Montenegro were ISO 'CS'. Serbia was subsequently
2821  // issued 'RS' and Montenegro 'ME'. Windows XP and Mac OS X Leopard still use
2822  // the value 'YU'. If we get a value of 'YU' or 'CS' we will map it to 'RS'.
2823  if ((c1 == 'Y' && c2 == 'U') ||
2824      (c1 == 'C' && c2 == 'S')) {
2825    c1 = 'R';
2826    c2 = 'S';
2827  }
2828
2829  // SPECIAL CASE: Timor-Leste changed from 'TP' to 'TL' in 2002. Windows XP
2830  // predates this; we therefore map this value.
2831  if (c1 == 'T' && c2 == 'P')
2832    c2 = 'L';
2833
2834  return CountryCharsToCountryID(c1, c2);
2835}
2836
2837#if defined(OS_WIN)
2838
2839// For reference, a list of GeoIDs can be found at
2840// http://msdn.microsoft.com/en-us/library/dd374073.aspx .
2841int GeoIDToCountryID(GEOID geo_id) {
2842  const int kISOBufferSize = 3;  // Two plus one for the terminator.
2843  wchar_t isobuf[kISOBufferSize] = { 0 };
2844  int retval = GetGeoInfo(geo_id, GEO_ISO2, isobuf, kISOBufferSize, 0);
2845
2846  if (retval == kISOBufferSize &&
2847      !(isobuf[0] == L'X' && isobuf[1] == L'X'))
2848    return CountryCharsToCountryIDWithUpdate(static_cast<char>(isobuf[0]),
2849                                             static_cast<char>(isobuf[1]));
2850
2851  // Various locations have ISO codes that Windows does not return.
2852  switch (geo_id) {
2853    case 0x144:   // Guernsey
2854      return CountryCharsToCountryID('G', 'G');
2855    case 0x148:   // Jersey
2856      return CountryCharsToCountryID('J', 'E');
2857    case 0x3B16:  // Isle of Man
2858      return CountryCharsToCountryID('I', 'M');
2859
2860    // 'UM' (U.S. Minor Outlying Islands)
2861    case 0x7F:    // Johnston Atoll
2862    case 0x102:   // Wake Island
2863    case 0x131:   // Baker Island
2864    case 0x146:   // Howland Island
2865    case 0x147:   // Jarvis Island
2866    case 0x149:   // Kingman Reef
2867    case 0x152:   // Palmyra Atoll
2868    case 0x52FA:  // Midway Islands
2869      return CountryCharsToCountryID('U', 'M');
2870
2871    // 'SH' (Saint Helena)
2872    case 0x12F:  // Ascension Island
2873    case 0x15C:  // Tristan da Cunha
2874      return CountryCharsToCountryID('S', 'H');
2875
2876    // 'IO' (British Indian Ocean Territory)
2877    case 0x13A:  // Diego Garcia
2878      return CountryCharsToCountryID('I', 'O');
2879
2880    // Other cases where there is no ISO country code; we assign countries that
2881    // can serve as reasonable defaults.
2882    case 0x154:  // Rota Island
2883    case 0x155:  // Saipan
2884    case 0x15A:  // Tinian Island
2885      return CountryCharsToCountryID('U', 'S');
2886    case 0x134:  // Channel Islands
2887      return CountryCharsToCountryID('G', 'B');
2888    case 0x143:  // Guantanamo Bay
2889    default:
2890      return kCountryIDUnknown;
2891  }
2892}
2893
2894int GetCurrentCountryID() {
2895  GEOID geo_id = GetUserGeoID(GEOCLASS_NATION);
2896
2897  return GeoIDToCountryID(geo_id);
2898}
2899
2900#elif defined(OS_MACOSX)
2901
2902int GetCurrentCountryID() {
2903  base::mac::ScopedCFTypeRef<CFLocaleRef> locale(CFLocaleCopyCurrent());
2904  CFStringRef country = (CFStringRef)CFLocaleGetValue(locale.get(),
2905                                                      kCFLocaleCountryCode);
2906  if (!country)
2907    return kCountryIDUnknown;
2908
2909  UniChar isobuf[2];
2910  CFRange char_range = CFRangeMake(0, 2);
2911  CFStringGetCharacters(country, char_range, isobuf);
2912
2913  return CountryCharsToCountryIDWithUpdate(static_cast<char>(isobuf[0]),
2914                                           static_cast<char>(isobuf[1]));
2915}
2916
2917#elif defined(OS_POSIX)
2918
2919int GetCurrentCountryID() {
2920  const char* locale = setlocale(LC_MESSAGES, NULL);
2921
2922  if (!locale)
2923    return kCountryIDUnknown;
2924
2925  // The format of a locale name is:
2926  // language[_territory][.codeset][@modifier], where territory is an ISO 3166
2927  // country code, which is what we want.
2928  std::string locale_str(locale);
2929  size_t begin = locale_str.find('_');
2930  if (begin == std::string::npos || locale_str.size() - begin < 3)
2931    return kCountryIDUnknown;
2932
2933  ++begin;
2934  size_t end = locale_str.find_first_of(".@", begin);
2935  if (end == std::string::npos)
2936    end = locale_str.size();
2937
2938  // The territory part must contain exactly two characters.
2939  if (end - begin == 2) {
2940    return CountryCharsToCountryIDWithUpdate(
2941        base::ToUpperASCII(locale_str[begin]),
2942        base::ToUpperASCII(locale_str[begin + 1]));
2943  }
2944
2945  return kCountryIDUnknown;
2946}
2947
2948#endif  // OS_*
2949
2950int GetCountryIDFromPrefs(PrefService* prefs) {
2951  // See if the user overrode the country on the command line.
2952  const std::string country(
2953      CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
2954          switches::kCountry));
2955  if (country.length() == 2)
2956    return CountryCharsToCountryIDWithUpdate(country[0], country[1]);
2957
2958  // Cache first run Country ID value in prefs, and use it afterwards.  This
2959  // ensures that just because the user moves around, we won't automatically
2960  // make major changes to their available search providers, which would feel
2961  // surprising.
2962  if (!prefs)
2963    return GetCurrentCountryID();
2964
2965  int new_country_id = GetCurrentCountryID();
2966#if defined(OS_WIN)
2967  // Migrate the old platform-specific value if it's present.
2968  if (prefs->HasPrefPath(prefs::kGeoIDAtInstall)) {
2969    int geo_id = prefs->GetInteger(prefs::kGeoIDAtInstall);
2970    prefs->ClearPref(prefs::kGeoIDAtInstall);
2971    new_country_id = GeoIDToCountryID(geo_id);
2972  }
2973#endif
2974
2975  if (!prefs->HasPrefPath(prefs::kCountryIDAtInstall))
2976    prefs->SetInteger(prefs::kCountryIDAtInstall, new_country_id);
2977
2978  return prefs->GetInteger(prefs::kCountryIDAtInstall);
2979}
2980
2981void GetPrepopulationSetFromCountryID(PrefService* prefs,
2982                                      const PrepopulatedEngine*** engines,
2983                                      size_t* num_engines) {
2984  // NOTE: This function should ALWAYS set its outparams.
2985
2986  // If you add a new country make sure to update the unit test for coverage.
2987  switch (GetCountryIDFromPrefs(prefs)) {
2988
2989#define CHAR_A 'A'
2990#define CHAR_B 'B'
2991#define CHAR_C 'C'
2992#define CHAR_D 'D'
2993#define CHAR_E 'E'
2994#define CHAR_F 'F'
2995#define CHAR_G 'G'
2996#define CHAR_H 'H'
2997#define CHAR_I 'I'
2998#define CHAR_J 'J'
2999#define CHAR_K 'K'
3000#define CHAR_L 'L'
3001#define CHAR_M 'M'
3002#define CHAR_N 'N'
3003#define CHAR_O 'O'
3004#define CHAR_P 'P'
3005#define CHAR_Q 'Q'
3006#define CHAR_R 'R'
3007#define CHAR_S 'S'
3008#define CHAR_T 'T'
3009#define CHAR_U 'U'
3010#define CHAR_V 'V'
3011#define CHAR_W 'W'
3012#define CHAR_X 'X'
3013#define CHAR_Y 'Y'
3014#define CHAR_Z 'Z'
3015#define CHAR(ch) CHAR_##ch
3016#define CODE_TO_ID(code1, code2)\
3017    (CHAR(code1) << 8 | CHAR(code2))
3018
3019#define UNHANDLED_COUNTRY(code1, code2)\
3020    case CODE_TO_ID(code1, code2):
3021#define END_UNHANDLED_COUNTRIES(code1, code2)\
3022      *engines = engines_##code1##code2;\
3023      *num_engines = arraysize(engines_##code1##code2);\
3024      return;
3025#define DECLARE_COUNTRY(code1, code2)\
3026    UNHANDLED_COUNTRY(code1, code2)\
3027    END_UNHANDLED_COUNTRIES(code1, code2)
3028
3029    // Countries with their own, dedicated engine set.
3030    DECLARE_COUNTRY(A, E)  // United Arab Emirates
3031    DECLARE_COUNTRY(A, L)  // Albania
3032    DECLARE_COUNTRY(A, R)  // Argentina
3033    DECLARE_COUNTRY(A, T)  // Austria
3034    DECLARE_COUNTRY(A, U)  // Australia
3035    DECLARE_COUNTRY(B, A)  // Bosnia and Herzegovina
3036    DECLARE_COUNTRY(B, E)  // Belgium
3037    DECLARE_COUNTRY(B, G)  // Bulgaria
3038    DECLARE_COUNTRY(B, H)  // Bahrain
3039    DECLARE_COUNTRY(B, I)  // Burundi
3040    DECLARE_COUNTRY(B, N)  // Brunei
3041    DECLARE_COUNTRY(B, O)  // Bolivia
3042    DECLARE_COUNTRY(B, R)  // Brazil
3043    DECLARE_COUNTRY(B, Y)  // Belarus
3044    DECLARE_COUNTRY(B, Z)  // Belize
3045    DECLARE_COUNTRY(C, A)  // Canada
3046    DECLARE_COUNTRY(C, H)  // Switzerland
3047    DECLARE_COUNTRY(C, L)  // Chile
3048    DECLARE_COUNTRY(C, N)  // China
3049    DECLARE_COUNTRY(C, O)  // Colombia
3050    DECLARE_COUNTRY(C, R)  // Costa Rica
3051    DECLARE_COUNTRY(C, Z)  // Czech Republic
3052    DECLARE_COUNTRY(D, E)  // Germany
3053    DECLARE_COUNTRY(D, K)  // Denmark
3054    DECLARE_COUNTRY(D, O)  // Dominican Republic
3055    DECLARE_COUNTRY(D, Z)  // Algeria
3056    DECLARE_COUNTRY(E, C)  // Ecuador
3057    DECLARE_COUNTRY(E, E)  // Estonia
3058    DECLARE_COUNTRY(E, G)  // Egypt
3059    DECLARE_COUNTRY(E, S)  // Spain
3060    DECLARE_COUNTRY(F, I)  // Finland
3061    DECLARE_COUNTRY(F, O)  // Faroe Islands
3062    DECLARE_COUNTRY(F, R)  // France
3063    DECLARE_COUNTRY(G, B)  // United Kingdom
3064    DECLARE_COUNTRY(G, R)  // Greece
3065    DECLARE_COUNTRY(G, T)  // Guatemala
3066    DECLARE_COUNTRY(H, K)  // Hong Kong
3067    DECLARE_COUNTRY(H, N)  // Honduras
3068    DECLARE_COUNTRY(H, R)  // Croatia
3069    DECLARE_COUNTRY(H, U)  // Hungary
3070    DECLARE_COUNTRY(I, D)  // Indonesia
3071    DECLARE_COUNTRY(I, E)  // Ireland
3072    DECLARE_COUNTRY(I, L)  // Israel
3073    DECLARE_COUNTRY(I, N)  // India
3074    DECLARE_COUNTRY(I, Q)  // Iraq
3075    DECLARE_COUNTRY(I, R)  // Iran
3076    DECLARE_COUNTRY(I, S)  // Iceland
3077    DECLARE_COUNTRY(I, T)  // Italy
3078    DECLARE_COUNTRY(J, M)  // Jamaica
3079    DECLARE_COUNTRY(J, O)  // Jordan
3080    DECLARE_COUNTRY(J, P)  // Japan
3081    DECLARE_COUNTRY(K, E)  // Kenya
3082    DECLARE_COUNTRY(K, R)  // South Korea
3083    DECLARE_COUNTRY(K, W)  // Kuwait
3084    DECLARE_COUNTRY(K, Z)  // Kazakhstan
3085    DECLARE_COUNTRY(L, B)  // Lebanon
3086    DECLARE_COUNTRY(L, I)  // Liechtenstein
3087    DECLARE_COUNTRY(L, T)  // Lithuania
3088    DECLARE_COUNTRY(L, U)  // Luxembourg
3089    DECLARE_COUNTRY(L, V)  // Latvia
3090    DECLARE_COUNTRY(L, Y)  // Libya
3091    DECLARE_COUNTRY(M, A)  // Morocco
3092    DECLARE_COUNTRY(M, C)  // Monaco
3093    DECLARE_COUNTRY(M, D)  // Moldova
3094    DECLARE_COUNTRY(M, E)  // Montenegro
3095    DECLARE_COUNTRY(M, K)  // Macedonia
3096    DECLARE_COUNTRY(M, X)  // Mexico
3097    DECLARE_COUNTRY(M, Y)  // Malaysia
3098    DECLARE_COUNTRY(N, I)  // Nicaragua
3099    DECLARE_COUNTRY(N, L)  // Netherlands
3100    DECLARE_COUNTRY(N, O)  // Norway
3101    DECLARE_COUNTRY(N, Z)  // New Zealand
3102    DECLARE_COUNTRY(O, M)  // Oman
3103    DECLARE_COUNTRY(P, A)  // Panama
3104    DECLARE_COUNTRY(P, E)  // Peru
3105    DECLARE_COUNTRY(P, H)  // Philippines
3106    DECLARE_COUNTRY(P, K)  // Pakistan
3107    DECLARE_COUNTRY(P, L)  // Poland
3108    DECLARE_COUNTRY(P, R)  // Puerto Rico
3109    DECLARE_COUNTRY(P, T)  // Portugal
3110    DECLARE_COUNTRY(P, Y)  // Paraguay
3111    DECLARE_COUNTRY(Q, A)  // Qatar
3112    DECLARE_COUNTRY(R, O)  // Romania
3113    DECLARE_COUNTRY(R, S)  // Serbia
3114    DECLARE_COUNTRY(R, U)  // Russia
3115    DECLARE_COUNTRY(R, W)  // Rwanda
3116    DECLARE_COUNTRY(S, A)  // Saudi Arabia
3117    DECLARE_COUNTRY(S, E)  // Sweden
3118    DECLARE_COUNTRY(S, G)  // Singapore
3119    DECLARE_COUNTRY(S, I)  // Slovenia
3120    DECLARE_COUNTRY(S, K)  // Slovakia
3121    DECLARE_COUNTRY(S, V)  // El Salvador
3122    DECLARE_COUNTRY(S, Y)  // Syria
3123    DECLARE_COUNTRY(T, H)  // Thailand
3124    DECLARE_COUNTRY(T, N)  // Tunisia
3125    DECLARE_COUNTRY(T, R)  // Turkey
3126    DECLARE_COUNTRY(T, T)  // Trinidad and Tobago
3127    DECLARE_COUNTRY(T, W)  // Taiwan
3128    DECLARE_COUNTRY(T, Z)  // Tanzania
3129    DECLARE_COUNTRY(U, A)  // Ukraine
3130    DECLARE_COUNTRY(U, S)  // United States
3131    DECLARE_COUNTRY(U, Y)  // Uruguay
3132    DECLARE_COUNTRY(V, E)  // Venezuela
3133    DECLARE_COUNTRY(V, N)  // Vietnam
3134    DECLARE_COUNTRY(Y, E)  // Yemen
3135    DECLARE_COUNTRY(Z, A)  // South Africa
3136    DECLARE_COUNTRY(Z, W)  // Zimbabwe
3137
3138    // Countries using the "Australia" engine set.
3139    UNHANDLED_COUNTRY(C, C)  // Cocos Islands
3140    UNHANDLED_COUNTRY(C, X)  // Christmas Island
3141    UNHANDLED_COUNTRY(H, M)  // Heard Island and McDonald Islands
3142    UNHANDLED_COUNTRY(N, F)  // Norfolk Island
3143    END_UNHANDLED_COUNTRIES(A, U)
3144
3145    // Countries using the "China" engine set.
3146    UNHANDLED_COUNTRY(M, O)  // Macao
3147    END_UNHANDLED_COUNTRIES(C, N)
3148
3149    // Countries using the "Denmark" engine set.
3150    UNHANDLED_COUNTRY(G, L)  // Greenland
3151    END_UNHANDLED_COUNTRIES(D, K)
3152
3153    // Countries using the "Spain" engine set.
3154    UNHANDLED_COUNTRY(A, D)  // Andorra
3155    END_UNHANDLED_COUNTRIES(E, S)
3156
3157    // Countries using the "Finland" engine set.
3158    UNHANDLED_COUNTRY(A, X)  // Aland Islands
3159    END_UNHANDLED_COUNTRIES(F, I)
3160
3161    // Countries using the "France" engine set.
3162    UNHANDLED_COUNTRY(B, F)  // Burkina Faso
3163    UNHANDLED_COUNTRY(B, J)  // Benin
3164    UNHANDLED_COUNTRY(C, D)  // Congo - Kinshasa
3165    UNHANDLED_COUNTRY(C, F)  // Central African Republic
3166    UNHANDLED_COUNTRY(C, G)  // Congo - Brazzaville
3167    UNHANDLED_COUNTRY(C, I)  // Ivory Coast
3168    UNHANDLED_COUNTRY(C, M)  // Cameroon
3169    UNHANDLED_COUNTRY(D, J)  // Djibouti
3170    UNHANDLED_COUNTRY(G, A)  // Gabon
3171    UNHANDLED_COUNTRY(G, F)  // French Guiana
3172    UNHANDLED_COUNTRY(G, N)  // Guinea
3173    UNHANDLED_COUNTRY(G, P)  // Guadeloupe
3174    UNHANDLED_COUNTRY(H, T)  // Haiti
3175#if defined(OS_WIN)
3176    UNHANDLED_COUNTRY(I, P)  // Clipperton Island ('IP' is an WinXP-ism; ISO
3177                             //                    includes it with France)
3178#endif
3179    UNHANDLED_COUNTRY(M, L)  // Mali
3180    UNHANDLED_COUNTRY(M, Q)  // Martinique
3181    UNHANDLED_COUNTRY(N, C)  // New Caledonia
3182    UNHANDLED_COUNTRY(N, E)  // Niger
3183    UNHANDLED_COUNTRY(P, F)  // French Polynesia
3184    UNHANDLED_COUNTRY(P, M)  // Saint Pierre and Miquelon
3185    UNHANDLED_COUNTRY(R, E)  // Reunion
3186    UNHANDLED_COUNTRY(S, N)  // Senegal
3187    UNHANDLED_COUNTRY(T, D)  // Chad
3188    UNHANDLED_COUNTRY(T, F)  // French Southern Territories
3189    UNHANDLED_COUNTRY(T, G)  // Togo
3190    UNHANDLED_COUNTRY(W, F)  // Wallis and Futuna
3191    UNHANDLED_COUNTRY(Y, T)  // Mayotte
3192    END_UNHANDLED_COUNTRIES(F, R)
3193
3194    // Countries using the "Greece" engine set.
3195    UNHANDLED_COUNTRY(C, Y)  // Cyprus
3196    END_UNHANDLED_COUNTRIES(G, R)
3197
3198    // Countries using the "Italy" engine set.
3199    UNHANDLED_COUNTRY(S, M)  // San Marino
3200    UNHANDLED_COUNTRY(V, A)  // Vatican
3201    END_UNHANDLED_COUNTRIES(I, T)
3202
3203    // Countries using the "Morocco" engine set.
3204    UNHANDLED_COUNTRY(E, H)  // Western Sahara
3205    END_UNHANDLED_COUNTRIES(M, A)
3206
3207    // Countries using the "Netherlands" engine set.
3208    UNHANDLED_COUNTRY(A, N)  // Netherlands Antilles
3209    UNHANDLED_COUNTRY(A, W)  // Aruba
3210    END_UNHANDLED_COUNTRIES(N, L)
3211
3212    // Countries using the "Norway" engine set.
3213    UNHANDLED_COUNTRY(B, V)  // Bouvet Island
3214    UNHANDLED_COUNTRY(S, J)  // Svalbard and Jan Mayen
3215    END_UNHANDLED_COUNTRIES(N, O)
3216
3217    // Countries using the "New Zealand" engine set.
3218    UNHANDLED_COUNTRY(C, K)  // Cook Islands
3219    UNHANDLED_COUNTRY(N, U)  // Niue
3220    UNHANDLED_COUNTRY(T, K)  // Tokelau
3221    END_UNHANDLED_COUNTRIES(N, Z)
3222
3223    // Countries using the "Portugal" engine set.
3224    UNHANDLED_COUNTRY(C, V)  // Cape Verde
3225    UNHANDLED_COUNTRY(G, W)  // Guinea-Bissau
3226    UNHANDLED_COUNTRY(M, Z)  // Mozambique
3227    UNHANDLED_COUNTRY(S, T)  // Sao Tome and Principe
3228    UNHANDLED_COUNTRY(T, L)  // Timor-Leste
3229    END_UNHANDLED_COUNTRIES(P, T)
3230
3231    // Countries using the "Russia" engine set.
3232    UNHANDLED_COUNTRY(A, M)  // Armenia
3233    UNHANDLED_COUNTRY(A, Z)  // Azerbaijan
3234    UNHANDLED_COUNTRY(K, G)  // Kyrgyzstan
3235    UNHANDLED_COUNTRY(T, J)  // Tajikistan
3236    UNHANDLED_COUNTRY(T, M)  // Turkmenistan
3237    UNHANDLED_COUNTRY(U, Z)  // Uzbekistan
3238    END_UNHANDLED_COUNTRIES(R, U)
3239
3240    // Countries using the "Saudi Arabia" engine set.
3241    UNHANDLED_COUNTRY(M, R)  // Mauritania
3242    UNHANDLED_COUNTRY(P, S)  // Palestinian Territory
3243    UNHANDLED_COUNTRY(S, D)  // Sudan
3244    END_UNHANDLED_COUNTRIES(S, A)
3245
3246    // Countries using the "United Kingdom" engine set.
3247    UNHANDLED_COUNTRY(B, M)  // Bermuda
3248    UNHANDLED_COUNTRY(F, K)  // Falkland Islands
3249    UNHANDLED_COUNTRY(G, G)  // Guernsey
3250    UNHANDLED_COUNTRY(G, I)  // Gibraltar
3251    UNHANDLED_COUNTRY(G, S)  // South Georgia and the South Sandwich
3252                             //   Islands
3253    UNHANDLED_COUNTRY(I, M)  // Isle of Man
3254    UNHANDLED_COUNTRY(I, O)  // British Indian Ocean Territory
3255    UNHANDLED_COUNTRY(J, E)  // Jersey
3256    UNHANDLED_COUNTRY(K, Y)  // Cayman Islands
3257    UNHANDLED_COUNTRY(M, S)  // Montserrat
3258    UNHANDLED_COUNTRY(M, T)  // Malta
3259    UNHANDLED_COUNTRY(P, N)  // Pitcairn Islands
3260    UNHANDLED_COUNTRY(S, H)  // Saint Helena, Ascension Island, and Tristan da
3261                             //   Cunha
3262    UNHANDLED_COUNTRY(T, C)  // Turks and Caicos Islands
3263    UNHANDLED_COUNTRY(V, G)  // British Virgin Islands
3264    END_UNHANDLED_COUNTRIES(G, B)
3265
3266    // Countries using the "United States" engine set.
3267    UNHANDLED_COUNTRY(A, S)  // American Samoa
3268    UNHANDLED_COUNTRY(G, U)  // Guam
3269    UNHANDLED_COUNTRY(M, P)  // Northern Mariana Islands
3270    UNHANDLED_COUNTRY(U, M)  // U.S. Minor Outlying Islands
3271    UNHANDLED_COUNTRY(V, I)  // U.S. Virgin Islands
3272    END_UNHANDLED_COUNTRIES(U, S)
3273
3274    // Countries using the "default" engine set.
3275    UNHANDLED_COUNTRY(A, F)  // Afghanistan
3276    UNHANDLED_COUNTRY(A, G)  // Antigua and Barbuda
3277    UNHANDLED_COUNTRY(A, I)  // Anguilla
3278    UNHANDLED_COUNTRY(A, O)  // Angola
3279    UNHANDLED_COUNTRY(A, Q)  // Antarctica
3280    UNHANDLED_COUNTRY(B, B)  // Barbados
3281    UNHANDLED_COUNTRY(B, D)  // Bangladesh
3282    UNHANDLED_COUNTRY(B, S)  // Bahamas
3283    UNHANDLED_COUNTRY(B, T)  // Bhutan
3284    UNHANDLED_COUNTRY(B, W)  // Botswana
3285    UNHANDLED_COUNTRY(C, U)  // Cuba
3286    UNHANDLED_COUNTRY(D, M)  // Dominica
3287    UNHANDLED_COUNTRY(E, R)  // Eritrea
3288    UNHANDLED_COUNTRY(E, T)  // Ethiopia
3289    UNHANDLED_COUNTRY(F, J)  // Fiji
3290    UNHANDLED_COUNTRY(F, M)  // Micronesia
3291    UNHANDLED_COUNTRY(G, D)  // Grenada
3292    UNHANDLED_COUNTRY(G, E)  // Georgia
3293    UNHANDLED_COUNTRY(G, H)  // Ghana
3294    UNHANDLED_COUNTRY(G, M)  // Gambia
3295    UNHANDLED_COUNTRY(G, Q)  // Equatorial Guinea
3296    UNHANDLED_COUNTRY(G, Y)  // Guyana
3297    UNHANDLED_COUNTRY(K, H)  // Cambodia
3298    UNHANDLED_COUNTRY(K, I)  // Kiribati
3299    UNHANDLED_COUNTRY(K, M)  // Comoros
3300    UNHANDLED_COUNTRY(K, N)  // Saint Kitts and Nevis
3301    UNHANDLED_COUNTRY(K, P)  // North Korea
3302    UNHANDLED_COUNTRY(L, A)  // Laos
3303    UNHANDLED_COUNTRY(L, C)  // Saint Lucia
3304    UNHANDLED_COUNTRY(L, K)  // Sri Lanka
3305    UNHANDLED_COUNTRY(L, R)  // Liberia
3306    UNHANDLED_COUNTRY(L, S)  // Lesotho
3307    UNHANDLED_COUNTRY(M, G)  // Madagascar
3308    UNHANDLED_COUNTRY(M, H)  // Marshall Islands
3309    UNHANDLED_COUNTRY(M, M)  // Myanmar
3310    UNHANDLED_COUNTRY(M, N)  // Mongolia
3311    UNHANDLED_COUNTRY(M, U)  // Mauritius
3312    UNHANDLED_COUNTRY(M, V)  // Maldives
3313    UNHANDLED_COUNTRY(M, W)  // Malawi
3314    UNHANDLED_COUNTRY(N, A)  // Namibia
3315    UNHANDLED_COUNTRY(N, G)  // Nigeria
3316    UNHANDLED_COUNTRY(N, P)  // Nepal
3317    UNHANDLED_COUNTRY(N, R)  // Nauru
3318    UNHANDLED_COUNTRY(P, G)  // Papua New Guinea
3319    UNHANDLED_COUNTRY(P, W)  // Palau
3320    UNHANDLED_COUNTRY(S, B)  // Solomon Islands
3321    UNHANDLED_COUNTRY(S, C)  // Seychelles
3322    UNHANDLED_COUNTRY(S, L)  // Sierra Leone
3323    UNHANDLED_COUNTRY(S, O)  // Somalia
3324    UNHANDLED_COUNTRY(S, R)  // Suriname
3325    UNHANDLED_COUNTRY(S, Z)  // Swaziland
3326    UNHANDLED_COUNTRY(T, O)  // Tonga
3327    UNHANDLED_COUNTRY(T, V)  // Tuvalu
3328    UNHANDLED_COUNTRY(U, G)  // Uganda
3329    UNHANDLED_COUNTRY(V, C)  // Saint Vincent and the Grenadines
3330    UNHANDLED_COUNTRY(V, U)  // Vanuatu
3331    UNHANDLED_COUNTRY(W, S)  // Samoa
3332    UNHANDLED_COUNTRY(Z, M)  // Zambia
3333    case kCountryIDUnknown:
3334    default:                // Unhandled location
3335    END_UNHANDLED_COUNTRIES(def, ault)
3336  }
3337}
3338
3339}  // namespace
3340
3341namespace TemplateURLPrepopulateData {
3342
3343void RegisterUserPrefs(PrefService* prefs) {
3344  prefs->RegisterIntegerPref(prefs::kCountryIDAtInstall, kCountryIDUnknown);
3345  prefs->RegisterListPref(prefs::kSearchProviderOverrides);
3346  prefs->RegisterIntegerPref(prefs::kSearchProviderOverridesVersion, -1);
3347  // Obsolete pref, for migration.
3348  prefs->RegisterIntegerPref(prefs::kGeoIDAtInstall, -1);
3349}
3350
3351int GetDataVersion(PrefService* prefs) {
3352  // Increment this if you change the above data in ways that mean users with
3353  // existing data should get a new version.
3354  const int kCurrentDataVersion = 33;
3355  if (!prefs)
3356    return kCurrentDataVersion;
3357  // If a version number exist in the preferences file, it overrides the
3358  // version of the built-in data.
3359  int version =
3360    prefs->GetInteger(prefs::kSearchProviderOverridesVersion);
3361  return (version >= 0) ? version : kCurrentDataVersion;
3362}
3363
3364TemplateURL* MakePrepopulatedTemplateURL(const wchar_t* name,
3365                                         const wchar_t* keyword,
3366                                         const wchar_t* search_url,
3367                                         const char* favicon_url,
3368                                         const wchar_t* suggest_url,
3369                                         const wchar_t* instant_url,
3370                                         const char* encoding,
3371                                         SearchEngineType search_engine_type,
3372                                         int logo_id,
3373                                         int id) {
3374  TemplateURL* new_turl = new TemplateURL();
3375  new_turl->SetURL(WideToUTF8(search_url), 0, 0);
3376  if (favicon_url)
3377    new_turl->SetFaviconURL(GURL(favicon_url));
3378  if (suggest_url)
3379    new_turl->SetSuggestionsURL(WideToUTF8(suggest_url), 0, 0);
3380  if (instant_url)
3381    new_turl->SetInstantURL(WideToUTF8(instant_url), 0, 0);
3382  new_turl->set_short_name(WideToUTF16Hack(name));
3383  if (keyword == NULL)
3384    new_turl->set_autogenerate_keyword(true);
3385  else
3386    new_turl->set_keyword(WideToUTF16Hack(keyword));
3387  new_turl->set_show_in_default_list(true);
3388  new_turl->set_safe_for_autoreplace(true);
3389  new_turl->set_date_created(Time());
3390  std::vector<std::string> turl_encodings;
3391  turl_encodings.push_back(encoding);
3392  new_turl->set_input_encodings(turl_encodings);
3393  new_turl->set_search_engine_type(search_engine_type);
3394  new_turl->set_logo_id(logo_id);
3395  new_turl->set_prepopulate_id(id);
3396  return new_turl;
3397}
3398
3399void GetPrepopulatedTemplateFromPrefs(PrefService* prefs,
3400                                      std::vector<TemplateURL*>* t_urls) {
3401  if (!prefs)
3402    return;
3403
3404  const ListValue* list =
3405      prefs->GetList(prefs::kSearchProviderOverrides);
3406  if (!list)
3407    return;
3408
3409  string16 name;
3410  string16 keyword;
3411  std::string search_url;
3412  std::string suggest_url;
3413  std::string instant_url;
3414  std::string favicon_url;
3415  std::string encoding;
3416  int search_engine_type;
3417  int logo_id;
3418  int id;
3419
3420  size_t num_engines = list->GetSize();
3421  for (size_t i = 0; i != num_engines; ++i) {
3422    Value* val;
3423    DictionaryValue* engine;
3424    list->GetDictionary(i, &engine);
3425    if (engine->Get("name", &val) && val->GetAsString(&name) &&
3426        engine->Get("keyword", &val) && val->GetAsString(&keyword) &&
3427        engine->Get("search_url", &val) && val->GetAsString(&search_url) &&
3428        engine->Get("suggest_url", &val) && val->GetAsString(&suggest_url) &&
3429        engine->Get("instant_url", &val) && val->GetAsString(&instant_url) &&
3430        engine->Get("favicon_url", &val) && val->GetAsString(&favicon_url) &&
3431        engine->Get("encoding", &val) && val->GetAsString(&encoding) &&
3432        engine->Get("search_engine_type", &val) && val->GetAsInteger(
3433            &search_engine_type) &&
3434        engine->Get("logo_id", &val) && val->GetAsInteger(&logo_id) &&
3435        engine->Get("id", &val) && val->GetAsInteger(&id)) {
3436      // These next fields are not allowed to be empty.
3437      if (search_url.empty() || favicon_url.empty() || encoding.empty())
3438        return;
3439    } else {
3440      // Got a parsing error. No big deal.
3441      continue;
3442    }
3443    // TODO(viettrungluu): convert |MakePrepopulatedTemplateURL()| and get rid
3444    // of conversions.
3445    t_urls->push_back(MakePrepopulatedTemplateURL(
3446        UTF16ToWideHack(name).c_str(),
3447        UTF16ToWideHack(keyword).c_str(),
3448        UTF8ToWide(search_url).c_str(),
3449        favicon_url.c_str(),
3450        UTF8ToWide(suggest_url).c_str(),
3451        UTF8ToWide(instant_url).c_str(),
3452        encoding.c_str(),
3453        static_cast<SearchEngineType>(search_engine_type),
3454        logo_id,
3455        id));
3456  }
3457}
3458
3459// The caller owns the returned TemplateURL.
3460TemplateURL* MakePrepopulateTemplateURLFromPrepopulateEngine(
3461    const PrepopulatedEngine& engine) {
3462  return MakePrepopulatedTemplateURL(engine.name,
3463                                     engine.keyword,
3464                                     engine.search_url,
3465                                     engine.favicon_url,
3466                                     engine.suggest_url,
3467                                     engine.instant_url,
3468                                     engine.encoding,
3469                                     engine.search_engine_type,
3470                                     engine.logo_id,
3471                                     engine.id);
3472}
3473
3474void GetPrepopulatedEngines(PrefService* prefs,
3475                            std::vector<TemplateURL*>* t_urls,
3476                            size_t* default_search_provider_index) {
3477  // If there is a set of search engines in the preferences file, it overrides
3478  // the built-in set.
3479  *default_search_provider_index = 0;
3480  GetPrepopulatedTemplateFromPrefs(prefs, t_urls);
3481  if (!t_urls->empty())
3482    return;
3483
3484  const PrepopulatedEngine** engines;
3485  size_t num_engines;
3486  GetPrepopulationSetFromCountryID(prefs, &engines, &num_engines);
3487  for (size_t i = 0; i != num_engines; ++i) {
3488    t_urls->push_back(
3489        MakePrepopulateTemplateURLFromPrepopulateEngine(*engines[i]));
3490  }
3491}
3492
3493TemplateURL* GetPrepopulatedDefaultSearch(PrefService* prefs) {
3494  TemplateURL* default_search_provider = NULL;
3495  ScopedVector<TemplateURL> loaded_urls;
3496  size_t default_search_index;
3497  // This could be more efficient.  We are loading all the URLs to only keep
3498  // the first one.
3499  GetPrepopulatedEngines(prefs, &loaded_urls.get(), &default_search_index);
3500  if (default_search_index < loaded_urls.size()) {
3501    default_search_provider = loaded_urls[default_search_index];
3502    loaded_urls.weak_erase(loaded_urls.begin() + default_search_index);
3503  }
3504  return default_search_provider;
3505}
3506
3507// Helper function for the templated function GetOriginForSearchURL.
3508static const std::string& ToUTF8(const std::string& str) {
3509  return str;
3510}
3511
3512// Helper function for the templated function GetOriginForSearchURL.
3513static std::string ToUTF8(const wchar_t* str) {
3514  return WideToUTF8(str);
3515}
3516
3517template<typename STR>
3518static GURL GetOriginForSearchURL(const STR& url_string) {
3519  // It is much faster to parse the url without generating the search URL, so
3520  // try that first.  If it fails, fallback to the slow method.
3521  std::string url_utf8_string(ToUTF8(url_string));
3522  GURL url(url_utf8_string);
3523  if (!url.is_valid()) {
3524    TemplateURL turl;
3525    turl.SetURL(url_utf8_string, 0, 0);
3526
3527    UIThreadSearchTermsData search_terms_data;
3528    url = TemplateURLModel::GenerateSearchURLUsingTermsData(
3529        &turl, search_terms_data);
3530  }
3531  return url.GetOrigin();
3532}
3533
3534TemplateURL* GetEngineForOrigin(PrefService* prefs, const GURL& url_to_find) {
3535  GURL origin_to_find = url_to_find.GetOrigin();
3536
3537  // Let's first try to find the url in the defaults. (In case the name
3538  // of logo is different for the current locale versus others.)
3539  ScopedVector<TemplateURL> loaded_urls;
3540  size_t default_search_index;
3541  GetPrepopulatedEngines(prefs, &loaded_urls.get(), &default_search_index);
3542
3543  UIThreadSearchTermsData search_terms_data;
3544  for (std::vector<TemplateURL*>::iterator i = loaded_urls->begin();
3545       i != loaded_urls->end(); ++i) {
3546    TemplateURL* template_url = *i;
3547    GURL engine_origin(GetOriginForSearchURL((*i)->url()->url()));
3548    if (origin_to_find == engine_origin) {
3549      loaded_urls.weak_erase(i);
3550      return template_url;
3551    }
3552  }
3553
3554  // Let's try all of known engines now.
3555  for (size_t i = 0; i < arraysize(kAllEngines); ++i) {
3556    GURL engine_origin(GetOriginForSearchURL(kAllEngines[i]->search_url));
3557    if (origin_to_find == engine_origin)
3558      return MakePrepopulateTemplateURLFromPrepopulateEngine(*kAllEngines[i]);
3559  }
3560  return NULL;
3561}
3562
3563int GetSearchEngineLogo(const GURL& url_to_find) {
3564  GURL origin_to_find = url_to_find.GetOrigin();
3565  for (size_t i = 0; i < arraysize(kAllEngines); ++i) {
3566    std::string url_utf8_string(ToUTF8(kAllEngines[i]->search_url));
3567    GURL url(url_utf8_string);
3568    if (origin_to_find == url.GetOrigin())
3569      return kAllEngines[i]->logo_id;
3570  }
3571  return kNoSearchEngineLogo;
3572}
3573
3574}  // namespace TemplateURLPrepopulateData
3575