OLD | NEW |
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_service.h" | 5 #include "chrome/browser/search_engines/template_url_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 int num_dupes = 0; | 225 int num_dupes = 0; |
226 for (std::map<std::string, int>::const_iterator it = duplicates.begin(); | 226 for (std::map<std::string, int>::const_iterator it = duplicates.begin(); |
227 it != duplicates.end(); ++it) { | 227 it != duplicates.end(); ++it) { |
228 if (it->second > 1) | 228 if (it->second > 1) |
229 num_dupes++; | 229 num_dupes++; |
230 } | 230 } |
231 | 231 |
232 UMA_HISTOGRAM_COUNTS_100("Search.SearchEngineDuplicateCounts", num_dupes); | 232 UMA_HISTOGRAM_COUNTS_100("Search.SearchEngineDuplicateCounts", num_dupes); |
233 } | 233 } |
234 | 234 |
235 typedef std::vector<TemplateURLService::ExtensionKeyword> ExtensionKeywords; | |
236 | |
237 #if !defined(OS_ANDROID) | |
238 // Extract all installed Omnibox Extensions. | |
239 ExtensionKeywords GetExtensionKeywords(Profile* profile) { | |
240 DCHECK(profile); | |
241 ExtensionService* extension_service = profile->GetExtensionService(); | |
242 DCHECK(extension_service); | |
243 const ExtensionSet* extensions = extension_service->extensions(); | |
244 ExtensionKeywords extension_keywords; | |
245 for (ExtensionSet::const_iterator it = extensions->begin(); | |
246 it != extensions->end(); ++it) { | |
247 const std::string& keyword = extensions::OmniboxInfo::GetKeyword(*it); | |
248 if (!keyword.empty()) { | |
249 extension_keywords.push_back(TemplateURLService::ExtensionKeyword( | |
250 (*it)->id(), (*it)->name(), keyword)); | |
251 } | |
252 } | |
253 return extension_keywords; | |
254 } | |
255 #else | |
256 // Extensions are not supported. | |
257 ExtensionKeywords GetExtensionKeywords(Profile* profile) { | |
258 return ExtensionKeywords(); | |
259 } | |
260 #endif | |
261 | |
262 } // namespace | 235 } // namespace |
263 | 236 |
264 | 237 |
265 // TemplateURLService::ExtensionKeyword --------------------------------------- | 238 // TemplateURLService::ExtensionKeyword --------------------------------------- |
266 | 239 |
267 TemplateURLService::ExtensionKeyword::ExtensionKeyword( | 240 TemplateURLService::ExtensionKeyword::ExtensionKeyword( |
268 const std::string& id, | 241 const std::string& id, |
269 const std::string& name, | 242 const std::string& name, |
270 const std::string& keyword) | 243 const std::string& keyword) |
271 : extension_id(id), | 244 : extension_id(id), |
(...skipping 2479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2751 new_dse = *i; | 2724 new_dse = *i; |
2752 break; | 2725 break; |
2753 } | 2726 } |
2754 } | 2727 } |
2755 } | 2728 } |
2756 } | 2729 } |
2757 if (!new_dse) | 2730 if (!new_dse) |
2758 new_dse = FindNewDefaultSearchProvider(); | 2731 new_dse = FindNewDefaultSearchProvider(); |
2759 SetDefaultSearchProviderNoNotify(new_dse); | 2732 SetDefaultSearchProviderNoNotify(new_dse); |
2760 } | 2733 } |
OLD | NEW |