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/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" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/md5.h" | 12 #include "base/md5.h" |
13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
14 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
16 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
17 #include "base/prefs/scoped_user_pref_update.h" | 17 #include "base/prefs/scoped_user_pref_update.h" |
18 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
21 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
22 #include "base/values.h" | 22 #include "base/values.h" |
23 #include "chrome/browser/favicon/fallback_icon_service_factory.h" | 23 #include "chrome/browser/favicon/fallback_icon_service_factory.h" |
24 #include "chrome/browser/favicon/favicon_service_factory.h" | 24 #include "chrome/browser/favicon/favicon_service_factory.h" |
25 #include "chrome/browser/favicon/large_icon_service_factory.h" | |
25 #include "chrome/browser/history/top_sites_factory.h" | 26 #include "chrome/browser/history/top_sites_factory.h" |
26 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
27 #include "chrome/browser/thumbnails/thumbnail_list_source.h" | 28 #include "chrome/browser/thumbnails/thumbnail_list_source.h" |
28 #include "chrome/browser/ui/browser.h" | 29 #include "chrome/browser/ui/browser.h" |
29 #include "chrome/browser/ui/browser_finder.h" | 30 #include "chrome/browser/ui/browser_finder.h" |
30 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 31 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
31 #include "chrome/browser/ui/tabs/tab_strip_model_utils.h" | 32 #include "chrome/browser/ui/tabs/tab_strip_model_utils.h" |
32 #include "chrome/browser/ui/webui/fallback_icon_source.h" | 33 #include "chrome/browser/ui/webui/fallback_icon_source.h" |
33 #include "chrome/browser/ui/webui/favicon_source.h" | 34 #include "chrome/browser/ui/webui/favicon_source.h" |
34 #include "chrome/browser/ui/webui/large_icon_source.h" | 35 #include "chrome/browser/ui/webui/large_icon_source.h" |
35 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 36 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
36 #include "chrome/browser/ui/webui/ntp/ntp_stats.h" | 37 #include "chrome/browser/ui/webui/ntp/ntp_stats.h" |
37 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" | 38 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" |
38 #include "chrome/common/pref_names.h" | 39 #include "chrome/common/pref_names.h" |
39 #include "chrome/common/url_constants.h" | 40 #include "chrome/common/url_constants.h" |
40 #include "components/favicon/core/fallback_icon_service.h" | 41 #include "components/favicon/core/fallback_icon_service.h" |
41 #include "components/favicon/core/favicon_service.h" | 42 #include "components/favicon/core/favicon_service.h" |
43 #include "components/favicon/core/large_icon_service.h" | |
42 #include "components/history/core/browser/page_usage_data.h" | 44 #include "components/history/core/browser/page_usage_data.h" |
43 #include "components/history/core/browser/top_sites.h" | 45 #include "components/history/core/browser/top_sites.h" |
44 #include "components/keyed_service/core/service_access_type.h" | 46 #include "components/keyed_service/core/service_access_type.h" |
45 #include "components/pref_registry/pref_registry_syncable.h" | 47 #include "components/pref_registry/pref_registry_syncable.h" |
46 #include "content/public/browser/navigation_controller.h" | 48 #include "content/public/browser/navigation_controller.h" |
47 #include "content/public/browser/navigation_entry.h" | 49 #include "content/public/browser/navigation_entry.h" |
48 #include "content/public/browser/url_data_source.h" | 50 #include "content/public/browser/url_data_source.h" |
49 #include "content/public/browser/user_metrics.h" | 51 #include "content/public/browser/user_metrics.h" |
50 #include "content/public/browser/web_contents.h" | 52 #include "content/public/browser/web_contents.h" |
51 #include "content/public/browser/web_ui.h" | 53 #include "content/public/browser/web_ui.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 content::URLDataSource::Add(profile, new ThumbnailSource(profile, true)); | 86 content::URLDataSource::Add(profile, new ThumbnailSource(profile, true)); |
85 | 87 |
86 // Set up our sources for top-sites data. | 88 // Set up our sources for top-sites data. |
87 content::URLDataSource::Add(profile, new ThumbnailListSource(profile)); | 89 content::URLDataSource::Add(profile, new ThumbnailListSource(profile)); |
88 | 90 |
89 favicon::FaviconService* favicon_service = | 91 favicon::FaviconService* favicon_service = |
90 FaviconServiceFactory::GetForProfile(profile, | 92 FaviconServiceFactory::GetForProfile(profile, |
91 ServiceAccessType::EXPLICIT_ACCESS); | 93 ServiceAccessType::EXPLICIT_ACCESS); |
92 favicon::FallbackIconService* fallback_icon_service = | 94 favicon::FallbackIconService* fallback_icon_service = |
93 FallbackIconServiceFactory::GetForBrowserContext(profile); | 95 FallbackIconServiceFactory::GetForBrowserContext(profile); |
96 favicon::LargeIconService* large_icon_service = | |
97 LargeIconServiceFactory::GetForBrowserContext(profile); | |
94 | 98 |
95 // Register chrome://large-icon as a data source for large icons. | 99 // Register chrome://large-icon as a data source for large icons. |
huangs
2015/04/20 19:50:25
NIT: Maybe move this guy after FaviconSource few l
beaudoin
2015/04/21 00:15:38
Done.
| |
96 content::URLDataSource::Add(profile, | 100 content::URLDataSource::Add(profile, new LargeIconSource( |
97 new LargeIconSource(favicon_service, fallback_icon_service)); | 101 favicon_service, fallback_icon_service, large_icon_service)); |
98 content::URLDataSource::Add(profile, | 102 content::URLDataSource::Add(profile, |
huangs
2015/04/20 19:50:25
Hmm weird, I missed adding
// Register chrome://f
beaudoin
2015/04/21 00:15:38
Done.
| |
99 new FallbackIconSource(fallback_icon_service)); | 103 new FallbackIconSource(fallback_icon_service)); |
100 | 104 |
101 // Register chrome://favicon as a data source for favicons. | 105 // Register chrome://favicon as a data source for favicons. |
102 content::URLDataSource::Add( | 106 content::URLDataSource::Add( |
103 profile, new FaviconSource(profile, FaviconSource::FAVICON)); | 107 profile, new FaviconSource(profile, FaviconSource::FAVICON)); |
104 | 108 |
105 scoped_refptr<history::TopSites> top_sites = | 109 scoped_refptr<history::TopSites> top_sites = |
106 TopSitesFactory::GetForProfile(profile); | 110 TopSitesFactory::GetForProfile(profile); |
107 if (top_sites) { | 111 if (top_sites) { |
108 // TopSites updates itself after a delay. This is especially noticable when | 112 // TopSites updates itself after a delay. This is especially noticable when |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 return base::MD5String(url); | 290 return base::MD5String(url); |
287 } | 291 } |
288 | 292 |
289 // static | 293 // static |
290 void MostVisitedHandler::RegisterProfilePrefs( | 294 void MostVisitedHandler::RegisterProfilePrefs( |
291 user_prefs::PrefRegistrySyncable* registry) { | 295 user_prefs::PrefRegistrySyncable* registry) { |
292 registry->RegisterDictionaryPref( | 296 registry->RegisterDictionaryPref( |
293 prefs::kNtpMostVisitedURLsBlacklist, | 297 prefs::kNtpMostVisitedURLsBlacklist, |
294 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 298 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
295 } | 299 } |
OLD | NEW |