Chromium Code Reviews| Index: chrome/browser/ui/webui/ntp/new_tab_ui.cc |
| diff --git a/chrome/browser/ui/webui/ntp/new_tab_ui.cc b/chrome/browser/ui/webui/ntp/new_tab_ui.cc |
| index 2ad0c41aa41c1ead7242ab332aea7337c67fbfe6..295f295dd7a4ed9a0f37f77f0c5d8dedf4fd274f 100644 |
| --- a/chrome/browser/ui/webui/ntp/new_tab_ui.cc |
| +++ b/chrome/browser/ui/webui/ntp/new_tab_ui.cc |
| @@ -29,6 +29,7 @@ |
| #include "chrome/browser/ui/webui/ntp/bookmarks_handler.h" |
| #include "chrome/browser/ui/webui/ntp/favicon_webui_handler.h" |
| #include "chrome/browser/ui/webui/ntp/foreign_session_handler.h" |
| +#include "chrome/browser/ui/webui/ntp/metrics_handler.h" |
| #include "chrome/browser/ui/webui/ntp/most_visited_handler.h" |
| #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h" |
| #include "chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.h" |
| @@ -55,12 +56,6 @@ |
| namespace { |
| -// The number of recent bookmarks we show. |
| -const int kRecentBookmarks = 9; |
| - |
| -// The number of search URLs to show. |
| -const int kSearchURLs = 3; |
| - |
|
Dan Beam
2011/09/28 03:12:10
As far as I can tell these were never used anywher
|
| // The amount of time there must be no painting for us to consider painting |
| // finished. Observed times are in the ~1200ms range on Windows. |
| const int kTimeoutMs = 2000; |
| @@ -70,119 +65,6 @@ const int kTimeoutMs = 2000; |
| const char kRTLHtmlTextDirection[] = "rtl"; |
| const char kDefaultHtmlTextDirection[] = "ltr"; |
| -/////////////////////////////////////////////////////////////////////////////// |
| -// MetricsHandler |
| - |
| -// Let the page contents record UMA actions. Only use when you can't do it from |
| -// C++. For example, we currently use it to let the NTP log the postion of the |
| -// Most Visited or Bookmark the user clicked on, as we don't get that |
| -// information through RequestOpenURL. You will need to update the metrics |
| -// dashboard with the action names you use, as our processor won't catch that |
| -// information (treat it as RecordComputedMetrics) |
| -class MetricsHandler : public WebUIMessageHandler { |
| - public: |
| - MetricsHandler() {} |
| - virtual ~MetricsHandler() {} |
| - |
| - // WebUIMessageHandler implementation. |
| - virtual void RegisterMessages() OVERRIDE; |
| - |
| - // Callback which records a user action. |
| - void HandleRecordAction(const ListValue* args); |
| - |
| - // Callback which records into a histogram. |args| contains the histogram |
| - // name, the value to record, and the maximum allowed value, which can be at |
| - // most 4000. The histogram will use at most 100 buckets, one for each 1, |
| - // 10, or 100 different values, depending on the maximum value. |
| - void HandleRecordInHistogram(const ListValue* args); |
| - |
| - // Callback for the "logEventTime" message. |
| - void HandleLogEventTime(const ListValue* args); |
| - |
| - private: |
| - |
| - DISALLOW_COPY_AND_ASSIGN(MetricsHandler); |
| -}; |
| - |
| -void MetricsHandler::RegisterMessages() { |
| - web_ui_->RegisterMessageCallback("recordAction", |
| - NewCallback(this, &MetricsHandler::HandleRecordAction)); |
| - web_ui_->RegisterMessageCallback("recordInHistogram", |
| - NewCallback(this, &MetricsHandler::HandleRecordInHistogram)); |
| - |
| - web_ui_->RegisterMessageCallback("logEventTime", |
| - NewCallback(this, &MetricsHandler::HandleLogEventTime)); |
| -} |
| - |
| -void MetricsHandler::HandleRecordAction(const ListValue* args) { |
| - std::string string_action = UTF16ToUTF8(ExtractStringValue(args)); |
| - UserMetrics::RecordComputedAction(string_action); |
| -} |
| - |
| -void MetricsHandler::HandleRecordInHistogram(const ListValue* args) { |
| - std::string histogram_name; |
| - double value; |
| - double boundary_value; |
| - if (!args->GetString(0, &histogram_name) || |
| - !args->GetDouble(1, &value) || |
| - !args->GetDouble(2, &boundary_value)) { |
| - NOTREACHED(); |
| - return; |
| - } |
| - |
| - int int_value = static_cast<int>(value); |
| - int int_boundary_value = static_cast<int>(boundary_value); |
| - if (int_boundary_value >= 4000 || |
| - int_value > int_boundary_value || |
| - int_value < 0) { |
| - NOTREACHED(); |
| - return; |
| - } |
| - |
| - int bucket_count = int_boundary_value; |
| - while (bucket_count >= 100) { |
| - bucket_count /= 10; |
| - } |
| - |
| - // As |histogram_name| may change between calls, the UMA_HISTOGRAM_ENUMERATION |
| - // macro cannot be used here. |
| - base::Histogram* counter = |
| - base::LinearHistogram::FactoryGet( |
| - histogram_name, 1, int_boundary_value, bucket_count + 1, |
| - base::Histogram::kUmaTargetedHistogramFlag); |
| - counter->Add(int_value); |
| -} |
| - |
| -void MetricsHandler::HandleLogEventTime(const ListValue* args) { |
| - std::string event_name = UTF16ToUTF8(ExtractStringValue(args)); |
| - TabContents* tab = web_ui_->tab_contents(); |
| - |
| - // Not all new tab pages get timed. In those cases, we don't have a |
| - // new_tab_start_time_. |
| - if (tab->new_tab_start_time().is_null()) |
| - return; |
| - |
| - base::TimeDelta duration = base::TimeTicks::Now() - tab->new_tab_start_time(); |
| - MetricEventDurationDetails details(event_name, |
| - static_cast<int>(duration.InMilliseconds())); |
| - |
| - if (event_name == "Tab.NewTabScriptStart") { |
| - UMA_HISTOGRAM_TIMES("Tab.NewTabScriptStart", duration); |
| - } else if (event_name == "Tab.NewTabDOMContentLoaded") { |
| - UMA_HISTOGRAM_TIMES("Tab.NewTabDOMContentLoaded", duration); |
| - } else if (event_name == "Tab.NewTabOnload") { |
| - UMA_HISTOGRAM_TIMES("Tab.NewTabOnload", duration); |
| - // The new tab page has finished loading; reset it. |
| - tab->set_new_tab_start_time(base::TimeTicks()); |
| - } else { |
| - NOTREACHED(); |
| - } |
| - NotificationService::current()->Notify( |
| - chrome::NOTIFICATION_METRIC_EVENT_DURATION, |
| - Source<TabContents>(tab), |
| - Details<MetricEventDurationDetails>(&details)); |
| -} |
| - |
| } // namespace |
| /////////////////////////////////////////////////////////////////////////////// |