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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 void NewTabPageHandler::HandlePageSelected(const ListValue* args) { | 83 void NewTabPageHandler::HandlePageSelected(const ListValue* args) { |
84 double page_id_double; | 84 double page_id_double; |
85 CHECK(args->GetDouble(0, &page_id_double)); | 85 CHECK(args->GetDouble(0, &page_id_double)); |
86 int page_id = static_cast<int>(page_id_double); | 86 int page_id = static_cast<int>(page_id_double); |
87 | 87 |
88 double index_double; | 88 double index_double; |
89 CHECK(args->GetDouble(1, &index_double)); | 89 CHECK(args->GetDouble(1, &index_double)); |
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 int previous_shown_page = |
| 94 prefs->GetInteger(prefs::kNTPShownPage) >> kPageIdOffset; |
| 95 UMA_HISTOGRAM_ENUMERATION("NewTabPage.PreviousSelectedPageType", |
| 96 previous_shown_page, kHistogramEnumerationMax); |
| 97 |
93 prefs->SetInteger(prefs::kNTPShownPage, page_id | index); | 98 prefs->SetInteger(prefs::kNTPShownPage, page_id | index); |
94 | 99 |
95 int shown_page_type = page_id >> kPageIdOffset; | 100 int shown_page_type = page_id >> kPageIdOffset; |
96 UMA_HISTOGRAM_ENUMERATION("NewTabPage.SelectedPageType", | 101 UMA_HISTOGRAM_ENUMERATION("NewTabPage.SelectedPageType", |
97 shown_page_type, kHistogramEnumerationMax); | 102 shown_page_type, kHistogramEnumerationMax); |
98 | 103 |
99 static bool default_apps_trial_exists = | 104 static bool default_apps_trial_exists = |
100 base::FieldTrialList::TrialExists(kDefaultAppsTrial_Name); | 105 base::FieldTrialList::TrialExists(kDefaultAppsTrial_Name); |
101 if (default_apps_trial_exists) { | 106 if (default_apps_trial_exists) { |
102 UMA_HISTOGRAM_ENUMERATION( | 107 UMA_HISTOGRAM_ENUMERATION( |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // is only called during startup before the ntp resource cache is constructed. | 175 // is only called during startup before the ntp resource cache is constructed. |
171 } | 176 } |
172 | 177 |
173 void NewTabPageHandler::Notify(chrome::NotificationType notification_type) { | 178 void NewTabPageHandler::Notify(chrome::NotificationType notification_type) { |
174 content::NotificationService* service = | 179 content::NotificationService* service = |
175 content::NotificationService::current(); | 180 content::NotificationService::current(); |
176 service->Notify(notification_type, | 181 service->Notify(notification_type, |
177 content::Source<NewTabPageHandler>(this), | 182 content::Source<NewTabPageHandler>(this), |
178 content::NotificationService::NoDetails()); | 183 content::NotificationService::NoDetails()); |
179 } | 184 } |
OLD | NEW |