OLD | NEW |
---|---|
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 <math.h> | 7 #include <math.h> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/md5.h" | 12 #include "base/md5.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "chrome/browser/chrome_notification_types.h" | 18 #include "chrome/browser/chrome_notification_types.h" |
19 #include "chrome/browser/history/top_sites.h" | 19 #include "chrome/browser/history/top_sites.h" |
20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/ui/webui/fallback_icon_source.h" | |
21 #include "chrome/browser/ui/webui/favicon_source.h" | 22 #include "chrome/browser/ui/webui/favicon_source.h" |
22 #include "chrome/browser/ui/webui/ntp/ntp_stats.h" | 23 #include "chrome/browser/ui/webui/ntp/ntp_stats.h" |
23 #include "chrome/browser/ui/webui/ntp/suggestions_combiner.h" | 24 #include "chrome/browser/ui/webui/ntp/suggestions_combiner.h" |
24 #include "chrome/browser/ui/webui/ntp/suggestions_source_top_sites.h" | 25 #include "chrome/browser/ui/webui/ntp/suggestions_source_top_sites.h" |
25 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" | 26 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" |
26 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
27 #include "components/history/core/browser/page_usage_data.h" | 28 #include "components/history/core/browser/page_usage_data.h" |
28 #include "components/pref_registry/pref_registry_syncable.h" | 29 #include "components/pref_registry/pref_registry_syncable.h" |
29 #include "content/public/browser/navigation_controller.h" | 30 #include "content/public/browser/navigation_controller.h" |
30 #include "content/public/browser/navigation_entry.h" | 31 #include "content/public/browser/navigation_entry.h" |
(...skipping 26 matching lines...) Expand all Loading... | |
57 | 58 |
58 UMA_HISTOGRAM_ENUMERATION("NewTabPage.SuggestedSitesAction", action_id, | 59 UMA_HISTOGRAM_ENUMERATION("NewTabPage.SuggestedSitesAction", action_id, |
59 NUM_NTP_FOLLOW_ACTIONS); | 60 NUM_NTP_FOLLOW_ACTIONS); |
60 } | 61 } |
61 } | 62 } |
62 | 63 |
63 void SuggestionsHandler::RegisterMessages() { | 64 void SuggestionsHandler::RegisterMessages() { |
64 Profile* profile = Profile::FromWebUI(web_ui()); | 65 Profile* profile = Profile::FromWebUI(web_ui()); |
65 // Set up our sources for thumbnail and favicon data. | 66 // Set up our sources for thumbnail and favicon data. |
66 content::URLDataSource::Add(profile, new ThumbnailSource(profile, false)); | 67 content::URLDataSource::Add(profile, new ThumbnailSource(profile, false)); |
68 content::URLDataSource::Add(profile, new FallbackIconSource()); | |
pkotwicz
2015/01/23 16:00:47
I think that SuggestionsHandler is no longer used
huangs
2015/01/23 19:47:50
Done.
| |
67 content::URLDataSource::Add( | 69 content::URLDataSource::Add( |
68 profile, new FaviconSource(profile, FaviconSource::FAVICON)); | 70 profile, new FaviconSource(profile, FaviconSource::FAVICON)); |
69 | 71 |
70 // TODO(georgey) change the source of the web-sites to provide our data. | 72 // TODO(georgey) change the source of the web-sites to provide our data. |
71 // Initial commit uses top sites as a data source. | 73 // Initial commit uses top sites as a data source. |
72 history::TopSites* top_sites = profile->GetTopSites(); | 74 history::TopSites* top_sites = profile->GetTopSites(); |
73 if (top_sites) { | 75 if (top_sites) { |
74 // TopSites updates itself after a delay. This is especially noticable when | 76 // TopSites updates itself after a delay. This is especially noticable when |
75 // your profile is empty. Ask TopSites to update itself when we're about to | 77 // your profile is empty. Ask TopSites to update itself when we're about to |
76 // show the new tab page. | 78 // show the new tab page. |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 | 192 |
191 std::string SuggestionsHandler::GetDictionaryKeyForURL(const std::string& url) { | 193 std::string SuggestionsHandler::GetDictionaryKeyForURL(const std::string& url) { |
192 return base::MD5String(url); | 194 return base::MD5String(url); |
193 } | 195 } |
194 | 196 |
195 // static | 197 // static |
196 void SuggestionsHandler::RegisterProfilePrefs( | 198 void SuggestionsHandler::RegisterProfilePrefs( |
197 user_prefs::PrefRegistrySyncable* registry) { | 199 user_prefs::PrefRegistrySyncable* registry) { |
198 // TODO(georgey) add user preferences (such as own blacklist) as needed. | 200 // TODO(georgey) add user preferences (such as own blacklist) as needed. |
199 } | 201 } |
OLD | NEW |