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/history/top_sites_factory.h" | 24 #include "chrome/browser/history/top_sites_factory.h" |
24 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/browser/thumbnails/thumbnail_list_source.h" | 26 #include "chrome/browser/thumbnails/thumbnail_list_source.h" |
26 #include "chrome/browser/ui/browser.h" | 27 #include "chrome/browser/ui/browser.h" |
27 #include "chrome/browser/ui/browser_finder.h" | 28 #include "chrome/browser/ui/browser_finder.h" |
28 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 29 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
29 #include "chrome/browser/ui/tabs/tab_strip_model_utils.h" | 30 #include "chrome/browser/ui/tabs/tab_strip_model_utils.h" |
30 #include "chrome/browser/ui/webui/fallback_icon_source.h" | 31 #include "chrome/browser/ui/webui/fallback_icon_source.h" |
31 #include "chrome/browser/ui/webui/favicon_source.h" | 32 #include "chrome/browser/ui/webui/favicon_source.h" |
32 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 33 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
33 #include "chrome/browser/ui/webui/ntp/ntp_stats.h" | 34 #include "chrome/browser/ui/webui/ntp/ntp_stats.h" |
34 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" | 35 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" |
35 #include "chrome/common/pref_names.h" | 36 #include "chrome/common/pref_names.h" |
36 #include "chrome/common/url_constants.h" | 37 #include "chrome/common/url_constants.h" |
37 #include "components/history/core/browser/page_usage_data.h" | 38 #include "components/history/core/browser/page_usage_data.h" |
38 #include "components/history/core/browser/top_sites.h" | 39 #include "components/history/core/browser/top_sites.h" |
| 40 #include "components/keyed_service/core/service_access_type.h" |
39 #include "components/pref_registry/pref_registry_syncable.h" | 41 #include "components/pref_registry/pref_registry_syncable.h" |
40 #include "content/public/browser/navigation_controller.h" | 42 #include "content/public/browser/navigation_controller.h" |
41 #include "content/public/browser/navigation_entry.h" | 43 #include "content/public/browser/navigation_entry.h" |
42 #include "content/public/browser/url_data_source.h" | 44 #include "content/public/browser/url_data_source.h" |
43 #include "content/public/browser/user_metrics.h" | 45 #include "content/public/browser/user_metrics.h" |
44 #include "content/public/browser/web_contents.h" | 46 #include "content/public/browser/web_contents.h" |
45 #include "content/public/browser/web_ui.h" | 47 #include "content/public/browser/web_ui.h" |
46 #include "url/gurl.h" | 48 #include "url/gurl.h" |
47 | 49 |
48 using base::UserMetricsAction; | 50 using base::UserMetricsAction; |
(...skipping 25 matching lines...) Expand all Loading... |
74 void MostVisitedHandler::RegisterMessages() { | 76 void MostVisitedHandler::RegisterMessages() { |
75 Profile* profile = Profile::FromWebUI(web_ui()); | 77 Profile* profile = Profile::FromWebUI(web_ui()); |
76 // Set up our sources for thumbnail and favicon data. | 78 // Set up our sources for thumbnail and favicon data. |
77 content::URLDataSource::Add(profile, new ThumbnailSource(profile, false)); | 79 content::URLDataSource::Add(profile, new ThumbnailSource(profile, false)); |
78 content::URLDataSource::Add(profile, new ThumbnailSource(profile, true)); | 80 content::URLDataSource::Add(profile, new ThumbnailSource(profile, true)); |
79 | 81 |
80 // Set up our sources for top-sites data. | 82 // Set up our sources for top-sites data. |
81 content::URLDataSource::Add(profile, new ThumbnailListSource(profile)); | 83 content::URLDataSource::Add(profile, new ThumbnailListSource(profile)); |
82 | 84 |
83 // Register chrome://fallback-icon as a data source for fallback icons. | 85 // Register chrome://fallback-icon as a data source for fallback icons. |
84 content::URLDataSource::Add(profile, new FallbackIconSource()); | 86 content::URLDataSource::Add(profile, |
| 87 new FallbackIconSource( |
| 88 FallbackIconServiceFactory::GetForProfile( |
| 89 profile, ServiceAccessType::EXPLICIT_ACCESS))); |
85 | 90 |
86 // Register chrome://favicon as a data source for favicons. | 91 // Register chrome://favicon as a data source for favicons. |
87 content::URLDataSource::Add( | 92 content::URLDataSource::Add( |
88 profile, new FaviconSource(profile, FaviconSource::FAVICON)); | 93 profile, new FaviconSource(profile, FaviconSource::FAVICON)); |
89 | 94 |
90 scoped_refptr<history::TopSites> top_sites = | 95 scoped_refptr<history::TopSites> top_sites = |
91 TopSitesFactory::GetForProfile(profile); | 96 TopSitesFactory::GetForProfile(profile); |
92 if (top_sites) { | 97 if (top_sites) { |
93 // TopSites updates itself after a delay. This is especially noticable when | 98 // TopSites updates itself after a delay. This is especially noticable when |
94 // your profile is empty. Ask TopSites to update itself when we're about to | 99 // your profile is empty. Ask TopSites to update itself when we're about to |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 return base::MD5String(url); | 276 return base::MD5String(url); |
272 } | 277 } |
273 | 278 |
274 // static | 279 // static |
275 void MostVisitedHandler::RegisterProfilePrefs( | 280 void MostVisitedHandler::RegisterProfilePrefs( |
276 user_prefs::PrefRegistrySyncable* registry) { | 281 user_prefs::PrefRegistrySyncable* registry) { |
277 registry->RegisterDictionaryPref( | 282 registry->RegisterDictionaryPref( |
278 prefs::kNtpMostVisitedURLsBlacklist, | 283 prefs::kNtpMostVisitedURLsBlacklist, |
279 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 284 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
280 } | 285 } |
OLD | NEW |