OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/prefs/pref_metrics_service.h" |
| 6 |
| 7 #include "base/metrics/histogram.h" |
| 8 #include "base/prefs/pref_service.h" |
| 9 #include "chrome/browser/profiles/incognito_helpers.h" |
| 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/common/pref_names.h" |
| 12 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
| 13 |
| 14 PrefMetricsService::PrefMetricsService(Profile* profile) |
| 15 : profile_(profile) { |
| 16 RecordLaunchPrefs(); |
| 17 } |
| 18 |
| 19 PrefMetricsService::~PrefMetricsService() { |
| 20 } |
| 21 |
| 22 void PrefMetricsService::RecordLaunchPrefs() { |
| 23 UMA_HISTOGRAM_BOOLEAN("Settings.ShowHomeButton", |
| 24 profile_->GetPrefs()->GetBoolean(prefs::kShowHomeButton)); |
| 25 UMA_HISTOGRAM_BOOLEAN("Settings.HomePageIsNewTabPage", |
| 26 profile_->GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage)); |
| 27 } |
| 28 |
| 29 // static |
| 30 PrefMetricsService::Factory* PrefMetricsService::Factory::GetInstance() { |
| 31 return Singleton<PrefMetricsService::Factory>::get(); |
| 32 } |
| 33 |
| 34 // static |
| 35 PrefMetricsService* PrefMetricsService::Factory::GetForProfile( |
| 36 Profile* profile) { |
| 37 return static_cast<PrefMetricsService*>( |
| 38 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 39 } |
| 40 |
| 41 PrefMetricsService::Factory::Factory() |
| 42 : BrowserContextKeyedServiceFactory( |
| 43 "PrefMetricsService", |
| 44 BrowserContextDependencyManager::GetInstance()) { |
| 45 } |
| 46 |
| 47 PrefMetricsService::Factory::~Factory() { |
| 48 } |
| 49 |
| 50 BrowserContextKeyedService* |
| 51 PrefMetricsService::Factory::BuildServiceInstanceFor( |
| 52 content::BrowserContext* profile) const { |
| 53 return new PrefMetricsService(static_cast<Profile*>(profile)); |
| 54 } |
| 55 |
| 56 bool PrefMetricsService::Factory::ServiceIsCreatedWithBrowserContext() const { |
| 57 return true; |
| 58 } |
| 59 |
| 60 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const { |
| 61 return false; |
| 62 } |
| 63 |
| 64 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse( |
| 65 content::BrowserContext* context) const { |
| 66 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 67 } |
OLD | NEW |