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

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

Issue 10196004: Changed ChromeURLDataManager to a ProfileKeyedService and made a Factory for it. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed style nit 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
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_factory.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/thumbnail_source.h" 27 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h"
28 #include "chrome/common/chrome_notification_types.h" 28 #include "chrome/common/chrome_notification_types.h"
29 #include "chrome/common/url_constants.h" 29 #include "chrome/common/url_constants.h"
30 #include "content/public/browser/browser_thread.h" 30 #include "content/public/browser/browser_thread.h"
31 #include "content/public/browser/navigation_controller.h" 31 #include "content/public/browser/navigation_controller.h"
32 #include "content/public/browser/navigation_entry.h" 32 #include "content/public/browser/navigation_entry.h"
33 #include "content/public/browser/notification_source.h" 33 #include "content/public/browser/notification_source.h"
34 #include "content/public/browser/user_metrics.h" 34 #include "content/public/browser/user_metrics.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 82 }
83 83
84 UMA_HISTOGRAM_ENUMERATION("NewTabPage.SuggestedSitesAction", action_id, 84 UMA_HISTOGRAM_ENUMERATION("NewTabPage.SuggestedSitesAction", action_id,
85 NUM_SUGGESTED_SITES_ACTIONS); 85 NUM_SUGGESTED_SITES_ACTIONS);
86 } 86 }
87 } 87 }
88 88
89 void SuggestionsHandler::RegisterMessages() { 89 void SuggestionsHandler::RegisterMessages() {
90 Profile* profile = Profile::FromWebUI(web_ui()); 90 Profile* profile = Profile::FromWebUI(web_ui());
91 // Set up our sources for thumbnail and favicon data. 91 // Set up our sources for thumbnail and favicon data.
92 profile->GetChromeURLDataManager()->AddDataSource( 92 ChromeURLDataManagerFactory::GetForProfile(profile)->
93 new ThumbnailSource(profile)); 93 AddDataSource(new ThumbnailSource(profile));
94 profile->GetChromeURLDataManager()->AddDataSource( 94 ChromeURLDataManagerFactory::GetForProfile(profile)->
95 new FaviconSource(profile, FaviconSource::FAVICON)); 95 AddDataSource(new FaviconSource(profile, FaviconSource::FAVICON));
96 96
97 // TODO(georgey) change the source of the web-sites to provide our data. 97 // TODO(georgey) change the source of the web-sites to provide our data.
98 // Initial commit uses top sites as a data source. 98 // Initial commit uses top sites as a data source.
99 history::TopSites* top_sites = profile->GetTopSites(); 99 history::TopSites* top_sites = profile->GetTopSites();
100 if (top_sites) { 100 if (top_sites) {
101 // TopSites updates itself after a delay. This is especially noticable when 101 // TopSites updates itself after a delay. This is especially noticable when
102 // your profile is empty. Ask TopSites to update itself when we're about to 102 // your profile is empty. Ask TopSites to update itself when we're about to
103 // show the new tab page. 103 // show the new tab page.
104 top_sites->SyncWithHistory(); 104 top_sites->SyncWithHistory();
105 105
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } 244 }
245 245
246 std::string SuggestionsHandler::GetDictionaryKeyForURL(const std::string& url) { 246 std::string SuggestionsHandler::GetDictionaryKeyForURL(const std::string& url) {
247 return base::MD5String(url); 247 return base::MD5String(url);
248 } 248 }
249 249
250 // static 250 // static
251 void SuggestionsHandler::RegisterUserPrefs(PrefService* prefs) { 251 void SuggestionsHandler::RegisterUserPrefs(PrefService* prefs) {
252 // TODO(georgey) add user preferences (such as own blacklist) as needed. 252 // TODO(georgey) add user preferences (such as own blacklist) as needed.
253 } 253 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698