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

Side by Side Diff: chrome/browser/prefs/pref_metrics_service.cc

Issue 20582004: Add histogram for pages to open enum on session restore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/profiles/incognito_helpers.h" 10 #include "chrome/browser/profiles/incognito_helpers.h"
10 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/common/pref_names.h" 12 #include "chrome/common/pref_names.h"
12 #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"
13 14
14 PrefMetricsService::PrefMetricsService(Profile* profile) 15 PrefMetricsService::PrefMetricsService(Profile* profile)
15 : profile_(profile) { 16 : profile_(profile) {
16 RecordLaunchPrefs(); 17 RecordLaunchPrefs();
17 } 18 }
18 19
19 PrefMetricsService::~PrefMetricsService() { 20 PrefMetricsService::~PrefMetricsService() {
20 } 21 }
21 22
23 class StartupPagePref {
bbudge 2013/07/27 10:49:06 Why not just declare an enum named StartupPagePref
meacer 2013/07/30 00:37:55 Done.
24 public:
25 enum Type {
26 NONE = 0,
27 HOMEPAGE = 1,
28 NEWTAB = 2,
29 LAST = 3,
30 NO_URL = 4,
bbudge 2013/07/27 10:49:06 ZERO_URLS ?
meacer 2013/07/30 00:37:55 Done.
31 ONE_URL = 5,
32 MULTIPLE_URLS = 6,
33 TYPE_COUNT = 7
34 };
35 };
36
37 StartupPagePref::Type GetStartupPagePref(Profile* profile) {
38 int restore_on_startup =
39 profile->GetPrefs()->GetInteger(prefs::kRestoreOnStartup);
40 int url_list_size = 0;
41 switch (restore_on_startup) {
42 case SessionStartupPref::kPrefValueHomePage:
43 return StartupPagePref::HOMEPAGE;
44 case SessionStartupPref::kPrefValueLast:
45 return StartupPagePref::LAST;
46 case SessionStartupPref::kPrefValueNewTab:
47 return StartupPagePref::NEWTAB;
48 case SessionStartupPref::kPrefValueURLs:
49 url_list_size = profile->GetPrefs()->GetList(
50 prefs::kURLsToRestoreOnStartup)->GetSize();
51 if (url_list_size == 0) {
52 return StartupPagePref::NO_URL;
53 } else if (url_list_size == 1) {
54 return StartupPagePref::ONE_URL;
55 } else {
56 return StartupPagePref::MULTIPLE_URLS;
57 }
58 default:
59 return StartupPagePref::NONE;
60 }
61 }
62
22 void PrefMetricsService::RecordLaunchPrefs() { 63 void PrefMetricsService::RecordLaunchPrefs() {
23 UMA_HISTOGRAM_BOOLEAN("Settings.ShowHomeButton", 64 UMA_HISTOGRAM_BOOLEAN("Settings.ShowHomeButton",
24 profile_->GetPrefs()->GetBoolean(prefs::kShowHomeButton)); 65 profile_->GetPrefs()->GetBoolean(prefs::kShowHomeButton));
25 UMA_HISTOGRAM_BOOLEAN("Settings.HomePageIsNewTabPage", 66 UMA_HISTOGRAM_BOOLEAN("Settings.HomePageIsNewTabPage",
26 profile_->GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage)); 67 profile_->GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage));
68 UMA_HISTOGRAM_ENUMERATION("Settings.SessionRestoreOnStartup",
69 GetStartupPagePref(profile_), StartupPagePref::TYPE_COUNT);
27 } 70 }
28 71
29 // static 72 // static
30 PrefMetricsService::Factory* PrefMetricsService::Factory::GetInstance() { 73 PrefMetricsService::Factory* PrefMetricsService::Factory::GetInstance() {
31 return Singleton<PrefMetricsService::Factory>::get(); 74 return Singleton<PrefMetricsService::Factory>::get();
32 } 75 }
33 76
34 // static 77 // static
35 PrefMetricsService* PrefMetricsService::Factory::GetForProfile( 78 PrefMetricsService* PrefMetricsService::Factory::GetForProfile(
36 Profile* profile) { 79 Profile* profile) {
(...skipping 21 matching lines...) Expand all
58 } 101 }
59 102
60 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const { 103 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const {
61 return false; 104 return false;
62 } 105 }
63 106
64 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse( 107 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse(
65 content::BrowserContext* context) const { 108 content::BrowserContext* context) const {
66 return chrome::GetBrowserContextRedirectedInIncognito(context); 109 return chrome::GetBrowserContextRedirectedInIncognito(context);
67 } 110 }
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698