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

Side by Side Diff: chrome/browser/android/ntp/most_visited_sites.h

Issue 1972923002: MostVisitedSites: Remove unused order-persisting code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: one more TODO, and rebase Created 4 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
« no previous file with comments | « no previous file | chrome/browser/android/ntp/most_visited_sites.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_ANDROID_NTP_MOST_VISITED_SITES_H_ 5 #ifndef CHROME_BROWSER_ANDROID_NTP_MOST_VISITED_SITES_H_
6 #define CHROME_BROWSER_ANDROID_NTP_MOST_VISITED_SITES_H_ 6 #define CHROME_BROWSER_ANDROID_NTP_MOST_VISITED_SITES_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 152 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
153 153
154 private: 154 private:
155 friend class MostVisitedSitesTest; 155 friend class MostVisitedSitesTest;
156 156
157 // TODO(treib): use SuggestionsVector in internal functions. crbug.com/601734 157 // TODO(treib): use SuggestionsVector in internal functions. crbug.com/601734
158 using SuggestionsPtrVector = std::vector<std::unique_ptr<Suggestion>>; 158 using SuggestionsPtrVector = std::vector<std::unique_ptr<Suggestion>>;
159 159
160 void BuildCurrentSuggestions(); 160 void BuildCurrentSuggestions();
161 161
162 // Initialize the query to Top Sites. Called if the SuggestionsService is not 162 // Initialize the query to Top Sites. Called if the SuggestionsService
163 // enabled, or if it returns no data. 163 // returned no data.
164 void InitiateTopSitesQuery(); 164 void InitiateTopSitesQuery();
165 165
166 // If there's a whitelist entry point for the URL, return the large icon path. 166 // If there's a whitelist entry point for the URL, return the large icon path.
167 base::FilePath GetWhitelistLargeIconPath(const GURL& url); 167 base::FilePath GetWhitelistLargeIconPath(const GURL& url);
168 168
169 // Callback for when data is available from TopSites. 169 // Callback for when data is available from TopSites.
170 void OnMostVisitedURLsAvailable( 170 void OnMostVisitedURLsAvailable(
171 const history::MostVisitedURLList& visited_list); 171 const history::MostVisitedURLList& visited_list);
172 172
173 // Callback for when data is available from the SuggestionsService. 173 // Callback for when data is available from the SuggestionsService.
174 void OnSuggestionsProfileAvailable( 174 void OnSuggestionsProfileAvailable(
175 const suggestions::SuggestionsProfile& suggestions_profile); 175 const suggestions::SuggestionsProfile& suggestions_profile);
176 176
177 // Takes the personal suggestions and creates whitelist entry point 177 // Takes the personal suggestions and creates whitelist entry point
178 // suggestions if necessary. 178 // suggestions if necessary.
179 SuggestionsPtrVector CreateWhitelistEntryPointSuggestions( 179 SuggestionsPtrVector CreateWhitelistEntryPointSuggestions(
180 const SuggestionsPtrVector& personal_suggestions); 180 const SuggestionsPtrVector& personal_suggestions);
181 181
182 // Takes the personal and whitelist suggestions and creates popular 182 // Takes the personal and whitelist suggestions and creates popular
183 // suggestions if necessary. 183 // suggestions if necessary.
184 SuggestionsPtrVector CreatePopularSitesSuggestions( 184 SuggestionsPtrVector CreatePopularSitesSuggestions(
185 const SuggestionsPtrVector& personal_suggestions, 185 const SuggestionsPtrVector& personal_suggestions,
186 const SuggestionsPtrVector& whitelist_suggestions); 186 const SuggestionsPtrVector& whitelist_suggestions);
187 187
188 // Takes the personal suggestions, creates and merges in whitelist and popular 188 // Takes the personal suggestions, creates and merges in whitelist and popular
189 // suggestions if appropriate, and saves the new suggestions. 189 // suggestions if appropriate, and saves the new suggestions.
190 void SaveNewNTPSuggestions(SuggestionsPtrVector* personal_suggestions); 190 void SaveNewSuggestions(SuggestionsPtrVector* personal_suggestions);
191 191
192 // Workhorse for SaveNewNTPSuggestions above. Implemented as a separate static 192 // Workhorse for SaveNewSuggestions above. Implemented as a separate static
193 // method for ease of testing. 193 // method for ease of testing.
194 static SuggestionsPtrVector MergeSuggestions( 194 static SuggestionsPtrVector MergeSuggestions(
195 SuggestionsPtrVector* personal_suggestions, 195 SuggestionsPtrVector* personal_suggestions,
196 SuggestionsPtrVector* whitelist_suggestions, 196 SuggestionsPtrVector* whitelist_suggestions,
197 SuggestionsPtrVector* popular_suggestions, 197 SuggestionsPtrVector* popular_suggestions);
198 const std::vector<std::string>& old_sites_url,
199 const std::vector<bool>& old_sites_is_personal);
200 198
201 void GetPreviousNTPSites(size_t num_tiles, 199 // Appends suggestions from |src| to |dst|.
202 std::vector<std::string>* old_sites_url, 200 static void AppendSuggestions(SuggestionsPtrVector* src,
203 std::vector<bool>* old_sites_source) const; 201 SuggestionsPtrVector* dst);
204 202
205 void SaveCurrentNTPSites(); 203 void SaveCurrentSuggestionsToPrefs();
206
207 // Takes suggestions from |src_suggestions| and moves them to
208 // |dst_suggestions| if the suggestion's url/host matches
209 // |match_urls|/|match_hosts| respectively. Unmatched suggestion indices from
210 // |src_suggestions| are returned for ease of insertion later.
211 static std::vector<size_t> InsertMatchingSuggestions(
212 SuggestionsPtrVector* src_suggestions,
213 SuggestionsPtrVector* dst_suggestions,
214 const std::vector<std::string>& match_urls,
215 const std::vector<std::string>& match_hosts);
216
217 // Inserts suggestions from |src_suggestions| at positions |insert_positions|
218 // into |dst_suggestions| where ever empty starting from |start_position|.
219 // Returns the last filled position so that future insertions can start from
220 // there.
221 static size_t InsertAllSuggestions(
222 size_t start_position,
223 const std::vector<size_t>& insert_positions,
224 SuggestionsPtrVector* src_suggestions,
225 SuggestionsPtrVector* dst_suggestions);
226 204
227 // Notifies the observer about the availability of suggestions. 205 // Notifies the observer about the availability of suggestions.
228 // Also records impressions UMA if not done already. 206 // Also records impressions UMA if not done already.
229 void NotifyMostVisitedURLsObserver(); 207 void NotifyMostVisitedURLsObserver();
230 208
231 void OnPopularSitesAvailable(bool success); 209 void OnPopularSitesAvailable(bool success);
232 210
233 // Runs on the UI Thread. 211 // Runs on the UI Thread.
234 void OnLocalThumbnailFetched( 212 void OnLocalThumbnailFetched(
235 const GURL& url, 213 const GURL& url,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 271
294 SuggestionsVector current_suggestions_; 272 SuggestionsVector current_suggestions_;
295 273
296 // For callbacks may be run after destruction. 274 // For callbacks may be run after destruction.
297 base::WeakPtrFactory<MostVisitedSites> weak_ptr_factory_; 275 base::WeakPtrFactory<MostVisitedSites> weak_ptr_factory_;
298 276
299 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites); 277 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites);
300 }; 278 };
301 279
302 #endif // CHROME_BROWSER_ANDROID_NTP_MOST_VISITED_SITES_H_ 280 #endif // CHROME_BROWSER_ANDROID_NTP_MOST_VISITED_SITES_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/ntp/most_visited_sites.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698