| 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" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "chrome/browser/history/top_sites.h" | 25 #include "chrome/browser/history/top_sites.h" |
| 26 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 26 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 27 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
| 28 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
| 29 #include "chrome/browser/ui/browser_finder.h" | 29 #include "chrome/browser/ui/browser_finder.h" |
| 30 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 30 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 31 #include "chrome/browser/ui/tabs/tab_strip_model_utils.h" | 31 #include "chrome/browser/ui/tabs/tab_strip_model_utils.h" |
| 32 #include "chrome/browser/ui/webui/favicon_source.h" | 32 #include "chrome/browser/ui/webui/favicon_source.h" |
| 33 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 33 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
| 34 #include "chrome/browser/ui/webui/ntp/ntp_stats.h" | 34 #include "chrome/browser/ui/webui/ntp/ntp_stats.h" |
| 35 #include "chrome/browser/ui/webui/ntp/thumbnail_list_source.h" |
| 35 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" | 36 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" |
| 36 #include "chrome/common/pref_names.h" | 37 #include "chrome/common/pref_names.h" |
| 37 #include "chrome/common/url_constants.h" | 38 #include "chrome/common/url_constants.h" |
| 38 #include "components/user_prefs/pref_registry_syncable.h" | 39 #include "components/user_prefs/pref_registry_syncable.h" |
| 39 #include "content/public/browser/navigation_controller.h" | 40 #include "content/public/browser/navigation_controller.h" |
| 40 #include "content/public/browser/navigation_entry.h" | 41 #include "content/public/browser/navigation_entry.h" |
| 41 #include "content/public/browser/notification_source.h" | 42 #include "content/public/browser/notification_source.h" |
| 42 #include "content/public/browser/url_data_source.h" | 43 #include "content/public/browser/url_data_source.h" |
| 43 #include "content/public/browser/user_metrics.h" | 44 #include "content/public/browser/user_metrics.h" |
| 44 #include "content/public/browser/web_contents.h" | 45 #include "content/public/browser/web_contents.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 70 } | 71 } |
| 71 | 72 |
| 72 UMA_HISTOGRAM_ENUMERATION("NewTabPage.MostVisitedAction", action_id, | 73 UMA_HISTOGRAM_ENUMERATION("NewTabPage.MostVisitedAction", action_id, |
| 73 NUM_NTP_FOLLOW_ACTIONS); | 74 NUM_NTP_FOLLOW_ACTIONS); |
| 74 } | 75 } |
| 75 } | 76 } |
| 76 | 77 |
| 77 void MostVisitedHandler::RegisterMessages() { | 78 void MostVisitedHandler::RegisterMessages() { |
| 78 Profile* profile = Profile::FromWebUI(web_ui()); | 79 Profile* profile = Profile::FromWebUI(web_ui()); |
| 79 // Set up our sources for thumbnail and favicon data. | 80 // Set up our sources for thumbnail and favicon data. |
| 80 ThumbnailSource* thumbnail_src_exact = new ThumbnailSource(profile, false); | 81 content::URLDataSource::Add(profile, new ThumbnailSource(profile, false)); |
| 81 content::URLDataSource::Add(profile, thumbnail_src_exact); | 82 content::URLDataSource::Add(profile, new ThumbnailSource(profile, true)); |
| 82 | 83 |
| 83 ThumbnailSource* thumbnail_src_prefix = new ThumbnailSource(profile, true); | 84 // Set up our sources for top-sites data. |
| 84 content::URLDataSource::Add(profile, thumbnail_src_prefix); | 85 content::URLDataSource::Add(profile, new ThumbnailListSource(profile)); |
| 85 | 86 |
| 86 #if defined(OS_ANDROID) | 87 #if defined(OS_ANDROID) |
| 87 // Register chrome://touch-icon as a data source for touch icons or favicons. | 88 // Register chrome://touch-icon as a data source for touch icons or favicons. |
| 88 content::URLDataSource::Add(profile, | 89 content::URLDataSource::Add(profile, |
| 89 new FaviconSource(profile, FaviconSource::ANY)); | 90 new FaviconSource(profile, FaviconSource::ANY)); |
| 90 #endif | 91 #endif |
| 91 // Register chrome://favicon as a data source for favicons. | 92 // Register chrome://favicon as a data source for favicons. |
| 92 content::URLDataSource::Add( | 93 content::URLDataSource::Add( |
| 93 profile, new FaviconSource(profile, FaviconSource::FAVICON)); | 94 profile, new FaviconSource(profile, FaviconSource::FAVICON)); |
| 94 | 95 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 #endif | 296 #endif |
| 296 } | 297 } |
| 297 | 298 |
| 298 // static | 299 // static |
| 299 void MostVisitedHandler::RegisterProfilePrefs( | 300 void MostVisitedHandler::RegisterProfilePrefs( |
| 300 user_prefs::PrefRegistrySyncable* registry) { | 301 user_prefs::PrefRegistrySyncable* registry) { |
| 301 registry->RegisterDictionaryPref( | 302 registry->RegisterDictionaryPref( |
| 302 prefs::kNtpMostVisitedURLsBlacklist, | 303 prefs::kNtpMostVisitedURLsBlacklist, |
| 303 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 304 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 304 } | 305 } |
| OLD | NEW |