| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 sent = 0; // Reset on day change. | 98 sent = 0; // Reset on day change. |
| 99 } | 99 } |
| 100 prefs->SetInteger(prefs::kContentSuggestionsNotificationsSentCount, sent + 1); | 100 prefs->SetInteger(prefs::kContentSuggestionsNotificationsSentCount, sent + 1); |
| 101 } | 101 } |
| 102 | 102 |
| 103 } // namespace | 103 } // namespace |
| 104 | 104 |
| 105 class ContentSuggestionsNotifierService::NotifyingObserver | 105 class ContentSuggestionsNotifierService::NotifyingObserver |
| 106 : public ContentSuggestionsService::Observer { | 106 : public ContentSuggestionsService::Observer { |
| 107 public: | 107 public: |
| 108 NotifyingObserver(ContentSuggestionsService* service, | 108 NotifyingObserver(ContentSuggestionsService* service, Profile* profile) |
| 109 Profile* profile) | |
| 110 : service_(service), | 109 : service_(service), |
| 111 profile_(profile), | 110 profile_(profile), |
| 112 app_status_listener_(base::Bind(&NotifyingObserver::AppStatusChanged, | 111 app_status_listener_(base::Bind(&NotifyingObserver::AppStatusChanged, |
| 113 base::Unretained(this))), | 112 base::Unretained(this))), |
| 114 weak_ptr_factory_(this) {} | 113 weak_ptr_factory_(this) {} |
| 115 | 114 |
| 116 void OnNewSuggestions(Category category) override { | 115 void OnNewSuggestions(Category category) override { |
| 117 if (!ShouldNotifyInState(app_status_listener_.GetState())) { | 116 if (!ShouldNotifyInState(app_status_listener_.GetState())) { |
| 118 DVLOG(1) << "Suppressed notification because Chrome is frontmost"; | 117 DVLOG(1) << "Suppressed notification because Chrome is frontmost"; |
| 119 return; | 118 return; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 registry->RegisterIntegerPref( | 256 registry->RegisterIntegerPref( |
| 258 prefs::kContentSuggestionsConsecutiveIgnoredPrefName, 0); | 257 prefs::kContentSuggestionsConsecutiveIgnoredPrefName, 0); |
| 259 registry->RegisterIntegerPref(prefs::kContentSuggestionsNotificationsSentDay, | 258 registry->RegisterIntegerPref(prefs::kContentSuggestionsNotificationsSentDay, |
| 260 0); | 259 0); |
| 261 registry->RegisterIntegerPref( | 260 registry->RegisterIntegerPref( |
| 262 prefs::kContentSuggestionsNotificationsSentCount, 0); | 261 prefs::kContentSuggestionsNotificationsSentCount, 0); |
| 263 | 262 |
| 264 // TODO(sfiera): remove after M62; no longer (and never really) used. | 263 // TODO(sfiera): remove after M62; no longer (and never really) used. |
| 265 registry->RegisterStringPref(kNotificationIDWithinCategory, std::string()); | 264 registry->RegisterStringPref(kNotificationIDWithinCategory, std::string()); |
| 266 } | 265 } |
| OLD | NEW |