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

Unified Diff: chrome/browser/prefs/pref_metrics_service.cc

Issue 19776015: Add UMA stat to track home button and page prefs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix histograms.xml formatting Created 7 years, 5 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
Index: chrome/browser/prefs/pref_metrics_service.cc
diff --git a/chrome/browser/prefs/pref_metrics_service.cc b/chrome/browser/prefs/pref_metrics_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1b2a18a595959aa02e5ced005bec0a690e7e2251
--- /dev/null
+++ b/chrome/browser/prefs/pref_metrics_service.cc
@@ -0,0 +1,67 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/prefs/pref_metrics_service.h"
+
+#include "base/metrics/histogram.h"
+#include "base/prefs/pref_service.h"
+#include "chrome/browser/profiles/incognito_helpers.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/pref_names.h"
+#include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
+
+PrefMetricsService::PrefMetricsService(Profile* profile)
+ : profile_(profile) {
+ RecordLaunchPrefs();
+}
+
+PrefMetricsService::~PrefMetricsService() {
+}
+
+void PrefMetricsService::RecordLaunchPrefs() {
+ UMA_HISTOGRAM_BOOLEAN("HomePage.IsHomeButtonEnabled",
+ profile_->GetPrefs()->GetBoolean(prefs::kShowHomeButton));
+ UMA_HISTOGRAM_BOOLEAN("HomePage.IsNewTabPage",
+ profile_->GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage));
+}
+
+// static
+PrefMetricsService::Factory* PrefMetricsService::Factory::GetInstance() {
+ return Singleton<PrefMetricsService::Factory>::get();
+}
+
+// static
+PrefMetricsService* PrefMetricsService::Factory::GetForProfile(
+ Profile* profile) {
+ return static_cast<PrefMetricsService*>(
+ GetInstance()->GetServiceForBrowserContext(profile, true));
+}
+
+PrefMetricsService::Factory::Factory()
+ : BrowserContextKeyedServiceFactory(
+ "PrefMetricsService",
+ BrowserContextDependencyManager::GetInstance()) {
+}
+
+PrefMetricsService::Factory::~Factory() {
+}
+
+BrowserContextKeyedService*
+PrefMetricsService::Factory::BuildServiceInstanceFor(
+ content::BrowserContext* profile) const {
+ return new PrefMetricsService(static_cast<Profile*>(profile));
+}
+
+bool PrefMetricsService::Factory::ServiceIsCreatedWithBrowserContext() const {
+ return true;
+}
+
+bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const {
+ return false;
+}
+
+content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse(
+ content::BrowserContext* context) const {
+ return chrome::GetBrowserContextRedirectedInIncognito(context);
+}

Powered by Google App Engine
This is Rietveld 408576698