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

Unified Diff: components/ntp_snippets/content_suggestions_service.h

Issue 2519053002: 📰 Let the backend trigger sign in related refreshes (Closed)
Patch Set: Created 4 years, 1 month 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: components/ntp_snippets/content_suggestions_service.h
diff --git a/components/ntp_snippets/content_suggestions_service.h b/components/ntp_snippets/content_suggestions_service.h
index 9559dccb25e13296cbb51ee8b759f8aae61fd720..c5fd6760b25793628b5076abcf91322500569b32 100644
--- a/components/ntp_snippets/content_suggestions_service.h
+++ b/components/ntp_snippets/content_suggestions_service.h
@@ -24,6 +24,7 @@
#include "components/ntp_snippets/category_status.h"
#include "components/ntp_snippets/content_suggestions_provider.h"
#include "components/ntp_snippets/user_classifier.h"
+#include "components/signin/core/browser/signin_manager.h"
class PrefService;
class PrefRegistrySimple;
@@ -36,6 +37,7 @@ class RemoteSuggestionsProvider;
// them grouped into categories. There can be at most one provider per category.
class ContentSuggestionsService : public KeyedService,
public ContentSuggestionsProvider::Observer,
+ public SigninManagerBase::Observer,
public history::HistoryServiceObserver {
public:
class Observer {
@@ -64,6 +66,12 @@ class ContentSuggestionsService : public KeyedService,
virtual void OnSuggestionInvalidated(
const ContentSuggestion::ID& suggestion_id) = 0;
+ // Fired when the previously sent data is not valid anymore and a refresh
+ // of all the suggestions is required. Called for example when the sign in
+ // state changes and that personalised suggestions have to be shown or
Marc Treib 2016/11/21 15:48:53 Remove "that"?
dgn 2016/11/21 16:22:08 Done.
+ // discarded.
+ virtual void OnFullRefreshRequired() = 0;
+
// Sent when the service is shutting down. After the service has shut down,
// it will not provide any data anymore, though calling the getters is still
// safe.
@@ -79,6 +87,7 @@ class ContentSuggestionsService : public KeyedService,
};
ContentSuggestionsService(State state,
+ SigninManagerBase* signin_manager,
history::HistoryService* history_service,
PrefService* pref_service);
~ContentSuggestionsService() override;
@@ -211,6 +220,13 @@ class ContentSuggestionsService : public KeyedService,
ContentSuggestionsProvider* provider,
const ContentSuggestion::ID& suggestion_id) override;
+ // SigninManagerBase::Observer implementation
+ void GoogleSigninSucceeded(const std::string& account_id,
+ const std::string& username,
+ const std::string& password) override;
+ void GoogleSignedOut(const std::string& account_id,
+ const std::string& username) override;
+
// history::HistoryServiceObserver implementation.
void OnURLsDeleted(history::HistoryService* history_service,
bool all_history,
@@ -237,6 +253,8 @@ class ContentSuggestionsService : public KeyedService,
// Fires the OnCategoryStatusChanged event for the given |category|.
void NotifyCategoryStatusChanged(Category category);
+ void OnSignInStateChanged();
+
void SortCategories();
// Re-enables a dismissed category, making querying its provider possible.
@@ -280,6 +298,11 @@ class ContentSuggestionsService : public KeyedService,
std::map<Category, std::vector<ContentSuggestion>, Category::CompareByID>
suggestions_by_category_;
+ // Observer for the SigninManager. All observers are notified when the signin
+ // state changes so that they can refresh their list of suggestions.
+ ScopedObserver<SigninManagerBase, SigninManagerBase::Observer>
+ signin_observer_;
+
// Observer for the HistoryService. All providers are notified when history is
// deleted.
ScopedObserver<history::HistoryService, history::HistoryServiceObserver>

Powered by Google App Engine
This is Rietveld 408576698