Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Side by Side Diff: chrome/browser/ui/webui/ntp/suggestions_page_handler.cc

Issue 10182006: Adds the MostVisitedAction stat. This stat will provide a baseline to compare (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/ntp/ntp_stats.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/suggestions_page_handler.h" 5 #include "chrome/browser/ui/webui/ntp/suggestions_page_handler.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/md5.h" 11 #include "base/md5.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/string16.h" 15 #include "base/string16.h"
16 #include "base/string_number_conversions.h" 16 #include "base/string_number_conversions.h"
17 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
18 #include "base/utf_string_conversions.h" 18 #include "base/utf_string_conversions.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "chrome/browser/history/page_usage_data.h" 20 #include "chrome/browser/history/page_usage_data.h"
21 #include "chrome/browser/history/top_sites.h" 21 #include "chrome/browser/history/top_sites.h"
22 #include "chrome/browser/history/visit_filter.h" 22 #include "chrome/browser/history/visit_filter.h"
23 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 24 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
25 #include "chrome/browser/ui/webui/favicon_source.h" 25 #include "chrome/browser/ui/webui/favicon_source.h"
26 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" 26 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
27 #include "chrome/browser/ui/webui/ntp/ntp_stats.h"
27 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" 28 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h"
28 #include "chrome/common/chrome_notification_types.h" 29 #include "chrome/common/chrome_notification_types.h"
29 #include "chrome/common/url_constants.h" 30 #include "chrome/common/url_constants.h"
30 #include "content/public/browser/browser_thread.h" 31 #include "content/public/browser/browser_thread.h"
31 #include "content/public/browser/navigation_controller.h" 32 #include "content/public/browser/navigation_controller.h"
32 #include "content/public/browser/navigation_entry.h" 33 #include "content/public/browser/navigation_entry.h"
33 #include "content/public/browser/notification_source.h" 34 #include "content/public/browser/notification_source.h"
34 #include "content/public/browser/user_metrics.h" 35 #include "content/public/browser/user_metrics.h"
35 #include "content/public/browser/web_contents.h" 36 #include "content/public/browser/web_contents.h"
36 #include "content/public/browser/web_ui.h" 37 #include "content/public/browser/web_ui.h"
37 #include "content/public/common/page_transition_types.h" 38 #include "content/public/common/page_transition_types.h"
38 #include "googleurl/src/gurl.h" 39 #include "googleurl/src/gurl.h"
39 40
40 using content::UserMetricsAction; 41 using content::UserMetricsAction;
41 42
42 namespace {
43
44 // Those values are defined in histograms.xml. These represent the action that
45 // the user has taken to leave the Suggested pane, given that they have viewed
46 // that pane on the NTP.
47 enum SuggestedSitesActions {
48 // Values 0 to 10 are the core values from PageTransition (see
49 // page_transition_types.h).
50
51 // The user has clicked on a Suggested tile.
52 SUGGESTED_SITES_ACTION_CLICKED_SUGGESTED_TILE = 11,
53 // The user has moved to another pane within the NTP.
54 SUGGESTED_SITES_ACTION_CLICKED_OTHER_NTP_PANE,
55 // Any action other than what is listed here (e.g. closing the tab, etc.).
56 SUGGESTED_SITES_ACTION_OTHER,
57 // The number of suggested sites actions that we log.
58 NUM_SUGGESTED_SITES_ACTIONS
59 };
60
61 } // namespace
62
63 SuggestionsHandler::SuggestionsHandler() 43 SuggestionsHandler::SuggestionsHandler()
64 : got_first_suggestions_request_(false), 44 : got_first_suggestions_request_(false),
65 suggestions_viewed_(false), 45 suggestions_viewed_(false),
66 user_action_logged_(false) { 46 user_action_logged_(false) {
67 } 47 }
68 48
69 SuggestionsHandler::~SuggestionsHandler() { 49 SuggestionsHandler::~SuggestionsHandler() {
70 // TODO(macourteau): ensure that |suggestions_viewed_| gets set correctly,
71 // once the Suggestions pane gets statically included into the NTP (e.g.,
72 // if the Suggestions pane is the one shown by default, the
73 // |suggestions_viewed_| flag might not get set).
74 if (!user_action_logged_ && suggestions_viewed_) { 50 if (!user_action_logged_ && suggestions_viewed_) {
75 const GURL ntp_url = GURL(chrome::kChromeUINewTabURL); 51 const GURL ntp_url = GURL(chrome::kChromeUINewTabURL);
76 int action_id = SUGGESTED_SITES_ACTION_OTHER; 52 int action_id = NTP_FOLLOW_ACTION_OTHER;
77 content::NavigationEntry* entry = 53 content::NavigationEntry* entry =
78 web_ui()->GetWebContents()->GetController().GetActiveEntry(); 54 web_ui()->GetWebContents()->GetController().GetActiveEntry();
79 if (entry && (entry->GetURL() != ntp_url)) { 55 if (entry && (entry->GetURL() != ntp_url)) {
80 action_id = 56 action_id =
81 content::PageTransitionStripQualifier(entry->GetTransitionType()); 57 content::PageTransitionStripQualifier(entry->GetTransitionType());
82 } 58 }
83 59
84 UMA_HISTOGRAM_ENUMERATION("NewTabPage.SuggestedSitesAction", action_id, 60 UMA_HISTOGRAM_ENUMERATION("NewTabPage.SuggestedSitesAction", action_id,
85 NUM_SUGGESTED_SITES_ACTIONS); 61 NUM_NTP_FOLLOW_ACTIONS);
86 } 62 }
87 } 63 }
88 64
89 void SuggestionsHandler::RegisterMessages() { 65 void SuggestionsHandler::RegisterMessages() {
90 Profile* profile = Profile::FromWebUI(web_ui()); 66 Profile* profile = Profile::FromWebUI(web_ui());
91 // Set up our sources for thumbnail and favicon data. 67 // Set up our sources for thumbnail and favicon data.
92 ChromeURLDataManager::AddDataSource(profile, new ThumbnailSource(profile)); 68 ChromeURLDataManager::AddDataSource(profile, new ThumbnailSource(profile));
93 ChromeURLDataManager::AddDataSource(profile, 69 ChromeURLDataManager::AddDataSource(profile,
94 new FaviconSource(profile, FaviconSource::FAVICON)); 70 new FaviconSource(profile, FaviconSource::FAVICON));
95 71
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 void SuggestionsHandler::HandleSuggestedSitesAction( 164 void SuggestionsHandler::HandleSuggestedSitesAction(
189 const base::ListValue* args) { 165 const base::ListValue* args) {
190 DCHECK(args); 166 DCHECK(args);
191 167
192 double action_id; 168 double action_id;
193 if (!args->GetDouble(0, &action_id)) 169 if (!args->GetDouble(0, &action_id))
194 NOTREACHED(); 170 NOTREACHED();
195 171
196 UMA_HISTOGRAM_ENUMERATION("NewTabPage.SuggestedSitesAction", 172 UMA_HISTOGRAM_ENUMERATION("NewTabPage.SuggestedSitesAction",
197 static_cast<int>(action_id), 173 static_cast<int>(action_id),
198 NUM_SUGGESTED_SITES_ACTIONS); 174 NUM_NTP_FOLLOW_ACTIONS);
199 suggestions_viewed_ = true; 175 suggestions_viewed_ = true;
200 user_action_logged_ = true; 176 user_action_logged_ = true;
201 } 177 }
202 178
203 void SuggestionsHandler::HandleSuggestedSitesSelected( 179 void SuggestionsHandler::HandleSuggestedSitesSelected(
204 const base::ListValue* args) { 180 const base::ListValue* args) {
205 suggestions_viewed_ = true; 181 suggestions_viewed_ = true;
206 } 182 }
207 183
208 void SuggestionsHandler::SetPagesValueFromTopSites( 184 void SuggestionsHandler::SetPagesValueFromTopSites(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } 219 }
244 220
245 std::string SuggestionsHandler::GetDictionaryKeyForURL(const std::string& url) { 221 std::string SuggestionsHandler::GetDictionaryKeyForURL(const std::string& url) {
246 return base::MD5String(url); 222 return base::MD5String(url);
247 } 223 }
248 224
249 // static 225 // static
250 void SuggestionsHandler::RegisterUserPrefs(PrefService* prefs) { 226 void SuggestionsHandler::RegisterUserPrefs(PrefService* prefs) {
251 // TODO(georgey) add user preferences (such as own blacklist) as needed. 227 // TODO(georgey) add user preferences (such as own blacklist) as needed.
252 } 228 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/ntp_stats.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698