| 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 | 7 |
| 8 // This file contains utility functions for search engine functionality. | 8 // This file contains utility functions for search engine functionality. |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 // NOTE: Takes ownership of, and clears, |prepopulated_urls|. | 74 // NOTE: Takes ownership of, and clears, |prepopulated_urls|. |
| 75 ActionsFromPrepopulateData CreateActionsFromCurrentPrepopulateData( | 75 ActionsFromPrepopulateData CreateActionsFromCurrentPrepopulateData( |
| 76 ScopedVector<TemplateURLData>* prepopulated_urls, | 76 ScopedVector<TemplateURLData>* prepopulated_urls, |
| 77 const TemplateURLService::TemplateURLVector& existing_urls, | 77 const TemplateURLService::TemplateURLVector& existing_urls, |
| 78 const TemplateURL* default_search_provider); | 78 const TemplateURL* default_search_provider); |
| 79 | 79 |
| 80 // Processes the results of WebDataService::GetKeywords, combining it with | 80 // Processes the results of WebDataService::GetKeywords, combining it with |
| 81 // prepopulated search providers to result in: | 81 // prepopulated search providers to result in: |
| 82 // * a set of template_urls (search providers). The caller owns the | 82 // * a set of template_urls (search providers). The caller owns the |
| 83 // TemplateURL* returned in template_urls. | 83 // TemplateURL* returned in template_urls. |
| 84 // * the default search provider (and if *default_search_provider is not NULL, |
| 85 // it is contained in template_urls). |
| 84 // * whether there is a new resource keyword version (and the value). | 86 // * whether there is a new resource keyword version (and the value). |
| 85 // |*new_resource_keyword_version| is set to 0 if no new value. Otherwise, | 87 // |*new_resource_keyword_version| is set to 0 if no new value. Otherwise, |
| 86 // it is the new value. | 88 // it is the new value. |
| 87 // Only pass in a non-NULL value for service if the WebDataService should be | 89 // Only pass in a non-NULL value for service if the WebDataService should be |
| 88 // updated. If |removed_keyword_guids| is not NULL, any TemplateURLs removed | 90 // updated. If |removed_keyword_guids| is not NULL, any TemplateURLs removed |
| 89 // from the keyword table in the WebDataService will have their Sync GUIDs | 91 // from the keyword table in the WebDataService will have their Sync GUIDs |
| 90 // added to it. |default_search_provider| will be used to prevent removing the | 92 // added to it. |
| 91 // current user-selected DSE, regardless of changes in prepopulate data. | |
| 92 void GetSearchProvidersUsingKeywordResult( | 93 void GetSearchProvidersUsingKeywordResult( |
| 93 const WDTypedResult& result, | 94 const WDTypedResult& result, |
| 94 WebDataService* service, | 95 WebDataService* service, |
| 95 Profile* profile, | 96 Profile* profile, |
| 96 TemplateURLService::TemplateURLVector* template_urls, | 97 TemplateURLService::TemplateURLVector* template_urls, |
| 97 TemplateURL* default_search_provider, | 98 TemplateURL** default_search_provider, |
| 98 int* new_resource_keyword_version, | 99 int* new_resource_keyword_version, |
| 99 std::set<std::string>* removed_keyword_guids); | 100 std::set<std::string>* removed_keyword_guids); |
| 100 | 101 |
| 101 // Like GetSearchProvidersUsingKeywordResult(), but allows the caller to pass in | 102 // Like GetSearchProvidersUsingKeywordResult(), but allows the caller to pass in |
| 102 // engines in |template_urls| instead of getting them via processing a web data | 103 // engines in |template_urls| instead of getting them via processing a web data |
| 103 // service request. | 104 // service request. |
| 104 // |resource_keyword_version| should contain the version number of the current | 105 // |resource_keyword_version| should contain the version number of the current |
| 105 // keyword data, i.e. the version number of the most recent prepopulate data | 106 // keyword data, i.e. the version number of the most recent prepopulate data |
| 106 // that has been merged into the current keyword data. On exit, this will be | 107 // that has been merged into the current keyword data. On exit, this will be |
| 107 // set as in GetSearchProvidersUsingKeywordResult(). | 108 // set as in GetSearchProvidersUsingKeywordResult(). |
| 108 void GetSearchProvidersUsingLoadedEngines( | 109 void GetSearchProvidersUsingLoadedEngines( |
| 109 WebDataService* service, | 110 WebDataService* service, |
| 110 Profile* profile, | 111 Profile* profile, |
| 111 TemplateURLService::TemplateURLVector* template_urls, | 112 TemplateURLService::TemplateURLVector* template_urls, |
| 112 TemplateURL* default_search_provider, | 113 TemplateURL** default_search_provider, |
| 113 int* resource_keyword_version, | 114 int* resource_keyword_version, |
| 114 std::set<std::string>* removed_keyword_guids); | 115 std::set<std::string>* removed_keyword_guids); |
| 115 | 116 |
| 116 // Due to a bug, the |input_encodings| field of TemplateURLData could have | 117 // Due to a bug, the |input_encodings| field of TemplateURLData could have |
| 117 // contained duplicate entries. This removes those entries and returns whether | 118 // contained duplicate entries. This removes those entries and returns whether |
| 118 // any were found. | 119 // any were found. |
| 119 bool DeDupeEncodings(std::vector<std::string>* encodings); | 120 bool DeDupeEncodings(std::vector<std::string>* encodings); |
| 120 | 121 |
| 121 // Removes (and deletes) TemplateURLs from |template_urls| and |service| if they | 122 // Removes (and deletes) TemplateURLs from |template_urls| and |service| if they |
| 122 // have duplicate prepopulate ids. If |removed_keyword_guids| is not NULL, the | 123 // have duplicate prepopulate ids. If |removed_keyword_guids| is not NULL, the |
| 123 // Sync GUID of each item removed from the DB will be added to it. This is a | 124 // Sync GUID of each item removed from the DB will be added to it. This is a |
| 124 // helper used by GetSearchProvidersUsingKeywordResult(), but is declared here | 125 // helper used by GetSearchProvidersUsingKeywordResult(), but is declared here |
| 125 // so it's accessible by unittests. | 126 // so it's accessible by unittests. |
| 126 void RemoveDuplicatePrepopulateIDs( | 127 void RemoveDuplicatePrepopulateIDs( |
| 127 WebDataService* service, | 128 WebDataService* service, |
| 128 const ScopedVector<TemplateURLData>& prepopulated_urls, | 129 const ScopedVector<TemplateURLData>& prepopulated_urls, |
| 129 TemplateURL* default_search_provider, | 130 TemplateURL* default_search_provider, |
| 130 TemplateURLService::TemplateURLVector* template_urls, | 131 TemplateURLService::TemplateURLVector* template_urls, |
| 131 std::set<std::string>* removed_keyword_guids); | 132 std::set<std::string>* removed_keyword_guids); |
| 132 | 133 |
| 133 #endif // CHROME_BROWSER_SEARCH_ENGINES_UTIL_H_ | 134 #endif // CHROME_BROWSER_SEARCH_ENGINES_UTIL_H_ |
| OLD | NEW |