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