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

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: 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
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 118 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
119 119
120 private: 120 private:
121 friend class MostVisitedSitesTest; 121 friend class MostVisitedSitesTest;
122 122
123 // TODO(treib): use SuggestionsVector in internal functions. crbug.com/601734 123 // TODO(treib): use SuggestionsVector in internal functions. crbug.com/601734
124 using SuggestionsPtrVector = std::vector<std::unique_ptr<Suggestion>>; 124 using SuggestionsPtrVector = std::vector<std::unique_ptr<Suggestion>>;
125 125
126 void BuildCurrentSuggestions(); 126 void BuildCurrentSuggestions();
127 127
128 // Initialize the query to Top Sites. Called if the SuggestionsService is not 128 // Initialize the query to Top Sites. Called if the SuggestionsService
129 // enabled, or if it returns no data. 129 // returned no data.
130 void InitiateTopSitesQuery(); 130 void InitiateTopSitesQuery();
131 131
132 // If there's a whitelist entry point for the URL, return the large icon path. 132 // If there's a whitelist entry point for the URL, return the large icon path.
133 base::FilePath GetWhitelistLargeIconPath(const GURL& url); 133 base::FilePath GetWhitelistLargeIconPath(const GURL& url);
134 134
135 // Callback for when data is available from TopSites. 135 // Callback for when data is available from TopSites.
136 void OnMostVisitedURLsAvailable( 136 void OnMostVisitedURLsAvailable(
137 const history::MostVisitedURLList& visited_list); 137 const history::MostVisitedURLList& visited_list);
138 138
139 // Callback for when data is available from the SuggestionsService. 139 // Callback for when data is available from the SuggestionsService.
140 void OnSuggestionsProfileAvailable( 140 void OnSuggestionsProfileAvailable(
141 const suggestions::SuggestionsProfile& suggestions_profile); 141 const suggestions::SuggestionsProfile& suggestions_profile);
142 142
143 // Takes the personal suggestions and creates whitelist entry point 143 // Takes the personal suggestions and creates whitelist entry point
144 // suggestions if necessary. 144 // suggestions if necessary.
145 SuggestionsPtrVector CreateWhitelistEntryPointSuggestions( 145 SuggestionsPtrVector CreateWhitelistEntryPointSuggestions(
146 const SuggestionsPtrVector& personal_suggestions); 146 const SuggestionsPtrVector& personal_suggestions);
147 147
148 // Takes the personal and whitelist suggestions and creates popular 148 // Takes the personal and whitelist suggestions and creates popular
149 // suggestions if necessary. 149 // suggestions if necessary.
150 SuggestionsPtrVector CreatePopularSitesSuggestions( 150 SuggestionsPtrVector CreatePopularSitesSuggestions(
151 const SuggestionsPtrVector& personal_suggestions, 151 const SuggestionsPtrVector& personal_suggestions,
152 const SuggestionsPtrVector& whitelist_suggestions); 152 const SuggestionsPtrVector& whitelist_suggestions);
153 153
154 // Takes the personal suggestions, creates and merges in whitelist and popular 154 // Takes the personal suggestions, creates and merges in whitelist and popular
155 // suggestions if appropriate, and saves the new suggestions. 155 // suggestions if appropriate, and saves the new suggestions.
156 void SaveNewNTPSuggestions(SuggestionsPtrVector* personal_suggestions); 156 void SaveNewSuggestions(SuggestionsPtrVector* personal_suggestions);
157 157
158 // Workhorse for SaveNewNTPSuggestions above. Implemented as a separate static 158 // Workhorse for SaveNewSuggestions above. Implemented as a separate static
159 // method for ease of testing. 159 // method for ease of testing.
160 static SuggestionsPtrVector MergeSuggestions( 160 static SuggestionsPtrVector MergeSuggestions(
161 SuggestionsPtrVector* personal_suggestions, 161 SuggestionsPtrVector* personal_suggestions,
162 SuggestionsPtrVector* whitelist_suggestions, 162 SuggestionsPtrVector* whitelist_suggestions,
163 SuggestionsPtrVector* popular_suggestions, 163 SuggestionsPtrVector* popular_suggestions);
164 const std::vector<std::string>& old_sites_url,
165 const std::vector<bool>& old_sites_is_personal);
166 164
167 void GetPreviousNTPSites(size_t num_tiles, 165 // Appends suggestions from |src| to |dst|.
168 std::vector<std::string>* old_sites_url, 166 static void AppendSuggestions(SuggestionsPtrVector* src,
169 std::vector<bool>* old_sites_source) const; 167 SuggestionsPtrVector* dst);
170 168
171 void SaveCurrentNTPSites(); 169 void SaveCurrentSuggestionsToPrefs();
172
173 // Takes suggestions from |src_suggestions| and moves them to
174 // |dst_suggestions| if the suggestion's url/host matches
175 // |match_urls|/|match_hosts| respectively. Unmatched suggestion indices from
176 // |src_suggestions| are returned for ease of insertion later.
177 static std::vector<size_t> InsertMatchingSuggestions(
178 SuggestionsPtrVector* src_suggestions,
179 SuggestionsPtrVector* dst_suggestions,
180 const std::vector<std::string>& match_urls,
181 const std::vector<std::string>& match_hosts);
182
183 // Inserts suggestions from |src_suggestions| at positions |insert_positions|
184 // into |dst_suggestions| where ever empty starting from |start_position|.
185 // Returns the last filled position so that future insertions can start from
186 // there.
187 static size_t InsertAllSuggestions(
188 size_t start_position,
189 const std::vector<size_t>& insert_positions,
190 SuggestionsPtrVector* src_suggestions,
191 SuggestionsPtrVector* dst_suggestions);
192 170
193 // Notifies the observer about the availability of suggestions. 171 // Notifies the observer about the availability of suggestions.
194 // Also records impressions UMA if not done already. 172 // Also records impressions UMA if not done already.
195 void NotifyMostVisitedURLsObserver(); 173 void NotifyMostVisitedURLsObserver();
196 174
197 void OnPopularSitesAvailable(bool success); 175 void OnPopularSitesAvailable(bool success);
198 176
199 // Runs on the UI Thread. 177 // Runs on the UI Thread.
200 void OnLocalThumbnailFetched( 178 void OnLocalThumbnailFetched(
201 const GURL& url, 179 const GURL& url,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 245
268 SuggestionsVector current_suggestions_; 246 SuggestionsVector current_suggestions_;
269 247
270 // For callbacks may be run after destruction. 248 // For callbacks may be run after destruction.
271 base::WeakPtrFactory<MostVisitedSites> weak_ptr_factory_; 249 base::WeakPtrFactory<MostVisitedSites> weak_ptr_factory_;
272 250
273 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites); 251 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites);
274 }; 252 };
275 253
276 #endif // CHROME_BROWSER_ANDROID_NTP_MOST_VISITED_SITES_H_ 254 #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') | chrome/browser/android/ntp/most_visited_sites.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698