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

Side by Side Diff: chrome/browser/android/ntp/content_suggestions_notifier_service.cc

Issue 2790183002: Add UMA for the content suggestions settings (Closed)
Patch Set: Rewrite metrics and add histograms changes Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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"
11 #include "base/metrics/histogram_macros.h"
11 #include "chrome/browser/android/ntp/content_suggestions_notification_helper.h" 12 #include "chrome/browser/android/ntp/content_suggestions_notification_helper.h"
12 #include "chrome/browser/notifications/notification.h" 13 #include "chrome/browser/notifications/notification.h"
13 #include "chrome/browser/notifications/notification_handler.h" 14 #include "chrome/browser/notifications/notification_handler.h"
14 #include "chrome/browser/ntp_snippets/ntp_snippets_features.h" 15 #include "chrome/browser/ntp_snippets/ntp_snippets_features.h"
15 #include "chrome/browser/ntp_snippets/ntp_snippets_metrics.h" 16 #include "chrome/browser/ntp_snippets/ntp_snippets_metrics.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
18 #include "components/ntp_snippets/content_suggestions_service.h" 19 #include "components/ntp_snippets/content_suggestions_service.h"
19 #include "components/pref_registry/pref_registry_syncable.h" 20 #include "components/pref_registry/pref_registry_syncable.h"
20 #include "components/prefs/pref_service.h" 21 #include "components/prefs/pref_service.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 229
229 DISALLOW_COPY_AND_ASSIGN(NotifyingObserver); 230 DISALLOW_COPY_AND_ASSIGN(NotifyingObserver);
230 }; 231 };
231 232
232 ContentSuggestionsNotifierService::ContentSuggestionsNotifierService( 233 ContentSuggestionsNotifierService::ContentSuggestionsNotifierService(
233 Profile* profile, 234 Profile* profile,
234 ContentSuggestionsService* suggestions) 235 ContentSuggestionsService* suggestions)
235 : profile_(profile), suggestions_service_(suggestions) { 236 : profile_(profile), suggestions_service_(suggestions) {
236 ContentSuggestionsNotificationHelper::FlushCachedMetrics(); 237 ContentSuggestionsNotificationHelper::FlushCachedMetrics();
237 UpdateObserverRegistrationState(); 238 UpdateObserverRegistrationState();
239
240 UMA_HISTOGRAM_BOOLEAN("ContentSuggestions.Preferences.Notifications",
241 IsEnabled());
238 } 242 }
239 243
240 ContentSuggestionsNotifierService::~ContentSuggestionsNotifierService() = 244 ContentSuggestionsNotifierService::~ContentSuggestionsNotifierService() =
241 default; 245 default;
242 246
243 void ContentSuggestionsNotifierService::RegisterProfilePrefs( 247 void ContentSuggestionsNotifierService::RegisterProfilePrefs(
244 user_prefs::PrefRegistrySyncable* registry) { 248 user_prefs::PrefRegistrySyncable* registry) {
245 registry->RegisterBooleanPref(prefs::kContentSuggestionsNotificationsEnabled, 249 registry->RegisterBooleanPref(prefs::kContentSuggestionsNotificationsEnabled,
246 true); 250 true);
247 registry->RegisterIntegerPref( 251 registry->RegisterIntegerPref(
(...skipping 20 matching lines...) Expand all
268 272
269 void ContentSuggestionsNotifierService::UpdateObserverRegistrationState() { 273 void ContentSuggestionsNotifierService::UpdateObserverRegistrationState() {
270 if (observer_ && !IsEnabled()) { 274 if (observer_ && !IsEnabled()) {
271 suggestions_service_->RemoveObserver(observer_.get()); 275 suggestions_service_->RemoveObserver(observer_.get());
272 observer_.reset(); 276 observer_.reset();
273 } else if (IsEnabled() && !observer_) { 277 } else if (IsEnabled() && !observer_) {
274 observer_.reset(new NotifyingObserver(suggestions_service_, profile_)); 278 observer_.reset(new NotifyingObserver(suggestions_service_, profile_));
275 suggestions_service_->AddObserver(observer_.get()); 279 suggestions_service_->AddObserver(observer_.get());
276 } 280 }
277 } 281 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698