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

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

Issue 8919017: Split UserMetrics into API vs. implementation. Move API to content/public. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Version for commit (merged again). Created 9 years 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/metrics_handler.cc ('k') | chrome/browser/ui/webui/ntp/new_tab_ui.cc » ('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) 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/most_visited_handler.h" 5 #include "chrome/browser/ui/webui/ntp/most_visited_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"
(...skipping 12 matching lines...) Expand all
23 #include "chrome/browser/prefs/pref_service.h" 23 #include "chrome/browser/prefs/pref_service.h"
24 #include "chrome/browser/prefs/scoped_user_pref_update.h" 24 #include "chrome/browser/prefs/scoped_user_pref_update.h"
25 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 26 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
27 #include "chrome/browser/ui/webui/favicon_source.h" 27 #include "chrome/browser/ui/webui/favicon_source.h"
28 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" 28 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
29 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" 29 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h"
30 #include "chrome/common/chrome_notification_types.h" 30 #include "chrome/common/chrome_notification_types.h"
31 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
32 #include "chrome/common/url_constants.h" 32 #include "chrome/common/url_constants.h"
33 #include "content/browser/user_metrics.h"
34 #include "content/public/browser/browser_thread.h" 33 #include "content/public/browser/browser_thread.h"
35 #include "content/public/browser/notification_source.h" 34 #include "content/public/browser/notification_source.h"
35 #include "content/public/browser/user_metrics.h"
36 #include "googleurl/src/gurl.h" 36 #include "googleurl/src/gurl.h"
37 #include "grit/chromium_strings.h" 37 #include "grit/chromium_strings.h"
38 #include "grit/generated_resources.h" 38 #include "grit/generated_resources.h"
39 #include "grit/locale_settings.h" 39 #include "grit/locale_settings.h"
40 #include "ui/base/l10n/l10n_util.h" 40 #include "ui/base/l10n/l10n_util.h"
41 41
42 using content::UserMetricsAction;
43
42 MostVisitedHandler::MostVisitedHandler() 44 MostVisitedHandler::MostVisitedHandler()
43 : got_first_most_visited_request_(false) { 45 : got_first_most_visited_request_(false) {
44 } 46 }
45 47
46 MostVisitedHandler::~MostVisitedHandler() { 48 MostVisitedHandler::~MostVisitedHandler() {
47 } 49 }
48 50
49 WebUIMessageHandler* MostVisitedHandler::Attach(WebUI* web_ui) { 51 WebUIMessageHandler* MostVisitedHandler::Attach(WebUI* web_ui) {
50 Profile* profile = Profile::FromWebUI(web_ui); 52 Profile* profile = Profile::FromWebUI(web_ui);
51 // Set up our sources for thumbnail and favicon data. 53 // Set up our sources for thumbnail and favicon data.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 DCHECK(args->GetSize() != 0); 141 DCHECK(args->GetSize() != 0);
140 142
141 for (ListValue::const_iterator iter = args->begin(); 143 for (ListValue::const_iterator iter = args->begin();
142 iter != args->end(); ++iter) { 144 iter != args->end(); ++iter) {
143 std::string url; 145 std::string url;
144 bool r = (*iter)->GetAsString(&url); 146 bool r = (*iter)->GetAsString(&url);
145 if (!r) { 147 if (!r) {
146 NOTREACHED(); 148 NOTREACHED();
147 return; 149 return;
148 } 150 }
149 UserMetrics::RecordAction(UserMetricsAction("MostVisited_UrlRemoved")); 151 content::RecordAction(UserMetricsAction("MostVisited_UrlRemoved"));
150 history::TopSites* ts = Profile::FromWebUI(web_ui_)->GetTopSites(); 152 history::TopSites* ts = Profile::FromWebUI(web_ui_)->GetTopSites();
151 if (ts) 153 if (ts)
152 ts->RemoveBlacklistedURL(GURL(url)); 154 ts->RemoveBlacklistedURL(GURL(url));
153 } 155 }
154 } 156 }
155 157
156 void MostVisitedHandler::HandleClearBlacklist(const ListValue* args) { 158 void MostVisitedHandler::HandleClearBlacklist(const ListValue* args) {
157 UserMetrics::RecordAction(UserMetricsAction("MostVisited_BlacklistCleared")); 159 content::RecordAction(UserMetricsAction("MostVisited_BlacklistCleared"));
158 160
159 history::TopSites* ts = Profile::FromWebUI(web_ui_)->GetTopSites(); 161 history::TopSites* ts = Profile::FromWebUI(web_ui_)->GetTopSites();
160 if (ts) 162 if (ts)
161 ts->ClearBlacklistedURLs(); 163 ts->ClearBlacklistedURLs();
162 } 164 }
163 165
164 void MostVisitedHandler::SetPagesValueFromTopSites( 166 void MostVisitedHandler::SetPagesValueFromTopSites(
165 const history::MostVisitedURLList& data) { 167 const history::MostVisitedURLList& data) {
166 pages_value_.reset(new ListValue); 168 pages_value_.reset(new ListValue);
167 for (size_t i = 0; i < data.size(); i++) { 169 for (size_t i = 0; i < data.size(); i++) {
(...skipping 26 matching lines...) Expand all
194 DCHECK_EQ(type, chrome::NOTIFICATION_TOP_SITES_CHANGED); 196 DCHECK_EQ(type, chrome::NOTIFICATION_TOP_SITES_CHANGED);
195 197
196 // Most visited urls changed, query again. 198 // Most visited urls changed, query again.
197 StartQueryForMostVisited(); 199 StartQueryForMostVisited();
198 } 200 }
199 201
200 void MostVisitedHandler::BlacklistURL(const GURL& url) { 202 void MostVisitedHandler::BlacklistURL(const GURL& url) {
201 history::TopSites* ts = Profile::FromWebUI(web_ui_)->GetTopSites(); 203 history::TopSites* ts = Profile::FromWebUI(web_ui_)->GetTopSites();
202 if (ts) 204 if (ts)
203 ts->AddBlacklistedURL(url); 205 ts->AddBlacklistedURL(url);
204 UserMetrics::RecordAction(UserMetricsAction("MostVisited_UrlBlacklisted")); 206 content::RecordAction(UserMetricsAction("MostVisited_UrlBlacklisted"));
205 } 207 }
206 208
207 std::string MostVisitedHandler::GetDictionaryKeyForURL(const std::string& url) { 209 std::string MostVisitedHandler::GetDictionaryKeyForURL(const std::string& url) {
208 return base::MD5String(url); 210 return base::MD5String(url);
209 } 211 }
210 212
211 // static 213 // static
212 void MostVisitedHandler::RegisterUserPrefs(PrefService* prefs) { 214 void MostVisitedHandler::RegisterUserPrefs(PrefService* prefs) {
213 prefs->RegisterDictionaryPref(prefs::kNTPMostVisitedURLsBlacklist, 215 prefs->RegisterDictionaryPref(prefs::kNTPMostVisitedURLsBlacklist,
214 PrefService::UNSYNCABLE_PREF); 216 PrefService::UNSYNCABLE_PREF);
215 // TODO(estade): remove this. 217 // TODO(estade): remove this.
216 prefs->RegisterDictionaryPref(prefs::kNTPMostVisitedPinnedURLs, 218 prefs->RegisterDictionaryPref(prefs::kNTPMostVisitedPinnedURLs,
217 PrefService::UNSYNCABLE_PREF); 219 PrefService::UNSYNCABLE_PREF);
218 } 220 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/metrics_handler.cc ('k') | chrome/browser/ui/webui/ntp/new_tab_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698