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

Unified Diff: chrome/browser/android/most_visited_sites.cc

Issue 1787633002: Use whitelist large icon for corresponding most visited suggestions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@icon-whitelist
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/most_visited_sites.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/most_visited_sites.cc
diff --git a/chrome/browser/android/most_visited_sites.cc b/chrome/browser/android/most_visited_sites.cc
index 3aac22e1b3b35cf4ef04a8386cd1c944a5bb4972..b13b5921f94ec1443575ce7a3032ed4cb1a3e84c 100644
--- a/chrome/browser/android/most_visited_sites.cc
+++ b/chrome/browser/android/most_visited_sites.cc
@@ -158,6 +158,10 @@ bool NeedPopularSites(const PrefService* prefs, size_t num_tiles) {
return false;
}
+bool AreURLsEquivalent(const GURL& url1, const GURL& url2) {
+ return url1.host() == url2.host() && url1.path() == url2.path();
+}
+
} // namespace
MostVisitedSites::Suggestion::Suggestion() : provider_index(-1) {}
@@ -429,11 +433,23 @@ void MostVisitedSites::InitiateTopSitesQuery() {
false);
}
+base::FilePath MostVisitedSites::GetWhitelistLargeIconPath(const GURL& url) {
+ SupervisedUserService* supervised_user_service =
+ SupervisedUserServiceFactory::GetForProfile(profile_);
+
+ for (const auto& whitelist : supervised_user_service->whitelists()) {
+ if (AreURLsEquivalent(whitelist->entry_point(), url))
+ return whitelist->large_icon_path();
+ }
+ return base::FilePath();
+}
+
void MostVisitedSites::OnMostVisitedURLsAvailable(
const history::MostVisitedURLList& visited_list) {
SupervisedUserURLFilter* url_filter =
SupervisedUserServiceFactory::GetForProfile(profile_)
->GetURLFilterForUIThread();
+
MostVisitedSites::SuggestionsVector suggestions;
size_t num_tiles =
std::min(visited_list.size(), static_cast<size_t>(num_sites_));
@@ -452,6 +468,7 @@ void MostVisitedSites::OnMostVisitedURLsAvailable(
suggestion->title = visited.title;
suggestion->url = visited.url;
suggestion->source = TOP_SITES;
+ suggestion->whitelist_icon_path = GetWhitelistLargeIconPath(visited.url);
suggestions.push_back(std::move(suggestion));
}
@@ -488,6 +505,8 @@ void MostVisitedSites::OnSuggestionsProfileAvailable(
generated_suggestion->title = base::UTF8ToUTF16(suggestion.title());
generated_suggestion->url = GURL(suggestion.url());
generated_suggestion->source = SUGGESTIONS_SERVICE;
+ generated_suggestion->whitelist_icon_path = GetWhitelistLargeIconPath(
+ GURL(suggestion.url()));
if (suggestion.providers_size() > 0)
generated_suggestion->provider_index = suggestion.providers(0);
« no previous file with comments | « chrome/browser/android/most_visited_sites.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698