OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/util.h" | 5 #include "chrome/browser/search_engines/util.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/utf_string_conversions.h" |
11 #include "chrome/browser/browser_thread.h" | 12 #include "chrome/browser/browser_thread.h" |
12 #include "chrome/browser/search_engines/template_url.h" | 13 #include "chrome/browser/search_engines/template_url.h" |
13 #include "chrome/browser/search_engines/template_url_model.h" | 14 #include "chrome/browser/search_engines/template_url_model.h" |
14 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 15 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
15 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
17 | 18 |
18 string16 GetDefaultSearchEngineName(Profile* profile) { | 19 string16 GetDefaultSearchEngineName(Profile* profile) { |
19 if (!profile) { | 20 if (!profile) { |
20 NOTREACHED(); | 21 NOTREACHED(); |
21 return string16(); | 22 return string16(); |
22 } | 23 } |
23 const TemplateURL* const default_provider = | 24 const TemplateURL* const default_provider = |
24 profile->GetTemplateURLModel()->GetDefaultSearchProvider(); | 25 profile->GetTemplateURLModel()->GetDefaultSearchProvider(); |
25 if (!default_provider) { | 26 if (!default_provider) { |
26 // TODO(cpu): bug 1187517. It is possible to have no default provider. | 27 // TODO(cpu): bug 1187517. It is possible to have no default provider. |
27 // returning an empty string is a stopgap measure for the crash | 28 // returning an empty string is a stopgap measure for the crash |
28 // http://code.google.com/p/chromium/issues/detail?id=2573 | 29 // http://code.google.com/p/chromium/issues/detail?id=2573 |
29 return string16(); | 30 return string16(); |
30 } | 31 } |
31 return default_provider->short_name(); | 32 return WideToUTF16(default_provider->short_name()); |
32 } | 33 } |
33 | 34 |
34 // Removes (and deletes) TemplateURLs from |urls| that have duplicate | 35 // Removes (and deletes) TemplateURLs from |urls| that have duplicate |
35 // prepopulate ids. Duplicate prepopulate ids are not allowed, but due to a | 36 // prepopulate ids. Duplicate prepopulate ids are not allowed, but due to a |
36 // bug it was possible get dups. This step is only called when the version | 37 // bug it was possible get dups. This step is only called when the version |
37 // number changes. Only pass in a non-NULL value for |service| if the removed | 38 // number changes. Only pass in a non-NULL value for |service| if the removed |
38 // items should be removed from the DB. | 39 // items should be removed from the DB. |
39 static void RemoveDuplicatePrepopulateIDs( | 40 static void RemoveDuplicatePrepopulateIDs( |
40 std::vector<TemplateURL*>* template_urls, | 41 std::vector<TemplateURL*>* template_urls, |
41 WebDataService* service) { | 42 WebDataService* service) { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 } | 190 } |
190 } | 191 } |
191 | 192 |
192 if (keyword_result.builtin_keyword_version != resource_keyword_version) { | 193 if (keyword_result.builtin_keyword_version != resource_keyword_version) { |
193 MergeEnginesFromPrepopulateData(prefs, service, template_urls, | 194 MergeEnginesFromPrepopulateData(prefs, service, template_urls, |
194 default_search_provider); | 195 default_search_provider); |
195 *new_resource_keyword_version = resource_keyword_version; | 196 *new_resource_keyword_version = resource_keyword_version; |
196 } | 197 } |
197 } | 198 } |
198 | 199 |
OLD | NEW |