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

Unified Diff: components/ntp_snippets/remote/ntp_snippets_status_service.cc

Issue 2378323002: 📰 Show the Sign In promo as a separate card from the section (Closed)
Patch Set: fix compilation Created 4 years, 2 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 | « components/ntp_snippets/remote/ntp_snippets_status_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_snippets/remote/ntp_snippets_status_service.cc
diff --git a/components/ntp_snippets/remote/ntp_snippets_status_service.cc b/components/ntp_snippets/remote/ntp_snippets_status_service.cc
index a15bfdfec1dfacdfb12e7ebef4b7c7b1ac75f679..0e2b3c06b2eb2887c52701eb1878eedea8160104 100644
--- a/components/ntp_snippets/remote/ntp_snippets_status_service.cc
+++ b/components/ntp_snippets/remote/ntp_snippets_status_service.cc
@@ -65,13 +65,16 @@ void NTPSnippetsStatusService::Init(
pref_change_registrar_.Init(pref_service_);
pref_change_registrar_.Add(
prefs::kEnableSnippets,
- base::Bind(&NTPSnippetsStatusService::OnStateChanged,
+ base::Bind(&NTPSnippetsStatusService::OnSnippetsEnabledChanged,
base::Unretained(this)));
}
-void NTPSnippetsStatusService::OnStateChanged() {
- DisabledReason new_disabled_reason = GetDisabledReasonFromDeps();
+void NTPSnippetsStatusService::OnSnippetsEnabledChanged() {
+ OnStateChanged(GetDisabledReasonFromDeps());
+}
+void NTPSnippetsStatusService::OnStateChanged(
+ DisabledReason new_disabled_reason) {
if (new_disabled_reason == disabled_reason_)
return;
@@ -83,17 +86,20 @@ void NTPSnippetsStatusService::GoogleSigninSucceeded(
const std::string& account_id,
const std::string& username,
const std::string& password) {
- OnStateChanged();
+ // TODO(dgn): The snippets should be refetched: https://crbug.com/650666
+ OnStateChanged(GetDisabledReasonFromDeps());
}
void NTPSnippetsStatusService::GoogleSignedOut(const std::string& account_id,
const std::string& username) {
if (!require_signin_ && disabled_reason_ == DisabledReason::NONE) {
// Temporary enter |SIGNED_OUT| state to clear all personalised suggestions.
- disabled_reason_change_callback_.Run(DisabledReason::SIGNED_OUT);
- disabled_reason_change_callback_.Run(disabled_reason_);
+ OnStateChanged(DisabledReason::SIGNED_OUT);
}
- OnStateChanged();
+
+ // Depending on |require_signin_|, will still report as SIGNED_OUT or switch
+ // back to |DisabledReason::NONE|
+ OnStateChanged(GetDisabledReasonFromDeps());
}
DisabledReason NTPSnippetsStatusService::GetDisabledReasonFromDeps() const {
« no previous file with comments | « components/ntp_snippets/remote/ntp_snippets_status_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698