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

Side by Side Diff: components/search_engines/util.h

Issue 2307663002: Remove ScopedVector from search_engines. (Closed)
Patch Set: devlin Created 4 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 COMPONENTS_SEARCH_ENGINES_UTIL_H_ 5 #ifndef COMPONENTS_SEARCH_ENGINES_UTIL_H_
6 #define COMPONENTS_SEARCH_ENGINES_UTIL_H_ 6 #define COMPONENTS_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
9 #include <memory> 10 #include <memory>
10 #include <set> 11 #include <set>
11 #include <string> 12 #include <string>
12 #include <vector> 13 #include <vector>
13 14
14 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
15 #include "components/search_engines/template_url_service.h" 16 #include "components/search_engines/template_url_service.h"
16 17
17 template <typename T>
18 class ScopedVector;
19
20 class KeywordWebDataService; 18 class KeywordWebDataService;
21 class PrefService; 19 class PrefService;
22 class TemplateURL; 20 class TemplateURL;
23 class WDTypedResult; 21 class WDTypedResult;
24 22
25 // Returns the short name of the default search engine, or the empty string if 23 // Returns the short name of the default search engine, or the empty string if
26 // none is set. 24 // none is set.
27 base::string16 GetDefaultSearchEngineName(TemplateURLService* service); 25 base::string16 GetDefaultSearchEngineName(TemplateURLService* service);
28 26
29 // Returns a GURL that searches for |terms| using the default search engine of 27 // Returns a GURL that searches for |terms| using the default search engine of
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 std::vector<TemplateURLData> added_engines; 68 std::vector<TemplateURLData> added_engines;
71 }; 69 };
72 70
73 // Given the user's current URLs and the current set of prepopulated URLs, 71 // Given the user's current URLs and the current set of prepopulated URLs,
74 // produces the set of actions (see above) required to make the user's URLs 72 // produces the set of actions (see above) required to make the user's URLs
75 // reflect the prepopulate data. |default_search_provider| is used to avoid 73 // reflect the prepopulate data. |default_search_provider| is used to avoid
76 // placing the current default provider on the "to be removed" list. 74 // placing the current default provider on the "to be removed" list.
77 // 75 //
78 // NOTE: Takes ownership of, and clears, |prepopulated_urls|. 76 // NOTE: Takes ownership of, and clears, |prepopulated_urls|.
79 ActionsFromPrepopulateData CreateActionsFromCurrentPrepopulateData( 77 ActionsFromPrepopulateData CreateActionsFromCurrentPrepopulateData(
80 ScopedVector<TemplateURLData>* prepopulated_urls, 78 std::vector<std::unique_ptr<TemplateURLData>>* prepopulated_urls,
81 const TemplateURLService::OwnedTemplateURLVector& existing_urls, 79 const TemplateURLService::OwnedTemplateURLVector& existing_urls,
82 const TemplateURL* default_search_provider); 80 const TemplateURL* default_search_provider);
83 81
84 // Processes the results of KeywordWebDataService::GetKeywords, combining it 82 // Processes the results of KeywordWebDataService::GetKeywords, combining it
85 // with prepopulated search providers to result in: 83 // with prepopulated search providers to result in:
86 // * a set of template_urls (search providers). The caller owns the 84 // * a set of template_urls (search providers). The caller owns the
87 // TemplateURL* returned in template_urls. 85 // TemplateURL* returned in template_urls.
88 // * whether there is a new resource keyword version (and the value). 86 // * whether there is a new resource keyword version (and the value).
89 // |*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,
90 // it is the new value. 88 // it is the new value.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // any were found. 122 // any were found.
125 bool DeDupeEncodings(std::vector<std::string>* encodings); 123 bool DeDupeEncodings(std::vector<std::string>* encodings);
126 124
127 // Removes (and deletes) TemplateURLs from |template_urls| and |service| if they 125 // Removes (and deletes) TemplateURLs from |template_urls| and |service| if they
128 // have duplicate prepopulate ids. If |removed_keyword_guids| is not NULL, the 126 // have duplicate prepopulate ids. If |removed_keyword_guids| is not NULL, the
129 // Sync GUID of each item removed from the DB will be added to it. This is a 127 // Sync GUID of each item removed from the DB will be added to it. This is a
130 // helper used by GetSearchProvidersUsingKeywordResult(), but is declared here 128 // helper used by GetSearchProvidersUsingKeywordResult(), but is declared here
131 // so it's accessible by unittests. 129 // so it's accessible by unittests.
132 void RemoveDuplicatePrepopulateIDs( 130 void RemoveDuplicatePrepopulateIDs(
133 KeywordWebDataService* service, 131 KeywordWebDataService* service,
134 const ScopedVector<TemplateURLData>& prepopulated_urls, 132 const std::vector<std::unique_ptr<TemplateURLData>>& prepopulated_urls,
135 TemplateURL* default_search_provider, 133 TemplateURL* default_search_provider,
136 TemplateURLService::OwnedTemplateURLVector* template_urls, 134 TemplateURLService::OwnedTemplateURLVector* template_urls,
137 const SearchTermsData& search_terms_data, 135 const SearchTermsData& search_terms_data,
138 std::set<std::string>* removed_keyword_guids); 136 std::set<std::string>* removed_keyword_guids);
139 137
140 TemplateURLService::OwnedTemplateURLVector::iterator FindTemplateURL( 138 TemplateURLService::OwnedTemplateURLVector::iterator FindTemplateURL(
141 TemplateURLService::OwnedTemplateURLVector* urls, 139 TemplateURLService::OwnedTemplateURLVector* urls,
142 const TemplateURL* url); 140 const TemplateURL* url);
143 141
144 #endif // COMPONENTS_SEARCH_ENGINES_UTIL_H_ 142 #endif // COMPONENTS_SEARCH_ENGINES_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698