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

Side by Side Diff: chrome/browser/android/most_visited_sites.cc

Issue 1772363002: Start using the whitelist icon on the NTP. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 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 #include "chrome/browser/android/most_visited_sites.h" 5 #include "chrome/browser/android/most_visited_sites.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 // The whole grid is already filled with personal suggestions, no point in 160 // The whole grid is already filled with personal suggestions, no point in
161 // bothering with popular ones. 161 // bothering with popular ones.
162 return false; 162 return false;
163 } 163 }
164 164
165 } // namespace 165 } // namespace
166 166
167 MostVisitedSites::Suggestion::Suggestion(const base::string16& title, 167 MostVisitedSites::Suggestion::Suggestion(const base::string16& title,
168 const std::string& url, 168 const std::string& url,
169 MostVisitedSource source) 169 MostVisitedSource source)
170 : title(title), url(url), source(source), provider_index(-1) {} 170 : title(title),
171 url(url),
172 local_large_icon_path(base::FilePath()),
Marc Treib 2016/03/08 14:27:12 This is unnecessary, also below
atanasova 2016/03/08 15:53:58 Done.
173 source(source),
174 provider_index(-1) {}
175
176 MostVisitedSites::Suggestion::Suggestion(
177 const base::string16& title,
178 const GURL& url,
179 const base::FilePath& local_large_icon_path,
180 MostVisitedSource source)
181 : title(title),
182 url(url),
183 local_large_icon_path(local_large_icon_path),
184 source(source),
185 provider_index(-1) {}
171 186
172 MostVisitedSites::Suggestion::Suggestion(const base::string16& title, 187 MostVisitedSites::Suggestion::Suggestion(const base::string16& title,
173 const GURL& url, 188 const GURL& url,
174 MostVisitedSource source) 189 MostVisitedSource source)
175 : title(title), url(url), source(source), provider_index(-1) {} 190 : title(title),
191 url(url),
192 local_large_icon_path(base::FilePath()),
193 source(source),
194 provider_index(-1) {}
176 195
177 MostVisitedSites::Suggestion::Suggestion(const base::string16& title, 196 MostVisitedSites::Suggestion::Suggestion(const base::string16& title,
178 const std::string& url, 197 const std::string& url,
179 MostVisitedSource source, 198 MostVisitedSource source,
180 int provider_index) 199 int provider_index)
181 : title(title), url(url), source(source), provider_index(provider_index) { 200 : title(title),
201 url(url),
202 local_large_icon_path(base::FilePath()),
203 source(source),
204 provider_index(provider_index) {
182 DCHECK_EQ(MostVisitedSites::SUGGESTIONS_SERVICE, source); 205 DCHECK_EQ(MostVisitedSites::SUGGESTIONS_SERVICE, source);
183 } 206 }
184 207
185 MostVisitedSites::Suggestion::~Suggestion() {} 208 MostVisitedSites::Suggestion::~Suggestion() {}
186 209
187 std::string MostVisitedSites::Suggestion::GetSourceHistogramName() const { 210 std::string MostVisitedSites::Suggestion::GetSourceHistogramName() const {
188 switch (source) { 211 switch (source) {
189 case MostVisitedSites::TOP_SITES: 212 case MostVisitedSites::TOP_SITES:
190 return kHistogramClientName; 213 return kHistogramClientName;
191 case MostVisitedSites::POPULAR: 214 case MostVisitedSites::POPULAR:
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 if (personal_hosts.find(whitelist->entry_point().host()) != 588 if (personal_hosts.find(whitelist->entry_point().host()) !=
566 personal_hosts.end()) 589 personal_hosts.end())
567 continue; 590 continue;
568 591
569 // Skip whitelist entry points that are manually blocked. 592 // Skip whitelist entry points that are manually blocked.
570 if (url_filter->GetFilteringBehaviorForURL(whitelist->entry_point()) == 593 if (url_filter->GetFilteringBehaviorForURL(whitelist->entry_point()) ==
571 SupervisedUserURLFilter::FilteringBehavior::BLOCK) { 594 SupervisedUserURLFilter::FilteringBehavior::BLOCK) {
572 continue; 595 continue;
573 } 596 }
574 597
575 whitelist_suggestions.push_back(make_scoped_ptr(new Suggestion( 598 whitelist_suggestions.push_back(make_scoped_ptr(
576 whitelist->title(), whitelist->entry_point(), WHITELIST))); 599 new Suggestion(whitelist->title(), whitelist->entry_point(),
600 whitelist->large_icon_path(), WHITELIST)));
577 if (whitelist_suggestions.size() >= num_whitelist_suggestions) 601 if (whitelist_suggestions.size() >= num_whitelist_suggestions)
578 break; 602 break;
579 } 603 }
580 604
581 return whitelist_suggestions; 605 return whitelist_suggestions;
582 } 606 }
583 607
584 MostVisitedSites::SuggestionsVector 608 MostVisitedSites::SuggestionsVector
585 MostVisitedSites::CreatePopularSitesSuggestions( 609 MostVisitedSites::CreatePopularSitesSuggestions(
586 const MostVisitedSites::SuggestionsVector& personal_suggestions, 610 const MostVisitedSites::SuggestionsVector& personal_suggestions,
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 void MostVisitedSites::NotifyMostVisitedURLsObserver() { 819 void MostVisitedSites::NotifyMostVisitedURLsObserver() {
796 size_t num_suggestions = current_suggestions_.size(); 820 size_t num_suggestions = current_suggestions_.size();
797 if (received_most_visited_sites_ && received_popular_sites_ && 821 if (received_most_visited_sites_ && received_popular_sites_ &&
798 !recorded_uma_) { 822 !recorded_uma_) {
799 RecordImpressionUMAMetrics(); 823 RecordImpressionUMAMetrics();
800 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.NumberOfTiles", num_suggestions); 824 UMA_HISTOGRAM_SPARSE_SLOWLY("NewTabPage.NumberOfTiles", num_suggestions);
801 recorded_uma_ = true; 825 recorded_uma_ = true;
802 } 826 }
803 std::vector<base::string16> titles; 827 std::vector<base::string16> titles;
804 std::vector<std::string> urls; 828 std::vector<std::string> urls;
829 std::vector<std::string> local_icon_paths;
805 titles.reserve(num_suggestions); 830 titles.reserve(num_suggestions);
806 urls.reserve(num_suggestions); 831 urls.reserve(num_suggestions);
807 for (const auto& suggestion : current_suggestions_) { 832 for (const auto& suggestion : current_suggestions_) {
808 titles.push_back(suggestion->title); 833 titles.push_back(suggestion->title);
809 urls.push_back(suggestion->url.spec()); 834 urls.push_back(suggestion->url.spec());
835 local_icon_paths.push_back(suggestion->local_large_icon_path.value());
810 } 836 }
811 JNIEnv* env = AttachCurrentThread(); 837 JNIEnv* env = AttachCurrentThread();
812 DCHECK_EQ(titles.size(), urls.size()); 838 DCHECK_EQ(titles.size(), urls.size());
813 Java_MostVisitedURLsObserver_onMostVisitedURLsAvailable( 839 Java_MostVisitedURLsObserver_onMostVisitedURLsAvailable(
814 env, observer_.obj(), ToJavaArrayOfStrings(env, titles).obj(), 840 env, observer_.obj(), ToJavaArrayOfStrings(env, titles).obj(),
815 ToJavaArrayOfStrings(env, urls).obj()); 841 ToJavaArrayOfStrings(env, urls).obj(),
842 ToJavaArrayOfStrings(env, local_icon_paths).obj());
816 } 843 }
817 844
818 void MostVisitedSites::OnPopularSitesAvailable(bool success) { 845 void MostVisitedSites::OnPopularSitesAvailable(bool success) {
819 received_popular_sites_ = true; 846 received_popular_sites_ = true;
820 847
821 if (!success) { 848 if (!success) {
822 LOG(WARNING) << "Download of popular sites failed"; 849 LOG(WARNING) << "Download of popular sites failed";
823 return; 850 return;
824 } 851 }
825 852
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 } 889 }
863 } 890 }
864 891
865 static jlong Init(JNIEnv* env, 892 static jlong Init(JNIEnv* env,
866 const JavaParamRef<jobject>& obj, 893 const JavaParamRef<jobject>& obj,
867 const JavaParamRef<jobject>& jprofile) { 894 const JavaParamRef<jobject>& jprofile) {
868 MostVisitedSites* most_visited_sites = 895 MostVisitedSites* most_visited_sites =
869 new MostVisitedSites(ProfileAndroid::FromProfileAndroid(jprofile)); 896 new MostVisitedSites(ProfileAndroid::FromProfileAndroid(jprofile));
870 return reinterpret_cast<intptr_t>(most_visited_sites); 897 return reinterpret_cast<intptr_t>(most_visited_sites);
871 } 898 }
OLDNEW
« chrome/browser/android/most_visited_sites.h ('K') | « 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