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

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

Issue 10409002: Make prepopulated-TemplateURL-de-duper heuristic smarter. Instead of blindly preserving the first U… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Steve's initial changes + tests Created 8 years, 7 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
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 #ifndef CHROME_BROWSER_SEARCH_ENGINES_UTIL_H_ 5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_UTIL_H_
6 #define CHROME_BROWSER_SEARCH_ENGINES_UTIL_H_ 6 #define CHROME_BROWSER_SEARCH_ENGINES_UTIL_H_
7 #pragma once 7 #pragma once
8 8
9 // This file contains utility functions for search engine functionality. 9 // This file contains utility functions for search engine functionality.
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/string16.h" 13 #include "base/string16.h"
14 #include "chrome/browser/search_engines/template_url_service.h"
14 15
15 class Profile; 16 class Profile;
16 class TemplateURL; 17 class TemplateURL;
17 class WDTypedResult; 18 class WDTypedResult;
18 class WebDataService; 19 class WebDataService;
19 20
20 // Returns the short name of the default search engine, or the empty string if 21 // Returns the short name of the default search engine, or the empty string if
21 // none is set. |profile| may be NULL. 22 // none is set. |profile| may be NULL.
22 string16 GetDefaultSearchEngineName(Profile* profile); 23 string16 GetDefaultSearchEngineName(Profile* profile);
23 24
24 // Processes the results of WebDataService::GetKeywords, combining it with 25 // Processes the results of WebDataService::GetKeywords, combining it with
25 // prepopulated search providers to result in: 26 // prepopulated search providers to result in:
26 // * a set of template_urls (search providers). The caller owns the 27 // * a set of template_urls (search providers). The caller owns the
27 // TemplateURL* returned in template_urls. 28 // TemplateURL* returned in template_urls.
28 // * the default search provider (and if *default_search_provider is not NULL, 29 // * the default search provider (and if *default_search_provider is not NULL,
29 // it is contained in template_urls). 30 // it is contained in template_urls).
30 // * whether there is a new resource keyword version (and the value). 31 // * whether there is a new resource keyword version (and the value).
31 // |*new_resource_keyword_version| is set to 0 if no new value. Otherwise, 32 // |*new_resource_keyword_version| is set to 0 if no new value. Otherwise,
32 // it is the new value. 33 // it is the new value.
33 // Only pass in a non-NULL value for service if the WebDataService should be 34 // Only pass in a non-NULL value for service if the WebDataService should be
34 // updated. 35 // updated.
35 void GetSearchProvidersUsingKeywordResult( 36 void GetSearchProvidersUsingKeywordResult(
36 const WDTypedResult& result, 37 const WDTypedResult& result,
37 WebDataService* service, 38 WebDataService* service,
38 Profile* profile, 39 Profile* profile,
39 std::vector<TemplateURL*>* template_urls, 40 TemplateURLService::TemplateURLVector* template_urls,
40 TemplateURL** default_search_provider, 41 TemplateURL** default_search_provider,
41 int* new_resource_keyword_version); 42 int* new_resource_keyword_version);
42 43
43 // Returns true if the default search provider setting has been changed or 44 // Returns true if the default search provider setting has been changed or
44 // corrupted. Returns the backup setting in |backup_default_search_provider|. 45 // corrupted. Returns the backup setting in |backup_default_search_provider|.
45 // |*backup_default_search_provider| can be NULL if the original setting is 46 // |*backup_default_search_provider| can be NULL if the original setting is
46 // lost. 47 // lost.
47 bool DidDefaultSearchProviderChange( 48 bool DidDefaultSearchProviderChange(
48 const WDTypedResult& result, 49 const WDTypedResult& result,
49 Profile* profile, 50 Profile* profile,
50 scoped_ptr<TemplateURL>* backup_default_search_provider); 51 scoped_ptr<TemplateURL>* backup_default_search_provider);
51 52
53 namespace testing {
54
55 // Expose and document for testing.
56 void TestRemoveDuplicatePrepopulateIDs(
57 WebDataService* service,
58 const std::vector<TemplateURL*>& prepopulated_urls,
59 TemplateURL* default_search_provider,
60 TemplateURLService::TemplateURLVector* template_urls);
SteveT 2012/05/17 13:34:54 I'm exposing RemoveDuplicatePrepopulateIDs for dir
Peter Kasting 2012/05/17 20:12:17 Seems like at this point we might as well just dec
SteveT 2012/05/17 21:27:22 Okay that's fair. Done.
61
62 } // namespace testing
63
52 #endif // CHROME_BROWSER_SEARCH_ENGINES_UTIL_H_ 64 #endif // CHROME_BROWSER_SEARCH_ENGINES_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698