OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/prefs/pref_metrics_service.h" | 5 #include "chrome/browser/prefs/pref_metrics_service.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "chrome/browser/prefs/session_startup_pref.h" | 9 #include "chrome/browser/prefs/session_startup_pref.h" |
10 #include "chrome/browser/profiles/incognito_helpers.h" | 10 #include "chrome/browser/profiles/incognito_helpers.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
13 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" | 13 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
14 | 14 |
15 PrefMetricsService::PrefMetricsService(Profile* profile) | 15 PrefMetricsService::PrefMetricsService(Profile* profile) |
16 : profile_(profile) { | 16 : profile_(profile) { |
17 RecordLaunchPrefs(); | 17 RecordLaunchPrefs(); |
18 } | 18 } |
19 | 19 |
20 PrefMetricsService::~PrefMetricsService() { | 20 PrefMetricsService::~PrefMetricsService() { |
21 } | 21 } |
22 | 22 |
23 void PrefMetricsService::RecordLaunchPrefs() { | 23 void PrefMetricsService::RecordLaunchPrefs() { |
24 UMA_HISTOGRAM_BOOLEAN("Settings.ShowHomeButton", | 24 PrefService* prefs = profile_->GetPrefs(); |
25 profile_->GetPrefs()->GetBoolean(prefs::kShowHomeButton)); | 25 bool show_home_button = prefs->GetBoolean(prefs::kShowHomeButton); |
26 UMA_HISTOGRAM_BOOLEAN("Settings.HomePageIsNewTabPage", | 26 bool home_page_is_ntp = prefs->GetBoolean(prefs::kHomePageIsNewTabPage); |
27 profile_->GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage)); | 27 UMA_HISTOGRAM_BOOLEAN("Settings.ShowHomeButton", show_home_button); |
28 | 28 if (show_home_button) { |
29 int restore_on_startup = profile_->GetPrefs()->GetInteger( | 29 UMA_HISTOGRAM_BOOLEAN("Settings.GivenShowHomeButton_HomePageIsNewTabPage", |
30 prefs::kRestoreOnStartup); | 30 home_page_is_ntp); |
| 31 } |
| 32 int restore_on_startup = prefs->GetInteger(prefs::kRestoreOnStartup); |
31 UMA_HISTOGRAM_ENUMERATION("Settings.StartupPageLoadSettings", | 33 UMA_HISTOGRAM_ENUMERATION("Settings.StartupPageLoadSettings", |
32 restore_on_startup, SessionStartupPref::kPrefValueMax); | 34 restore_on_startup, SessionStartupPref::kPrefValueMax); |
33 if (restore_on_startup == SessionStartupPref::kPrefValueURLs) { | 35 if (restore_on_startup == SessionStartupPref::kPrefValueURLs) { |
34 const int url_list_size = profile_->GetPrefs()->GetList( | 36 const int url_list_size = prefs->GetList( |
35 prefs::kURLsToRestoreOnStartup)->GetSize(); | 37 prefs::kURLsToRestoreOnStartup)->GetSize(); |
36 UMA_HISTOGRAM_CUSTOM_COUNTS( | 38 UMA_HISTOGRAM_CUSTOM_COUNTS( |
37 "Settings.StartupPageLoadURLs", url_list_size, 1, 50, 20); | 39 "Settings.StartupPageLoadURLs", url_list_size, 1, 50, 20); |
38 } | 40 } |
39 } | 41 } |
40 | 42 |
41 // static | 43 // static |
42 PrefMetricsService::Factory* PrefMetricsService::Factory::GetInstance() { | 44 PrefMetricsService::Factory* PrefMetricsService::Factory::GetInstance() { |
43 return Singleton<PrefMetricsService::Factory>::get(); | 45 return Singleton<PrefMetricsService::Factory>::get(); |
44 } | 46 } |
(...skipping 25 matching lines...) Expand all Loading... |
70 } | 72 } |
71 | 73 |
72 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const { | 74 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const { |
73 return false; | 75 return false; |
74 } | 76 } |
75 | 77 |
76 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse( | 78 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse( |
77 content::BrowserContext* context) const { | 79 content::BrowserContext* context) const { |
78 return chrome::GetBrowserContextRedirectedInIncognito(context); | 80 return chrome::GetBrowserContextRedirectedInIncognito(context); |
79 } | 81 } |
OLD | NEW |