OLD | NEW |
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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 WebUIMessageHandler* NewTabPageHandler::Attach(WebUI* web_ui) { | 31 WebUIMessageHandler* NewTabPageHandler::Attach(WebUI* web_ui) { |
32 // Record an open of the NTP with its default page type. | 32 // Record an open of the NTP with its default page type. |
33 PrefService* prefs = Profile::FromWebUI(web_ui)->GetPrefs(); | 33 PrefService* prefs = Profile::FromWebUI(web_ui)->GetPrefs(); |
34 int shown_page_type = prefs->GetInteger(prefs::kNTPShownPage) >> | 34 int shown_page_type = prefs->GetInteger(prefs::kNTPShownPage) >> |
35 kPageIdOffset; | 35 kPageIdOffset; |
36 UMA_HISTOGRAM_ENUMERATION("NewTabPage.DefaultPageType", | 36 UMA_HISTOGRAM_ENUMERATION("NewTabPage.DefaultPageType", |
37 shown_page_type, kHistogramEnumerationMax); | 37 shown_page_type, kHistogramEnumerationMax); |
38 | 38 |
39 static bool default_apps_trial_exists = | 39 static bool default_apps_trial_exists = |
40 base::FieldTrialList::TrialExists(kDefaultAppsTrial_Name); | 40 base::FieldTrialList::TrialExists(kDefaultAppsTrialName); |
41 if (default_apps_trial_exists) { | 41 if (default_apps_trial_exists) { |
42 UMA_HISTOGRAM_ENUMERATION( | 42 UMA_HISTOGRAM_ENUMERATION( |
43 base::FieldTrial::MakeName("NewTabPage.DefaultPageType", | 43 base::FieldTrial::MakeName("NewTabPage.DefaultPageType", |
44 kDefaultAppsTrial_Name), | 44 kDefaultAppsTrialName), |
45 shown_page_type, kHistogramEnumerationMax); | 45 shown_page_type, kHistogramEnumerationMax); |
46 } | 46 } |
47 | 47 |
48 return WebUIMessageHandler::Attach(web_ui); | 48 return WebUIMessageHandler::Attach(web_ui); |
49 } | 49 } |
50 | 50 |
51 void NewTabPageHandler::RegisterMessages() { | 51 void NewTabPageHandler::RegisterMessages() { |
52 web_ui()->RegisterMessageCallback("closeNotificationPromo", | 52 web_ui()->RegisterMessageCallback("closeNotificationPromo", |
53 base::Bind(&NewTabPageHandler::HandleCloseNotificationPromo, | 53 base::Bind(&NewTabPageHandler::HandleCloseNotificationPromo, |
54 base::Unretained(this))); | 54 base::Unretained(this))); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 int index = static_cast<int>(index_double); | 90 int index = static_cast<int>(index_double); |
91 | 91 |
92 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); | 92 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); |
93 prefs->SetInteger(prefs::kNTPShownPage, page_id | index); | 93 prefs->SetInteger(prefs::kNTPShownPage, page_id | index); |
94 | 94 |
95 int shown_page_type = page_id >> kPageIdOffset; | 95 int shown_page_type = page_id >> kPageIdOffset; |
96 UMA_HISTOGRAM_ENUMERATION("NewTabPage.SelectedPageType", | 96 UMA_HISTOGRAM_ENUMERATION("NewTabPage.SelectedPageType", |
97 shown_page_type, kHistogramEnumerationMax); | 97 shown_page_type, kHistogramEnumerationMax); |
98 | 98 |
99 static bool default_apps_trial_exists = | 99 static bool default_apps_trial_exists = |
100 base::FieldTrialList::TrialExists(kDefaultAppsTrial_Name); | 100 base::FieldTrialList::TrialExists(kDefaultAppsTrialName); |
101 if (default_apps_trial_exists) { | 101 if (default_apps_trial_exists) { |
102 UMA_HISTOGRAM_ENUMERATION( | 102 UMA_HISTOGRAM_ENUMERATION( |
103 base::FieldTrial::MakeName("NewTabPage.SelectedPageType", | 103 base::FieldTrial::MakeName("NewTabPage.SelectedPageType", |
104 kDefaultAppsTrial_Name), | 104 kDefaultAppsTrialName), |
105 shown_page_type, kHistogramEnumerationMax); | 105 shown_page_type, kHistogramEnumerationMax); |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 void NewTabPageHandler::HandleIntroMessageDismissed(const ListValue* args) { | 109 void NewTabPageHandler::HandleIntroMessageDismissed(const ListValue* args) { |
110 PrefService* prefs = g_browser_process->local_state(); | 110 PrefService* prefs = g_browser_process->local_state(); |
111 prefs->SetInteger(prefs::kNTP4IntroDisplayCount, kIntroDisplayMax + 1); | 111 prefs->SetInteger(prefs::kNTP4IntroDisplayCount, kIntroDisplayMax + 1); |
112 Notify(chrome::NTP4_INTRO_PREF_CHANGED); | 112 Notify(chrome::NTP4_INTRO_PREF_CHANGED); |
113 } | 113 } |
114 | 114 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // is only called during startup before the ntp resource cache is constructed. | 170 // is only called during startup before the ntp resource cache is constructed. |
171 } | 171 } |
172 | 172 |
173 void NewTabPageHandler::Notify(chrome::NotificationType notification_type) { | 173 void NewTabPageHandler::Notify(chrome::NotificationType notification_type) { |
174 content::NotificationService* service = | 174 content::NotificationService* service = |
175 content::NotificationService::current(); | 175 content::NotificationService::current(); |
176 service->Notify(notification_type, | 176 service->Notify(notification_type, |
177 content::Source<NewTabPageHandler>(this), | 177 content::Source<NewTabPageHandler>(this), |
178 content::NotificationService::NoDetails()); | 178 content::NotificationService::NoDetails()); |
179 } | 179 } |
OLD | NEW |