| 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/history/top_sites_factory.h" | 23 #include "chrome/browser/history/top_sites_factory.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/thumbnails/thumbnail_list_source.h" | 25 #include "chrome/browser/thumbnails/thumbnail_list_source.h" |
| 26 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
| 27 #include "chrome/browser/ui/browser_finder.h" | 27 #include "chrome/browser/ui/browser_finder.h" |
| 28 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 28 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 29 #include "chrome/browser/ui/tabs/tab_strip_model_utils.h" | 29 #include "chrome/browser/ui/tabs/tab_strip_model_utils.h" |
| 30 #include "chrome/browser/ui/webui/big_icon_source.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" |
| 39 #include "components/pref_registry/pref_registry_syncable.h" | 40 #include "components/pref_registry/pref_registry_syncable.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 74 |
| 74 void MostVisitedHandler::RegisterMessages() { | 75 void MostVisitedHandler::RegisterMessages() { |
| 75 Profile* profile = Profile::FromWebUI(web_ui()); | 76 Profile* profile = Profile::FromWebUI(web_ui()); |
| 76 // Set up our sources for thumbnail and favicon data. | 77 // Set up our sources for thumbnail and favicon data. |
| 77 content::URLDataSource::Add(profile, new ThumbnailSource(profile, false)); | 78 content::URLDataSource::Add(profile, new ThumbnailSource(profile, false)); |
| 78 content::URLDataSource::Add(profile, new ThumbnailSource(profile, true)); | 79 content::URLDataSource::Add(profile, new ThumbnailSource(profile, true)); |
| 79 | 80 |
| 80 // Set up our sources for top-sites data. | 81 // Set up our sources for top-sites data. |
| 81 content::URLDataSource::Add(profile, new ThumbnailListSource(profile)); | 82 content::URLDataSource::Add(profile, new ThumbnailListSource(profile)); |
| 82 | 83 |
| 84 // Register chrome://big-icon as a data source for big icons. |
| 85 content::URLDataSource::Add(profile, new BigIconSource(profile)); |
| 86 |
| 83 // Register chrome://fallback-icon as a data source for fallback icons. | 87 // Register chrome://fallback-icon as a data source for fallback icons. |
| 84 content::URLDataSource::Add(profile, new FallbackIconSource()); | 88 content::URLDataSource::Add(profile, new FallbackIconSource()); |
| 85 | 89 |
| 86 // Register chrome://favicon as a data source for favicons. | 90 // Register chrome://favicon as a data source for favicons. |
| 87 content::URLDataSource::Add( | 91 content::URLDataSource::Add( |
| 88 profile, new FaviconSource(profile, FaviconSource::FAVICON)); | 92 profile, new FaviconSource(profile, FaviconSource::FAVICON)); |
| 89 | 93 |
| 90 scoped_refptr<history::TopSites> top_sites = | 94 scoped_refptr<history::TopSites> top_sites = |
| 91 TopSitesFactory::GetForProfile(profile); | 95 TopSitesFactory::GetForProfile(profile); |
| 92 if (top_sites) { | 96 if (top_sites) { |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 return base::MD5String(url); | 275 return base::MD5String(url); |
| 272 } | 276 } |
| 273 | 277 |
| 274 // static | 278 // static |
| 275 void MostVisitedHandler::RegisterProfilePrefs( | 279 void MostVisitedHandler::RegisterProfilePrefs( |
| 276 user_prefs::PrefRegistrySyncable* registry) { | 280 user_prefs::PrefRegistrySyncable* registry) { |
| 277 registry->RegisterDictionaryPref( | 281 registry->RegisterDictionaryPref( |
| 278 prefs::kNtpMostVisitedURLsBlacklist, | 282 prefs::kNtpMostVisitedURLsBlacklist, |
| 279 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 283 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 280 } | 284 } |
| OLD | NEW |