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 10 matching lines...) Expand all Loading... |
21 #include "grit/chromium_strings.h" | 21 #include "grit/chromium_strings.h" |
22 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
24 | 24 |
25 static const int kIntroDisplayMax = 10; | 25 static const int kIntroDisplayMax = 10; |
26 | 26 |
27 // The URL of a knowledge-base article about the new NTP. | 27 // The URL of a knowledge-base article about the new NTP. |
28 static const char kNTP4IntroURL[] = | 28 static const char kNTP4IntroURL[] = |
29 "http://www.google.com/support/chrome/bin/answer.py?answer=95451"; | 29 "http://www.google.com/support/chrome/bin/answer.py?answer=95451"; |
30 | 30 |
| 31 NewTabPageHandler::NewTabPageHandler() : page_switch_count_(0) { |
| 32 } |
| 33 |
| 34 NewTabPageHandler::~NewTabPageHandler() { |
| 35 HISTOGRAM_COUNTS_100("NewTabPage.SingleSessionPageSwitches", |
| 36 page_switch_count_); |
| 37 } |
| 38 |
31 WebUIMessageHandler* NewTabPageHandler::Attach(WebUI* web_ui) { | 39 WebUIMessageHandler* NewTabPageHandler::Attach(WebUI* web_ui) { |
32 // Record an open of the NTP with its default page type. | 40 // Record an open of the NTP with its default page type. |
33 PrefService* prefs = Profile::FromWebUI(web_ui)->GetPrefs(); | 41 PrefService* prefs = Profile::FromWebUI(web_ui)->GetPrefs(); |
34 int shown_page_type = prefs->GetInteger(prefs::kNTPShownPage) >> | 42 int shown_page_type = prefs->GetInteger(prefs::kNTPShownPage) >> |
35 kPageIdOffset; | 43 kPageIdOffset; |
36 UMA_HISTOGRAM_ENUMERATION("NewTabPage.DefaultPageType", | 44 UMA_HISTOGRAM_ENUMERATION("NewTabPage.DefaultPageType", |
37 shown_page_type, kHistogramEnumerationMax); | 45 shown_page_type, kHistogramEnumerationMax); |
38 | 46 |
39 static bool default_apps_trial_exists = | 47 static bool default_apps_trial_exists = |
40 base::FieldTrialList::TrialExists(kDefaultAppsTrialName); | 48 base::FieldTrialList::TrialExists(kDefaultAppsTrialName); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } | 82 } |
75 | 83 |
76 void NewTabPageHandler::HandleNotificationPromoViewed(const ListValue* args) { | 84 void NewTabPageHandler::HandleNotificationPromoViewed(const ListValue* args) { |
77 scoped_refptr<NotificationPromo> notification_promo = | 85 scoped_refptr<NotificationPromo> notification_promo = |
78 NotificationPromo::Create(Profile::FromWebUI(web_ui_), NULL); | 86 NotificationPromo::Create(Profile::FromWebUI(web_ui_), NULL); |
79 if (notification_promo->HandleViewed()) | 87 if (notification_promo->HandleViewed()) |
80 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED); | 88 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED); |
81 } | 89 } |
82 | 90 |
83 void NewTabPageHandler::HandlePageSelected(const ListValue* args) { | 91 void NewTabPageHandler::HandlePageSelected(const ListValue* args) { |
| 92 page_switch_count_++; |
| 93 |
84 double page_id_double; | 94 double page_id_double; |
85 CHECK(args->GetDouble(0, &page_id_double)); | 95 CHECK(args->GetDouble(0, &page_id_double)); |
86 int page_id = static_cast<int>(page_id_double); | 96 int page_id = static_cast<int>(page_id_double); |
87 | 97 |
88 double index_double; | 98 double index_double; |
89 CHECK(args->GetDouble(1, &index_double)); | 99 CHECK(args->GetDouble(1, &index_double)); |
90 int index = static_cast<int>(index_double); | 100 int index = static_cast<int>(index_double); |
91 | 101 |
92 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); | 102 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); |
93 int previous_shown_page = | 103 int previous_shown_page = |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 // is only called during startup before the ntp resource cache is constructed. | 185 // is only called during startup before the ntp resource cache is constructed. |
176 } | 186 } |
177 | 187 |
178 void NewTabPageHandler::Notify(chrome::NotificationType notification_type) { | 188 void NewTabPageHandler::Notify(chrome::NotificationType notification_type) { |
179 content::NotificationService* service = | 189 content::NotificationService* service = |
180 content::NotificationService::current(); | 190 content::NotificationService::current(); |
181 service->Notify(notification_type, | 191 service->Notify(notification_type, |
182 content::Source<NewTabPageHandler>(this), | 192 content::Source<NewTabPageHandler>(this), |
183 content::NotificationService::NoDetails()); | 193 content::NotificationService::NoDetails()); |
184 } | 194 } |
OLD | NEW |