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

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

Issue 18119005: Misc. cleanup: (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 5 months 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/search_engines/util.h ('k') | chrome/browser/ui/omnibox/omnibox_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/util.h" 5 #include "chrome/browser/search_engines/util.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 21 matching lines...) Expand all
32 GetDefaultSearchProvider(); 32 GetDefaultSearchProvider();
33 if (!default_provider) { 33 if (!default_provider) {
34 // TODO(cpu): bug 1187517. It is possible to have no default provider. 34 // TODO(cpu): bug 1187517. It is possible to have no default provider.
35 // returning an empty string is a stopgap measure for the crash 35 // returning an empty string is a stopgap measure for the crash
36 // http://code.google.com/p/chromium/issues/detail?id=2573 36 // http://code.google.com/p/chromium/issues/detail?id=2573
37 return string16(); 37 return string16();
38 } 38 }
39 return default_provider->short_name(); 39 return default_provider->short_name();
40 } 40 }
41 41
42 GURL GetDefaultSearchURLForSearchTerms(Profile* profile,
43 const string16& terms) {
44 DCHECK(profile);
45 const TemplateURL* default_provider =
46 TemplateURLServiceFactory::GetForProfile(profile)->
47 GetDefaultSearchProvider();
48 if (!default_provider)
49 return GURL();
50 const TemplateURLRef& search_url = default_provider->url_ref();
51 DCHECK(search_url.SupportsReplacement());
52 TemplateURLRef::SearchTermsArgs search_terms_args(terms);
53 return GURL(search_url.ReplaceSearchTerms(search_terms_args));
54 }
55
42 void RemoveDuplicatePrepopulateIDs( 56 void RemoveDuplicatePrepopulateIDs(
43 WebDataService* service, 57 WebDataService* service,
44 const ScopedVector<TemplateURL>& prepopulated_urls, 58 const ScopedVector<TemplateURL>& prepopulated_urls,
45 TemplateURL* default_search_provider, 59 TemplateURL* default_search_provider,
46 TemplateURLService::TemplateURLVector* template_urls, 60 TemplateURLService::TemplateURLVector* template_urls,
47 std::set<std::string>* removed_keyword_guids) { 61 std::set<std::string>* removed_keyword_guids) {
48 DCHECK(service == NULL || BrowserThread::CurrentlyOn(BrowserThread::UI)); 62 DCHECK(service == NULL || BrowserThread::CurrentlyOn(BrowserThread::UI));
49 DCHECK(template_urls); 63 DCHECK(template_urls);
50 64
51 // For convenience construct an ID->TemplateURL* map from |prepopulated_urls|. 65 // For convenience construct an ID->TemplateURL* map from |prepopulated_urls|.
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 std::vector<std::string> deduped_encodings; 345 std::vector<std::string> deduped_encodings;
332 std::set<std::string> encoding_set; 346 std::set<std::string> encoding_set;
333 for (std::vector<std::string>::const_iterator i(encodings->begin()); 347 for (std::vector<std::string>::const_iterator i(encodings->begin());
334 i != encodings->end(); ++i) { 348 i != encodings->end(); ++i) {
335 if (encoding_set.insert(*i).second) 349 if (encoding_set.insert(*i).second)
336 deduped_encodings.push_back(*i); 350 deduped_encodings.push_back(*i);
337 } 351 }
338 encodings->swap(deduped_encodings); 352 encodings->swap(deduped_encodings);
339 return encodings->size() != deduped_encodings.size(); 353 return encodings->size() != deduped_encodings.size();
340 } 354 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/util.h ('k') | chrome/browser/ui/omnibox/omnibox_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698