OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ntp/content_suggestions_notifier_service.h" | 5 #include "chrome/browser/android/ntp/content_suggestions_notifier_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/android/application_status_listener.h" | 9 #include "base/android/application_status_listener.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 sent = 0; // Reset on day change. | 97 sent = 0; // Reset on day change. |
98 } | 98 } |
99 prefs->SetInteger(prefs::kContentSuggestionsNotificationsSentCount, sent + 1); | 99 prefs->SetInteger(prefs::kContentSuggestionsNotificationsSentCount, sent + 1); |
100 } | 100 } |
101 | 101 |
102 } // namespace | 102 } // namespace |
103 | 103 |
104 class ContentSuggestionsNotifierService::NotifyingObserver | 104 class ContentSuggestionsNotifierService::NotifyingObserver |
105 : public ContentSuggestionsService::Observer { | 105 : public ContentSuggestionsService::Observer { |
106 public: | 106 public: |
107 NotifyingObserver(ContentSuggestionsService* service, | 107 NotifyingObserver(ContentSuggestionsService* service, Profile* profile) |
108 Profile* profile) | |
109 : service_(service), | 108 : service_(service), |
110 profile_(profile), | 109 profile_(profile), |
111 app_status_listener_(base::Bind(&NotifyingObserver::AppStatusChanged, | 110 app_status_listener_(base::Bind(&NotifyingObserver::AppStatusChanged, |
112 base::Unretained(this))), | 111 base::Unretained(this))), |
113 weak_ptr_factory_(this) {} | 112 weak_ptr_factory_(this) {} |
114 | 113 |
115 void OnNewSuggestions(Category category) override { | 114 void OnNewSuggestions(Category category) override { |
116 if (!ShouldNotifyInState(app_status_listener_.GetState())) { | 115 if (!ShouldNotifyInState(app_status_listener_.GetState())) { |
117 DVLOG(1) << "Suppressed notification because Chrome is frontmost"; | 116 DVLOG(1) << "Suppressed notification because Chrome is frontmost"; |
118 return; | 117 return; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 registry->RegisterIntegerPref( | 245 registry->RegisterIntegerPref( |
247 prefs::kContentSuggestionsConsecutiveIgnoredPrefName, 0); | 246 prefs::kContentSuggestionsConsecutiveIgnoredPrefName, 0); |
248 registry->RegisterIntegerPref(prefs::kContentSuggestionsNotificationsSentDay, | 247 registry->RegisterIntegerPref(prefs::kContentSuggestionsNotificationsSentDay, |
249 0); | 248 0); |
250 registry->RegisterIntegerPref( | 249 registry->RegisterIntegerPref( |
251 prefs::kContentSuggestionsNotificationsSentCount, 0); | 250 prefs::kContentSuggestionsNotificationsSentCount, 0); |
252 | 251 |
253 // TODO(sfiera): remove after M62; no longer (and never really) used. | 252 // TODO(sfiera): remove after M62; no longer (and never really) used. |
254 registry->RegisterStringPref(kNotificationIDWithinCategory, std::string()); | 253 registry->RegisterStringPref(kNotificationIDWithinCategory, std::string()); |
255 } | 254 } |
OLD | NEW |