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

Side by Side Diff: chrome/browser/search_engines/template_url_prepopulate_data.cc

Issue 11377049: Moving prepopulated search engines to a JSON file. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" 5 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
6 6
7 #if defined(OS_POSIX) && !defined(OS_MACOSX) 7 #if defined(OS_POSIX) && !defined(OS_MACOSX)
8 #include <locale.h> 8 #include <locale.h>
9 #endif 9 #endif
10 10
(...skipping 14 matching lines...) Expand all
25 #include "chrome/browser/search_engines/template_url.h" 25 #include "chrome/browser/search_engines/template_url.h"
26 #include "chrome/browser/search_engines/template_url_service.h" 26 #include "chrome/browser/search_engines/template_url_service.h"
27 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
28 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
29 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
30 #include "googleurl/src/gurl.h" 30 #include "googleurl/src/gurl.h"
31 #include "grit/generated_resources.h" 31 #include "grit/generated_resources.h"
32 #include "grit/theme_resources.h" 32 #include "grit/theme_resources.h"
33 #include "ui/base/l10n/l10n_util.h" 33 #include "ui/base/l10n/l10n_util.h"
34 34
35 #include "prepopulated_engines.h"
36
37 using namespace search_engines;
Peter Kasting 2012/11/08 19:02:25 This is banned by the style guide
beaudoin 2012/11/08 19:39:01 I didn't like it either. Other options I can think
beaudoin 2012/11/09 04:16:53 Found an elegant fix by using the same namespace f
38
35 #if defined(OS_WIN) 39 #if defined(OS_WIN)
36 #undef IN // On Windows, windef.h defines this, which screws up "India" cases. 40 #undef IN // On Windows, windef.h defines this, which screws up "India" cases.
37 #elif defined(OS_MACOSX) 41 #elif defined(OS_MACOSX)
38 #include "base/mac/scoped_cftyperef.h" 42 #include "base/mac/scoped_cftyperef.h"
39 #endif 43 #endif
40 44
41 namespace { 45 namespace {
42 46
43 // NOTE: See comments in GetDataVersion() below! You should probably not change 47 // NOTE: See comments in GetDataVersion() below! You should probably not change
44 // the data in this file without changing the result of that function! 48 // the data in this file without changing the result of that function!
45 49
46 // Engine definitions //////////////////////////////////////////////////////////
47
48 struct PrepopulatedEngine {
49 const wchar_t* const name;
50 const wchar_t* const keyword;
51 const char* const favicon_url; // If NULL, there is no favicon.
52 const char* const search_url;
53 const char* const encoding;
54 const char* const suggest_url; // If NULL, this engine does not support
55 // suggestions.
56 const char* const instant_url; // If NULL, this engine does not support
57 // instant.
58 // A JSON array containing a list of URL patterns that can be used, in
59 // addition to |search_url|, to extract search terms from a URL. Can be NULL.
60 const char* const alternate_urls;
61 // SEARCH_ENGINE_OTHER if there is no matching type.
62 const SearchEngineType type;
63 // Unique id for this prepopulate engine (corresponds to
64 // TemplateURL::prepopulate_id). This ID must be greater than zero and must
65 // remain the same for a particular site regardless of how the url changes;
66 // the ID is used when modifying engine data in subsequent versions, so that
67 // we can find the "old" entry to update even when the name or URL changes.
68 //
69 // This ID must be "unique" within one country's prepopulated data, but two
70 // entries can share an ID if they represent the "same" engine (e.g. Yahoo! US
71 // vs. Yahoo! UK) and will not appear in the same user-visible data set. This
72 // facilitates changes like adding more specific per-country data in the
73 // future; in such a case the localized engines will transparently replace the
74 // previous, non-localized versions. For engines where we need two instances
75 // to appear for one country (e.g. Bing Search U.S. English and Spanish), we
76 // must use two different unique IDs (and different keywords).
77 //
78 // The following unique IDs are available:
79 // 53, 56, 58, 60, 61, 64, 65, 66, 70, 74, 78, 79, 80, 81, 84, 86, 88, 91,
80 // 92, 93, 94, 95, 96, 97, 98, 99, 102+
81 //
82 // IDs > 1000 are reserved for distribution custom engines.
83 //
84 // NOTES:
85 // CHANGE THE ABOVE NUMBERS IF YOU ADD A NEW ENGINE; ID conflicts = bad!
86 // CHANGE kMaxPrepopulatedEngineID below if you add new engine outside
87 // of the current range or it will not be counted in stats.
88 const int id;
89 };
90
91 // Prepopulated engines //////////////////////////////////////////////////////// 50 // Prepopulated engines ////////////////////////////////////////////////////////
92 51
93 // The following engines are included in country lists and are added to the list 52 // The following engines are included in country lists and are added to the list
94 // of search engines on the first run depending on user's country. 53 // of search engines on the first run depending on user's country.
95 54
96 const PrepopulatedEngine abcsok = {
97 L"ABC S\x00f8k",
98 L"abcsok.no",
99 "http://abcsok.no/favicon.ico",
100 "http://abcsok.no/index.html?q={searchTerms}",
101 "UTF-8",
102 NULL,
103 NULL,
104 NULL,
105 SEARCH_ENGINE_ABCSOK,
106 72,
107 };
108
109 const PrepopulatedEngine altavista = {
110 L"AltaVista",
111 L"altavista.com",
112 "http://www.altavista.com/favicon.ico",
113 "http://www.altavista.com/web/results?q={searchTerms}",
114 "UTF-8",
115 NULL,
116 NULL,
117 NULL,
118 SEARCH_ENGINE_ALTAVISTA,
119 89,
120 };
121
122 const PrepopulatedEngine altavista_ar = { 55 const PrepopulatedEngine altavista_ar = {
123 L"AltaVista", 56 L"AltaVista",
124 L"ar.altavista.com", 57 L"ar.altavista.com",
125 "http://ar.altavista.com/favicon.ico", 58 "http://ar.altavista.com/favicon.ico",
126 "http://ar.altavista.com/web/results?q={searchTerms}", 59 "http://ar.altavista.com/web/results?q={searchTerms}",
127 "UTF-8", 60 "UTF-8",
128 NULL, 61 NULL,
129 NULL, 62 NULL,
130 NULL, 63 NULL,
131 SEARCH_ENGINE_ALTAVISTA, 64 SEARCH_ENGINE_ALTAVISTA,
(...skipping 3576 matching lines...) Expand 10 before | Expand all | Expand 10 after
3708 g_country_code_at_install = kCountryIDUnknown; 3641 g_country_code_at_install = kCountryIDUnknown;
3709 } else { 3642 } else {
3710 g_country_code_at_install = 3643 g_country_code_at_install =
3711 CountryCharsToCountryIDWithUpdate(country_code[0], country_code[1]); 3644 CountryCharsToCountryIDWithUpdate(country_code[0], country_code[1]);
3712 } 3645 }
3713 } 3646 }
3714 3647
3715 #endif 3648 #endif
3716 3649
3717 } // namespace TemplateURLPrepopulateData 3650 } // namespace TemplateURLPrepopulateData
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698