| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/search/most_visited_iframe_source.h" | 5 #include "chrome/browser/search/most_visited_iframe_source.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
| 10 #include "content/public/browser/user_metrics.h" | 10 #include "content/public/browser/user_metrics.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 MostVisitedIframeSource::MostVisitedIframeSource() { | 29 MostVisitedIframeSource::MostVisitedIframeSource() { |
| 30 } | 30 } |
| 31 | 31 |
| 32 MostVisitedIframeSource::~MostVisitedIframeSource() { | 32 MostVisitedIframeSource::~MostVisitedIframeSource() { |
| 33 } | 33 } |
| 34 | 34 |
| 35 const int MostVisitedIframeSource::kNumMostVisited = 8; | 35 const int MostVisitedIframeSource::kNumMostVisited = 8; |
| 36 const char MostVisitedIframeSource::kMostVisitedHistogramName[] = | 36 const char MostVisitedIframeSource::kMostVisitedHistogramName[] = |
| 37 "NewTabPage.MostVisited"; | 37 "NewTabPage.MostVisited"; |
| 38 const char MostVisitedIframeSource::kMostVisitedHistogramWithProvider[] = |
| 39 "NewTabPage.MostVisited.%s"; |
| 38 | 40 |
| 39 std::string MostVisitedIframeSource::GetSource() const { | 41 std::string MostVisitedIframeSource::GetSource() const { |
| 40 return chrome::kChromeSearchMostVisitedHost; | 42 return chrome::kChromeSearchMostVisitedHost; |
| 41 } | 43 } |
| 42 | 44 |
| 43 void MostVisitedIframeSource::StartDataRequest( | 45 void MostVisitedIframeSource::StartDataRequest( |
| 44 const std::string& path_and_query, | 46 const std::string& path_and_query, |
| 45 int render_process_id, | 47 int render_process_id, |
| 46 int render_view_id, | 48 int render_view_id, |
| 47 const content::URLDataSource::GotDataCallback& callback) { | 49 const content::URLDataSource::GotDataCallback& callback) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 62 } else if (path == kUtilJSPath) { | 64 } else if (path == kUtilJSPath) { |
| 63 SendResource(IDR_MOST_VISITED_UTIL_JS, callback); | 65 SendResource(IDR_MOST_VISITED_UTIL_JS, callback); |
| 64 } else if (path == kCommonCSSPath) { | 66 } else if (path == kCommonCSSPath) { |
| 65 SendResource(IDR_MOST_VISITED_IFRAME_CSS, callback); | 67 SendResource(IDR_MOST_VISITED_IFRAME_CSS, callback); |
| 66 } else if (path == kLogHTMLPath) { | 68 } else if (path == kLogHTMLPath) { |
| 67 // Log the clicked MostVisited element by position. | 69 // Log the clicked MostVisited element by position. |
| 68 std::string str_position; | 70 std::string str_position; |
| 69 int position; | 71 int position; |
| 70 if (net::GetValueForKeyInQuery(url, "pos", &str_position) && | 72 if (net::GetValueForKeyInQuery(url, "pos", &str_position) && |
| 71 base::StringToInt(str_position, &position)) { | 73 base::StringToInt(str_position, &position)) { |
| 72 UMA_HISTOGRAM_ENUMERATION(kMostVisitedHistogramName, position, | 74 // Log the Most Visited click. |
| 73 kNumMostVisited); | 75 MV_CLICK_HISTOGRAM(position, NULL); |
| 76 // If a specific provider is specified, log the metric specific to the |
| 77 // provider. |
| 78 std::string provider; |
| 79 if (net::GetValueForKeyInQuery(url, "pr", &provider)) { |
| 80 MV_CLICK_HISTOGRAM(position, provider.c_str()); |
| 81 } |
| 74 // Records the action. This will be available as a time-stamped stream | 82 // Records the action. This will be available as a time-stamped stream |
| 75 // server-side and can be used to compute time-to-long-dwell. | 83 // server-side and can be used to compute time-to-long-dwell. |
| 76 content::RecordAction(content::UserMetricsAction("MostVisited_Clicked")); | 84 content::RecordAction(content::UserMetricsAction("MostVisited_Clicked")); |
| 77 } | 85 } |
| 78 callback.Run(NULL); | 86 callback.Run(NULL); |
| 79 } else { | 87 } else { |
| 80 callback.Run(NULL); | 88 callback.Run(NULL); |
| 81 } | 89 } |
| 82 } | 90 } |
| 83 | 91 |
| 84 bool MostVisitedIframeSource::ServesPath(const std::string& path) const { | 92 bool MostVisitedIframeSource::ServesPath(const std::string& path) const { |
| 85 return path == kTitleHTMLPath || path == kTitleCSSPath || | 93 return path == kTitleHTMLPath || path == kTitleCSSPath || |
| 86 path == kTitleJSPath || path == kThumbnailHTMLPath || | 94 path == kTitleJSPath || path == kThumbnailHTMLPath || |
| 87 path == kThumbnailCSSPath || path == kThumbnailJSPath || | 95 path == kThumbnailCSSPath || path == kThumbnailJSPath || |
| 88 path == kUtilJSPath || path == kCommonCSSPath || path == kLogHTMLPath; | 96 path == kUtilJSPath || path == kCommonCSSPath || path == kLogHTMLPath; |
| 89 } | 97 } |
| OLD | NEW |