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 #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 <set> |
| 11 #include <string> |
10 #include <vector> | 12 #include <vector> |
11 | 13 |
12 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
13 #include "base/string16.h" | 15 #include "base/string16.h" |
14 | 16 |
15 class Profile; | 17 class Profile; |
16 class TemplateURL; | 18 class TemplateURL; |
17 class WDTypedResult; | 19 class WDTypedResult; |
18 class WebDataService; | 20 class WebDataService; |
19 | 21 |
20 // Returns the short name of the default search engine, or the empty string if | 22 // Returns the short name of the default search engine, or the empty string if |
21 // none is set. |profile| may be NULL. | 23 // none is set. |profile| may be NULL. |
22 string16 GetDefaultSearchEngineName(Profile* profile); | 24 string16 GetDefaultSearchEngineName(Profile* profile); |
23 | 25 |
24 // Processes the results of WebDataService::GetKeywords, combining it with | 26 // Processes the results of WebDataService::GetKeywords, combining it with |
25 // prepopulated search providers to result in: | 27 // prepopulated search providers to result in: |
26 // * a set of template_urls (search providers). The caller owns the | 28 // * a set of template_urls (search providers). The caller owns the |
27 // TemplateURL* returned in template_urls. | 29 // TemplateURL* returned in template_urls. |
28 // * the default search provider (and if *default_search_provider is not NULL, | 30 // * the default search provider (and if *default_search_provider is not NULL, |
29 // it is contained in template_urls). | 31 // it is contained in template_urls). |
30 // * whether there is a new resource keyword version (and the value). | 32 // * 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, | 33 // |*new_resource_keyword_version| is set to 0 if no new value. Otherwise, |
32 // it is the new value. | 34 // it is the new value. |
33 // Only pass in a non-NULL value for service if the WebDataService should be | 35 // Only pass in a non-NULL value for service if the WebDataService should be |
34 // updated. | 36 // updated. If |removed_keyword_guids| is not NULL, any TemplateURLs removed |
| 37 // from the keyword table in the WebDataService will have their Sync GUIDs |
| 38 // added to it. |
35 void GetSearchProvidersUsingKeywordResult( | 39 void GetSearchProvidersUsingKeywordResult( |
36 const WDTypedResult& result, | 40 const WDTypedResult& result, |
37 WebDataService* service, | 41 WebDataService* service, |
38 Profile* profile, | 42 Profile* profile, |
39 std::vector<TemplateURL*>* template_urls, | 43 std::vector<TemplateURL*>* template_urls, |
40 TemplateURL** default_search_provider, | 44 TemplateURL** default_search_provider, |
41 int* new_resource_keyword_version); | 45 int* new_resource_keyword_version, |
| 46 std::set<std::string>* removed_keyword_guids); |
42 | 47 |
43 // Returns true if the default search provider setting has been changed or | 48 // Returns true if the default search provider setting has been changed or |
44 // corrupted. Returns the backup setting in |backup_default_search_provider|. | 49 // corrupted. Returns the backup setting in |backup_default_search_provider|. |
45 // |*backup_default_search_provider| can be NULL if the original setting is | 50 // |*backup_default_search_provider| can be NULL if the original setting is |
46 // lost. | 51 // lost. |
47 bool DidDefaultSearchProviderChange( | 52 bool DidDefaultSearchProviderChange( |
48 const WDTypedResult& result, | 53 const WDTypedResult& result, |
49 Profile* profile, | 54 Profile* profile, |
50 scoped_ptr<TemplateURL>* backup_default_search_provider); | 55 scoped_ptr<TemplateURL>* backup_default_search_provider); |
51 | 56 |
52 #endif // CHROME_BROWSER_SEARCH_ENGINES_UTIL_H_ | 57 #endif // CHROME_BROWSER_SEARCH_ENGINES_UTIL_H_ |
OLD | NEW |