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

Side by Side Diff: chrome/browser/ui/webui/ntp/new_tab_page_handler.cc

Issue 8086002: Add metrics to help measure effects of installing default apps in a profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 2 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/webui/ntp/new_tab_page_handler.h" 5 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h"
6 6
7 #include "base/metrics/field_trial.h"
8 #include "base/metrics/histogram.h"
9 #include "chrome/browser/extensions/default_apps_trial.h"
7 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
8 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/sync/profile_sync_service.h" 12 #include "chrome/browser/sync/profile_sync_service.h"
10 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" 13 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
11 #include "chrome/common/chrome_notification_types.h" 14 #include "chrome/common/chrome_notification_types.h"
12 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
13 #include "content/common/notification_service.h" 16 #include "content/common/notification_service.h"
14 #include "grit/chromium_strings.h" 17 #include "grit/chromium_strings.h"
15 #include "grit/generated_resources.h" 18 #include "grit/generated_resources.h"
16 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
17 20
18 static const int kIntroDisplayMax = 10; 21 static const int kIntroDisplayMax = 10;
19 22
20 // The URL of a knowledge-base article about the new NTP. 23 // The URL of a knowledge-base article about the new NTP.
21 static const char kNTP4IntroURL[] = 24 static const char kNTP4IntroURL[] =
22 "http://www.google.com/support/chrome/bin/answer.py?answer=95451"; 25 "http://www.google.com/support/chrome/bin/answer.py?answer=95451";
23 26
27 WebUIMessageHandler* NewTabPageHandler::Attach(WebUI* web_ui) {
28 // Record an open of the NTP with its default page type.
29 PrefService* prefs = Profile::FromWebUI(web_ui)->GetPrefs();
30 int shown_page_type = prefs->GetInteger(prefs::kNTPShownPage) >>
31 PAGE_ID_OFFSET;
32 UMA_HISTOGRAM_ENUMERATION("NtpHandler.AttachShownPageType",
33 shown_page_type, 4);
34
35 static bool default_apps_trial_exists = base::FieldTrialList::TrialExists(
36 kDefaultAppsTrial_Name);
csilv 2011/09/29 18:32:04 style nit: line 36 should be indented 4 spaces. P
Roger Tawa OOO till Jul 10th 2011/09/29 19:10:59 Done.
37 if (default_apps_trial_exists) {
38 UMA_HISTOGRAM_ENUMERATION(base::FieldTrial::MakeName(
39 "NtpHandler.AttachShownPageType", kDefaultAppsTrial_Name),
40 shown_page_type, 4);
41 }
42
43 return WebUIMessageHandler::Attach(web_ui);
44 }
45
24 void NewTabPageHandler::RegisterMessages() { 46 void NewTabPageHandler::RegisterMessages() {
25 web_ui_->RegisterMessageCallback("closePromo", NewCallback( 47 web_ui()->RegisterMessageCallback("closePromo", NewCallback(
26 this, &NewTabPageHandler::HandleClosePromo)); 48 this, &NewTabPageHandler::HandleClosePromo));
27 web_ui_->RegisterMessageCallback("pageSelected", NewCallback( 49 web_ui()->RegisterMessageCallback("pageSelected", NewCallback(
28 this, &NewTabPageHandler::HandlePageSelected)); 50 this, &NewTabPageHandler::HandlePageSelected));
29 web_ui_->RegisterMessageCallback("introMessageDismissed", NewCallback( 51 web_ui()->RegisterMessageCallback("introMessageDismissed", NewCallback(
30 this, &NewTabPageHandler::HandleIntroMessageDismissed)); 52 this, &NewTabPageHandler::HandleIntroMessageDismissed));
31 web_ui_->RegisterMessageCallback("introMessageSeen", NewCallback( 53 web_ui()->RegisterMessageCallback("introMessageSeen", NewCallback(
32 this, &NewTabPageHandler::HandleIntroMessageSeen)); 54 this, &NewTabPageHandler::HandleIntroMessageSeen));
33 } 55 }
34 56
35 void NewTabPageHandler::HandleClosePromo(const ListValue* args) { 57 void NewTabPageHandler::HandleClosePromo(const ListValue* args) {
36 Profile::FromWebUI(web_ui_)->GetPrefs()->SetBoolean(prefs::kNTPPromoClosed, 58 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean(prefs::kNTPPromoClosed,
37 true); 59 true);
38 NotificationService* service = NotificationService::current(); 60 NotificationService* service = NotificationService::current();
39 service->Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED, 61 service->Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED,
40 Source<NewTabPageHandler>(this), 62 Source<NewTabPageHandler>(this),
41 NotificationService::NoDetails()); 63 NotificationService::NoDetails());
42 } 64 }
43 65
44 void NewTabPageHandler::HandlePageSelected(const ListValue* args) { 66 void NewTabPageHandler::HandlePageSelected(const ListValue* args) {
45 double page_id_double; 67 double page_id_double;
46 CHECK(args->GetDouble(0, &page_id_double)); 68 CHECK(args->GetDouble(0, &page_id_double));
47 int page_id = static_cast<int>(page_id_double); 69 int page_id = static_cast<int>(page_id_double);
48 70
49 double index_double; 71 double index_double;
50 CHECK(args->GetDouble(1, &index_double)); 72 CHECK(args->GetDouble(1, &index_double));
51 int index = static_cast<int>(index_double); 73 int index = static_cast<int>(index_double);
52 74
53 PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs(); 75 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
54 prefs->SetInteger(prefs::kNTPShownPage, page_id | index); 76 prefs->SetInteger(prefs::kNTPShownPage, page_id | index);
77
78 int shown_page_type = page_id >> PAGE_ID_OFFSET;
79 UMA_HISTOGRAM_ENUMERATION("NtpHandler.SelectedShownPageType",
80 shown_page_type, 4);
81
82 static bool default_apps_trial_exists = base::FieldTrialList::TrialExists(
83 kDefaultAppsTrial_Name);
csilv 2011/09/29 18:32:04 ditto above comment
Roger Tawa OOO till Jul 10th 2011/09/29 19:10:59 Done.
84 if (default_apps_trial_exists) {
85 UMA_HISTOGRAM_ENUMERATION(base::FieldTrial::MakeName(
86 "NtpHandler.SelectedShownPageType", kDefaultAppsTrial_Name),
87 shown_page_type, 4);
88 }
55 } 89 }
csilv 2011/09/29 18:32:04 The above block is mostly a repeat of the contents
Roger Tawa OOO till Jul 10th 2011/09/29 19:10:59 The way the UMA_HISTOGRAM_ENUMERATION macro works
56 90
57 void NewTabPageHandler::HandleIntroMessageDismissed(const ListValue* args) { 91 void NewTabPageHandler::HandleIntroMessageDismissed(const ListValue* args) {
58 PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs(); 92 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
59 prefs->SetInteger(prefs::kNTP4IntroDisplayCount, kIntroDisplayMax + 1); 93 prefs->SetInteger(prefs::kNTP4IntroDisplayCount, kIntroDisplayMax + 1);
60 } 94 }
61 95
62 void NewTabPageHandler::HandleIntroMessageSeen(const ListValue* args) { 96 void NewTabPageHandler::HandleIntroMessageSeen(const ListValue* args) {
63 PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs(); 97 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
64 int intro_displays = prefs->GetInteger(prefs::kNTP4IntroDisplayCount); 98 int intro_displays = prefs->GetInteger(prefs::kNTP4IntroDisplayCount);
65 prefs->SetInteger(prefs::kNTP4IntroDisplayCount, intro_displays + 1); 99 prefs->SetInteger(prefs::kNTP4IntroDisplayCount, intro_displays + 1);
66 } 100 }
67 101
68 // static 102 // static
69 void NewTabPageHandler::RegisterUserPrefs(PrefService* prefs) { 103 void NewTabPageHandler::RegisterUserPrefs(PrefService* prefs) {
70 // TODO(estade): should be syncable. 104 // TODO(estade): should be syncable.
71 prefs->RegisterIntegerPref(prefs::kNTPShownPage, APPS_PAGE_ID, 105 prefs->RegisterIntegerPref(prefs::kNTPShownPage, APPS_PAGE_ID,
72 PrefService::UNSYNCABLE_PREF); 106 PrefService::UNSYNCABLE_PREF);
73 prefs->RegisterIntegerPref(prefs::kNTP4IntroDisplayCount, 0, 107 prefs->RegisterIntegerPref(prefs::kNTP4IntroDisplayCount, 0,
(...skipping 22 matching lines...) Expand all
96 values->SetString("ntp4_intro_url", kNTP4IntroURL); 130 values->SetString("ntp4_intro_url", kNTP4IntroURL);
97 values->SetString("learn_more", 131 values->SetString("learn_more",
98 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); 132 l10n_util::GetStringUTF16(IDS_LEARN_MORE));
99 } 133 }
100 } 134 }
101 135
102 // static 136 // static
103 void NewTabPageHandler::DismissIntroMessage(PrefService* prefs) { 137 void NewTabPageHandler::DismissIntroMessage(PrefService* prefs) {
104 prefs->SetInteger(prefs::kNTP4IntroDisplayCount, kIntroDisplayMax + 1); 138 prefs->SetInteger(prefs::kNTP4IntroDisplayCount, kIntroDisplayMax + 1);
105 } 139 }
OLDNEW
« chrome/browser/ui/browser.cc ('K') | « chrome/browser/ui/webui/ntp/new_tab_page_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698