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..74f92f510cd4a2135fbf2845097a9bfa4e89bb31 100644 |
--- a/chrome/browser/android/most_visited_sites.cc |
+++ b/chrome/browser/android/most_visited_sites.cc |
@@ -158,6 +158,12 @@ bool NeedPopularSites(const PrefService* prefs, size_t num_tiles) { |
return false; |
} |
+bool URLsEquals(const GURL& url1, const GURL& url2) { |
Marc Treib
2016/03/22 12:25:38
nit: AreURLsEquivalent or something? We're not act
atanasova
2016/03/22 14:14:10
Done.
|
+ std::string truncated_url1 = url1.host() + url1.path(); |
+ std::string truncated_url2 = url2.host() + url2.path(); |
+ return truncated_url1 == truncated_url2; |
Marc Treib
2016/03/22 12:25:38
I'd just compare host() and path() separately, tha
atanasova
2016/03/22 14:14:10
Done.
|
+} |
+ |
} // namespace |
MostVisitedSites::Suggestion::Suggestion() : provider_index(-1) {} |
@@ -429,11 +435,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 (URLsEquals(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 +470,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 +507,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); |