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

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: Uploading merges after sync 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
« no previous file with comments | « chrome/browser/ui/webui/ntp/new_tab_page_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/metrics/field_trial.h"
10 #include "base/metrics/histogram.h"
11 #include "chrome/browser/extensions/default_apps_trial.h"
9 #include "chrome/browser/prefs/pref_service.h" 12 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/sync/profile_sync_service.h" 14 #include "chrome/browser/sync/profile_sync_service.h"
12 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" 15 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
13 #include "chrome/browser/web_resource/notification_promo.h" 16 #include "chrome/browser/web_resource/notification_promo.h"
14 #include "chrome/common/chrome_notification_types.h" 17 #include "chrome/common/chrome_notification_types.h"
15 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
16 #include "content/common/notification_service.h" 19 #include "content/common/notification_service.h"
17 #include "grit/chromium_strings.h" 20 #include "grit/chromium_strings.h"
18 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
19 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
20 23
21 static const int kIntroDisplayMax = 10; 24 namespace {
25 const int kIntroDisplayMax = 10;
26 } // anonymous
Evan Stade 2011/10/04 16:58:33 is there a difference?
Roger Tawa OOO till Jul 10th 2011/10/04 17:38:46 I believe unnamed namespaces are preferred, but I
Evan Stade 2011/10/04 17:54:35 I think it's the same thing, but for very short na
Roger Tawa OOO till Jul 10th 2011/10/04 18:15:25 Put back static.
22 27
23 // The URL of a knowledge-base article about the new NTP. 28 // The URL of a knowledge-base article about the new NTP.
24 static const char kNTP4IntroURL[] = 29 static const char kNTP4IntroURL[] =
25 "http://www.google.com/support/chrome/bin/answer.py?answer=95451"; 30 "http://www.google.com/support/chrome/bin/answer.py?answer=95451";
26 31
32 WebUIMessageHandler* NewTabPageHandler::Attach(WebUI* web_ui) {
33 // Record an open of the NTP with its default page type.
34 PrefService* prefs = Profile::FromWebUI(web_ui)->GetPrefs();
35 int shown_page_type = prefs->GetInteger(prefs::kNTPShownPage) >>
36 PAGE_ID_OFFSET;
37 UMA_HISTOGRAM_ENUMERATION("NtpHandler.AttachShownPageType",
38 shown_page_type, 4);
39
40 static bool default_apps_trial_exists =
41 base::FieldTrialList::TrialExists(kDefaultAppsTrial_Name);
Evan Stade 2011/10/04 16:58:33 why does this variable have an underscore in it
Roger Tawa OOO till Jul 10th 2011/10/04 17:38:46 Because that's the way its declared in default_app
Evan Stade 2011/10/04 17:54:35 right. I couldn't comment there because it's not i
Roger Tawa OOO till Jul 10th 2011/10/04 18:15:25 That can be addressed in a follow up CL.
42 if (default_apps_trial_exists) {
43 UMA_HISTOGRAM_ENUMERATION(
44 base::FieldTrial::MakeName("NtpHandler.AttachShownPageType",
45 kDefaultAppsTrial_Name),
46 shown_page_type, 4);
47 }
48
49 return WebUIMessageHandler::Attach(web_ui);
50 }
51
27 void NewTabPageHandler::RegisterMessages() { 52 void NewTabPageHandler::RegisterMessages() {
28 web_ui_->RegisterMessageCallback("closeNotificationPromo", 53 web_ui()->RegisterMessageCallback("closeNotificationPromo",
29 base::Bind(&NewTabPageHandler::HandleCloseNotificationPromo, 54 base::Bind(&NewTabPageHandler::HandleCloseNotificationPromo,
30 base::Unretained(this))); 55 base::Unretained(this)));
31 web_ui_->RegisterMessageCallback("notificationPromoViewed", 56 web_ui()->RegisterMessageCallback("notificationPromoViewed",
32 base::Bind(&NewTabPageHandler::HandleNotificationPromoViewed, 57 base::Bind(&NewTabPageHandler::HandleNotificationPromoViewed,
33 base::Unretained(this))); 58 base::Unretained(this)));
34 web_ui_->RegisterMessageCallback("pageSelected", 59 web_ui()->RegisterMessageCallback("pageSelected",
35 base::Bind(&NewTabPageHandler::HandlePageSelected, 60 base::Bind(&NewTabPageHandler::HandlePageSelected,
36 base::Unretained(this))); 61 base::Unretained(this)));
37 web_ui_->RegisterMessageCallback("introMessageDismissed", 62 web_ui()->RegisterMessageCallback("introMessageDismissed",
38 base::Bind(&NewTabPageHandler::HandleIntroMessageDismissed, 63 base::Bind(&NewTabPageHandler::HandleIntroMessageDismissed,
39 base::Unretained(this))); 64 base::Unretained(this)));
40 web_ui_->RegisterMessageCallback("introMessageSeen", 65 web_ui()->RegisterMessageCallback("introMessageSeen",
41 base::Bind(&NewTabPageHandler::HandleIntroMessageSeen, 66 base::Bind(&NewTabPageHandler::HandleIntroMessageSeen,
42 base::Unretained(this))); 67 base::Unretained(this)));
43 } 68 }
44 69
45 void NewTabPageHandler::HandleCloseNotificationPromo(const ListValue* args) { 70 void NewTabPageHandler::HandleCloseNotificationPromo(const ListValue* args) {
46 NotificationPromo notification_promo( 71 NotificationPromo notification_promo(
47 Profile::FromWebUI(web_ui_)->GetPrefs(), NULL); 72 Profile::FromWebUI(web_ui())->GetPrefs(), NULL);
48 notification_promo.HandleClosed(); 73 notification_promo.HandleClosed();
49 NotifyPromoResourceChanged(); 74 NotifyPromoResourceChanged();
50 } 75 }
51 76
52 void NewTabPageHandler::HandleNotificationPromoViewed(const ListValue* args) { 77 void NewTabPageHandler::HandleNotificationPromoViewed(const ListValue* args) {
53 NotificationPromo notification_promo( 78 NotificationPromo notification_promo(
54 Profile::FromWebUI(web_ui_)->GetPrefs(), NULL); 79 Profile::FromWebUI(web_ui_)->GetPrefs(), NULL);
55 if (notification_promo.HandleViewed()) { 80 if (notification_promo.HandleViewed()) {
56 NotifyPromoResourceChanged(); 81 NotifyPromoResourceChanged();
57 } 82 }
58 } 83 }
59 84
60 void NewTabPageHandler::HandlePageSelected(const ListValue* args) { 85 void NewTabPageHandler::HandlePageSelected(const ListValue* args) {
61 double page_id_double; 86 double page_id_double;
62 CHECK(args->GetDouble(0, &page_id_double)); 87 CHECK(args->GetDouble(0, &page_id_double));
63 int page_id = static_cast<int>(page_id_double); 88 int page_id = static_cast<int>(page_id_double);
64 89
65 double index_double; 90 double index_double;
66 CHECK(args->GetDouble(1, &index_double)); 91 CHECK(args->GetDouble(1, &index_double));
67 int index = static_cast<int>(index_double); 92 int index = static_cast<int>(index_double);
68 93
69 PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs(); 94 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
70 prefs->SetInteger(prefs::kNTPShownPage, page_id | index); 95 prefs->SetInteger(prefs::kNTPShownPage, page_id | index);
96
97 int shown_page_type = page_id >> PAGE_ID_OFFSET;
98 UMA_HISTOGRAM_ENUMERATION("NtpHandler.SelectedShownPageType",
Evan Stade 2011/10/04 16:58:33 don't you have to add this name to a list somewher
Roger Tawa OOO till Jul 10th 2011/10/04 17:38:46 That change is in a separate repo.
99 shown_page_type, 4);
100
101 static bool default_apps_trial_exists =
102 base::FieldTrialList::TrialExists(kDefaultAppsTrial_Name);
103 if (default_apps_trial_exists) {
104 UMA_HISTOGRAM_ENUMERATION(
105 base::FieldTrial::MakeName("NtpHandler.SelectedShownPageType",
106 kDefaultAppsTrial_Name),
107 shown_page_type, 4);
108 }
71 } 109 }
72 110
73 void NewTabPageHandler::HandleIntroMessageDismissed(const ListValue* args) { 111 void NewTabPageHandler::HandleIntroMessageDismissed(const ListValue* args) {
74 PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs(); 112 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
75 prefs->SetInteger(prefs::kNTP4IntroDisplayCount, kIntroDisplayMax + 1); 113 prefs->SetInteger(prefs::kNTP4IntroDisplayCount, kIntroDisplayMax + 1);
76 } 114 }
77 115
78 void NewTabPageHandler::HandleIntroMessageSeen(const ListValue* args) { 116 void NewTabPageHandler::HandleIntroMessageSeen(const ListValue* args) {
79 PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs(); 117 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
80 int intro_displays = prefs->GetInteger(prefs::kNTP4IntroDisplayCount); 118 int intro_displays = prefs->GetInteger(prefs::kNTP4IntroDisplayCount);
81 prefs->SetInteger(prefs::kNTP4IntroDisplayCount, intro_displays + 1); 119 prefs->SetInteger(prefs::kNTP4IntroDisplayCount, intro_displays + 1);
82 } 120 }
83 121
84 // static 122 // static
85 void NewTabPageHandler::RegisterUserPrefs(PrefService* prefs) { 123 void NewTabPageHandler::RegisterUserPrefs(PrefService* prefs) {
86 // TODO(estade): should be syncable. 124 // TODO(estade): should be syncable.
87 prefs->RegisterIntegerPref(prefs::kNTPShownPage, APPS_PAGE_ID, 125 prefs->RegisterIntegerPref(prefs::kNTPShownPage, APPS_PAGE_ID,
88 PrefService::UNSYNCABLE_PREF); 126 PrefService::UNSYNCABLE_PREF);
89 prefs->RegisterIntegerPref(prefs::kNTP4IntroDisplayCount, 0, 127 prefs->RegisterIntegerPref(prefs::kNTP4IntroDisplayCount, 0,
(...skipping 29 matching lines...) Expand all
119 void NewTabPageHandler::DismissIntroMessage(PrefService* prefs) { 157 void NewTabPageHandler::DismissIntroMessage(PrefService* prefs) {
120 prefs->SetInteger(prefs::kNTP4IntroDisplayCount, kIntroDisplayMax + 1); 158 prefs->SetInteger(prefs::kNTP4IntroDisplayCount, kIntroDisplayMax + 1);
121 } 159 }
122 160
123 void NewTabPageHandler::NotifyPromoResourceChanged() { 161 void NewTabPageHandler::NotifyPromoResourceChanged() {
124 NotificationService* service = NotificationService::current(); 162 NotificationService* service = NotificationService::current();
125 service->Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED, 163 service->Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED,
126 Source<NewTabPageHandler>(this), 164 Source<NewTabPageHandler>(this),
127 NotificationService::NoDetails()); 165 NotificationService::NoDetails());
128 } 166 }
OLDNEW
« no previous file with comments | « 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