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

Unified Diff: chrome/browser/android/ntp/most_visited_sites_bridge.cc

Issue 1954973004: Remove MostVisitedSites => SupervisedUserService dep. (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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/ntp/most_visited_sites_bridge.cc
diff --git a/chrome/browser/android/ntp/most_visited_sites_bridge.cc b/chrome/browser/android/ntp/most_visited_sites_bridge.cc
index b606586073708ef5dba7298e42882f8918b9e1ab..425be0233e9ce28efd28d4b075edd4a541c6723c 100644
--- a/chrome/browser/android/ntp/most_visited_sites_bridge.cc
+++ b/chrome/browser/android/ntp/most_visited_sites_bridge.cc
@@ -19,6 +19,9 @@
#include "chrome/browser/profiles/profile_android.h"
#include "chrome/browser/search/suggestions/suggestions_service_factory.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_url_filter.h"
#include "chrome/browser/thumbnails/thumbnail_list_source.h"
#include "components/history/core/browser/top_sites.h"
#include "content/public/browser/url_data_source.h"
@@ -49,6 +52,56 @@ void CallJavaWithBitmap(
} // namespace
+MostVisitedSitesBridge::SupervisorBridge::SupervisorBridge(Profile* profile)
+ : profile_(profile),
+ register_observer_(this) {
+ register_observer_.Add(
+ SupervisedUserServiceFactory::GetForProfile(profile_));
+}
+
+void
+MostVisitedSitesBridge::SupervisorBridge::SetObserver(Observer* new_observer) {
Marc Treib 2016/05/09 08:22:48 Can this method move into MostVisitedSitesSupervis
sfiera 2016/05/09 09:33:35 A rough check of Chromium code suggests that of Ad
Marc Treib 2016/05/09 09:55:12 Okay, fair enough. My rationale was that the metho
sfiera 2016/05/09 10:26:17 If I were to go further, I think that really The C
+ if (new_observer) {
+ DCHECK(!observer_);
+ } else {
+ DCHECK(observer_);
+ }
+ observer_ = new_observer;
+}
+
+bool MostVisitedSitesBridge::SupervisorBridge::IsBlocked(const GURL& url) {
+ SupervisedUserService* supervised_user_service =
+ SupervisedUserServiceFactory::GetForProfile(profile_);
Marc Treib 2016/05/09 08:22:48 wrong indent
sfiera 2016/05/09 09:33:35 Done.
+ auto url_filter = supervised_user_service->GetURLFilterForUIThread();
+ return url_filter->GetFilteringBehaviorForURL(url) ==
+ SupervisedUserURLFilter::FilteringBehavior::BLOCK;
Marc Treib 2016/05/09 08:22:48 here too
sfiera 2016/05/09 09:33:35 Done.
+}
+
+std::vector<MostVisitedSitesSupervisor::Whitelist>
+MostVisitedSitesBridge::SupervisorBridge::whitelists() {
+ std::vector<MostVisitedSitesSupervisor::Whitelist> results;
+ SupervisedUserService* supervised_user_service =
+ SupervisedUserServiceFactory::GetForProfile(profile_);
Marc Treib 2016/05/09 08:22:48 and here
sfiera 2016/05/09 09:33:35 Done.
+ for (const auto& whitelist : supervised_user_service->whitelists()) {
+ results.emplace_back(Whitelist{
Marc Treib 2016/05/09 08:22:48 I think when called like this, emplace_back will d
sfiera 2016/05/09 09:33:35 I tried without the explicit ctor, and you're righ
Marc Treib 2016/05/09 09:55:12 Eh, it's fine. I guess I'd slightly prefer push_ba
+ whitelist->title(),
+ whitelist->entry_point(),
+ whitelist->large_icon_path(),
+ });
+ }
+ return results;
+}
+
+bool MostVisitedSitesBridge::SupervisorBridge::IsChildProfile() {
+ return profile_->IsChild();
+}
+
+void MostVisitedSitesBridge::SupervisorBridge::OnURLFilterChanged() {
+ if (observer_) {
Marc Treib 2016/05/09 08:22:48 nit: no braces
sfiera 2016/05/09 09:33:35 (OK, these were mine)
+ observer_->OnBlockedSitesChanged();
+ }
+}
+
class MostVisitedSitesBridge::Observer
: public MostVisitedSites::Observer {
public:
@@ -108,14 +161,14 @@ void MostVisitedSitesBridge::Observer::OnPopularURLsAvailable(
}
MostVisitedSitesBridge::MostVisitedSitesBridge(Profile* profile)
- : most_visited_(profile->GetPrefs(),
+ : supervisor_(profile),
+ most_visited_(profile->GetPrefs(),
TemplateURLServiceFactory::GetForProfile(profile),
g_browser_process->variations_service(),
profile->GetRequestContext(),
TopSitesFactory::GetForProfile(profile),
SuggestionsServiceFactory::GetForProfile(profile),
- profile->IsChild(),
- profile) {
+ &supervisor_) {
// Register the thumbnails debugging page.
// TODO(sfiera): find thumbnails a home. They don't belong here.
content::URLDataSource::Add(profile, new ThumbnailListSource(profile));

Powered by Google App Engine
This is Rietveld 408576698