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

Unified Diff: chrome/browser/android/ntp/most_visited_sites.h

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
« no previous file with comments | « no previous file | chrome/browser/android/ntp/most_visited_sites.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/ntp/most_visited_sites.h
diff --git a/chrome/browser/android/ntp/most_visited_sites.h b/chrome/browser/android/ntp/most_visited_sites.h
index 27f7250893e7aec126a2c76e5ecb9d10a7228894..ad3c3398862187b01cebbd69b5017d907a2fe7cc 100644
--- a/chrome/browser/android/ntp/most_visited_sites.h
+++ b/chrome/browser/android/ntp/most_visited_sites.h
@@ -41,6 +41,63 @@ namespace variations {
class VariationsService;
}
+class Supervisor {
+ public:
+ struct Whitelist {
+ base::string16 title;
+ GURL entry_point;
+ base::FilePath large_icon_path;
+ };
+
+ class Observer {
+ public:
+ virtual void OnURLFilterChanged() {}
+
+ protected:
+ ~Observer() {}
+ };
+
+ virtual void AddObserver(Observer* observer) = 0;
+ virtual void RemoveObserver(Observer* observer) = 0;
Marc Treib 2016/05/06 13:24:11 There'll only ever be one observer, namely the Mos
sfiera 2016/05/06 15:48:35 Done.
+ virtual SupervisedUserURLFilter* GetURLFilterForUIThread() = 0;
Marc Treib 2016/05/06 13:24:11 Like this, you still have a dependency on Supervis
sfiera 2016/05/06 15:48:35 Done.
+ virtual std::vector<Whitelist> whitelists() const = 0;
+
+ protected:
+ virtual ~Supervisor() {}
+};
+
+class SupervisedUserServiceSupervisor : public Supervisor {
+ public:
+ SupervisedUserServiceSupervisor(Profile* profile);
+
+ void AddObserver(Observer* observer) override;
+ void RemoveObserver(Observer* observer) override;
+ SupervisedUserURLFilter* GetURLFilterForUIThread() override;
+ std::vector<Supervisor::Whitelist> whitelists() const override;
+
+ private:
+ struct SUSObserver : public SupervisedUserServiceObserver {
+ public:
+ SUSObserver(SupervisedUserService* service, Supervisor::Observer* observer)
+ : observer_(observer),
+ scope_(this) {
+ scope_.Add(service);
+ }
+
+ void OnURLFilterChanged() override {
+ observer_->OnURLFilterChanged();
+ }
+
+ private:
+ Supervisor::Observer* observer_;
+ ScopedObserver<SupervisedUserService, SupervisedUserServiceObserver> scope_;
+ };
+
+ Profile* const profile_;
+ std::map<Supervisor::Observer*, std::unique_ptr<SUSObserver>>
+ observers_;
+};
+
// Tracks the list of most visited sites and their thumbnails.
//
// Do not use, except from MostVisitedSitesBridge. The interface is in flux
@@ -49,7 +106,7 @@ class VariationsService;
//
// TODO(sfiera): finalize interface.
class MostVisitedSites : public history::TopSitesObserver,
- public SupervisedUserServiceObserver {
+ public Supervisor::Observer {
public:
struct Suggestion;
using SuggestionsVector = std::vector<Suggestion>;
@@ -97,7 +154,7 @@ class MostVisitedSites : public history::TopSitesObserver,
scoped_refptr<history::TopSites> top_sites,
suggestions::SuggestionsService* suggestions,
bool is_child_profile,
- Profile* profile);
+ Supervisor* supervisor);
~MostVisitedSites() override;
@@ -222,7 +279,6 @@ class MostVisitedSites : public history::TopSitesObserver,
ChangeReason change_reason) override;
// The profile whose most visited sites will be queried.
- Profile* profile_;
PrefService* prefs_;
const TemplateURLService* template_url_service_;
@@ -230,6 +286,7 @@ class MostVisitedSites : public history::TopSitesObserver,
net::URLRequestContextGetter* download_context_;
scoped_refptr<history::TopSites> top_sites_;
suggestions::SuggestionsService* suggestions_service_;
+ Supervisor* supervisor_;
// Children will not be shown popular sites as suggestions.
// TODO(sfiera): enable/disable suggestions if the profile is marked or
« no previous file with comments | « no previous file | chrome/browser/android/ntp/most_visited_sites.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698