Chromium Code Reviews| 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 1e138f191eca86a2e035ca5a7c323b381fda238b..7027b89dd44a74fb1b69da8b9977ad3f00e55844 100644 |
| --- a/chrome/browser/android/most_visited_sites.cc |
| +++ b/chrome/browser/android/most_visited_sites.cc |
| @@ -165,32 +165,40 @@ bool NeedPopularSites(const PrefService* prefs, size_t num_tiles) { |
| } // namespace |
| MostVisitedSites::Suggestion::Suggestion(const base::string16& title, |
| - const std::string& url, |
| + const GURL& url, |
| MostVisitedSource source) |
| : title(title), url(url), source(source), provider_index(-1) {} |
| MostVisitedSites::Suggestion::Suggestion(const base::string16& title, |
| - const GURL& url, |
| + const std::string& url, |
| MostVisitedSource source, |
| const base::FilePath& large_icon_path) |
| : title(title), |
| url(url), |
| source(source), |
| large_icon_path(large_icon_path), |
| - provider_index(-1) { |
| - DCHECK_EQ(MostVisitedSites::WHITELIST, source); |
| -} |
| + provider_index(-1) {} |
| MostVisitedSites::Suggestion::Suggestion(const base::string16& title, |
| const GURL& url, |
| - MostVisitedSource source) |
| - : title(title), url(url), source(source), provider_index(-1) {} |
| + MostVisitedSource source, |
| + const base::FilePath& large_icon_path) |
| + : title(title), |
| + url(url), |
| + source(source), |
| + large_icon_path(large_icon_path), |
| + provider_index(-1) {} |
| MostVisitedSites::Suggestion::Suggestion(const base::string16& title, |
| const std::string& url, |
| MostVisitedSource source, |
| + const base::FilePath& large_icon_path, |
| int provider_index) |
| - : title(title), url(url), source(source), provider_index(provider_index) { |
| + : title(title), |
| + url(url), |
| + source(source), |
| + large_icon_path(large_icon_path), |
| + provider_index(provider_index) { |
| DCHECK_EQ(MostVisitedSites::SUGGESTIONS_SERVICE, source); |
| } |
| @@ -486,11 +494,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 (whitelist->entry_point().GetContent() == url.GetContent()) |
| + 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_)); |
| @@ -506,7 +526,8 @@ void MostVisitedSites::OnMostVisitedURLsAvailable( |
| } |
| suggestions.push_back(make_scoped_ptr( |
| - new Suggestion(visited.title, visited.url.spec(), TOP_SITES))); |
| + new Suggestion(visited.title, visited.url.spec(), TOP_SITES, |
|
Marc Treib
2016/03/11 14:21:01
nit (pre-existing): ".spec()" isn't needed, Sugges
atanasova
2016/03/11 15:59:25
Done.
|
| + GetWhitelistLargeIconPath(visited.url)))); |
| } |
| received_most_visited_sites_ = true; |
| @@ -539,7 +560,7 @@ void MostVisitedSites::OnSuggestionsProfileAvailable( |
| suggestions.push_back(make_scoped_ptr(new Suggestion( |
| base::UTF8ToUTF16(suggestion.title()), suggestion.url(), |
| - SUGGESTIONS_SERVICE, |
| + SUGGESTIONS_SERVICE, GetWhitelistLargeIconPath(GURL(suggestion.url())), |
|
Marc Treib
2016/03/11 14:21:01
You could do "GURL url(suggestion.url());" above a
atanasova
2016/03/11 15:59:25
Done.
|
| suggestion.providers_size() > 0 ? suggestion.providers(0) : -1))); |
| } |