Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(624)

Side by Side Diff: chrome/browser/ui/webui/ntp/most_visited_handler.cc

Issue 1092873002: [Icons NTP] Refactor large_icon_source to extract the logic shared between desktop and Android to f… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/large_icon_service_factory.h"
25 #include "chrome/browser/history/top_sites_factory.h" 25 #include "chrome/browser/history/top_sites_factory.h"
26 #include "chrome/browser/profiles/profile.h" 26 #include "chrome/browser/profiles/profile.h"
27 #include "chrome/browser/thumbnails/thumbnail_list_source.h" 27 #include "chrome/browser/thumbnails/thumbnail_list_source.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/fallback_icon_source.h" 32 #include "chrome/browser/ui/webui/fallback_icon_source.h"
33 #include "chrome/browser/ui/webui/favicon_source.h" 33 #include "chrome/browser/ui/webui/favicon_source.h"
34 #include "chrome/browser/ui/webui/large_icon_source.h" 34 #include "chrome/browser/ui/webui/large_icon_source.h"
35 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" 35 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
36 #include "chrome/browser/ui/webui/ntp/ntp_stats.h" 36 #include "chrome/browser/ui/webui/ntp/ntp_stats.h"
37 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" 37 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h"
38 #include "chrome/common/pref_names.h" 38 #include "chrome/common/pref_names.h"
39 #include "chrome/common/url_constants.h" 39 #include "chrome/common/url_constants.h"
40 #include "components/favicon/core/fallback_icon_service.h" 40 #include "components/favicon/core/fallback_icon_service.h"
41 #include "components/favicon/core/favicon_service.h" 41 #include "components/favicon/core/large_icon_service.h"
42 #include "components/history/core/browser/page_usage_data.h" 42 #include "components/history/core/browser/page_usage_data.h"
43 #include "components/history/core/browser/top_sites.h" 43 #include "components/history/core/browser/top_sites.h"
44 #include "components/keyed_service/core/service_access_type.h" 44 #include "components/keyed_service/core/service_access_type.h"
45 #include "components/pref_registry/pref_registry_syncable.h" 45 #include "components/pref_registry/pref_registry_syncable.h"
46 #include "content/public/browser/navigation_controller.h" 46 #include "content/public/browser/navigation_controller.h"
47 #include "content/public/browser/navigation_entry.h" 47 #include "content/public/browser/navigation_entry.h"
48 #include "content/public/browser/url_data_source.h" 48 #include "content/public/browser/url_data_source.h"
49 #include "content/public/browser/user_metrics.h" 49 #include "content/public/browser/user_metrics.h"
50 #include "content/public/browser/web_contents.h" 50 #include "content/public/browser/web_contents.h"
51 #include "content/public/browser/web_ui.h" 51 #include "content/public/browser/web_ui.h"
(...skipping 27 matching lines...) Expand all
79 79
80 void MostVisitedHandler::RegisterMessages() { 80 void MostVisitedHandler::RegisterMessages() {
81 Profile* profile = Profile::FromWebUI(web_ui()); 81 Profile* profile = Profile::FromWebUI(web_ui());
82 // Set up our sources for thumbnail and favicon data. 82 // Set up our sources for thumbnail and favicon data.
83 content::URLDataSource::Add(profile, new ThumbnailSource(profile, false)); 83 content::URLDataSource::Add(profile, new ThumbnailSource(profile, false));
84 content::URLDataSource::Add(profile, new ThumbnailSource(profile, true)); 84 content::URLDataSource::Add(profile, new ThumbnailSource(profile, true));
85 85
86 // Set up our sources for top-sites data. 86 // Set up our sources for top-sites data.
87 content::URLDataSource::Add(profile, new ThumbnailListSource(profile)); 87 content::URLDataSource::Add(profile, new ThumbnailListSource(profile));
88 88
89 favicon::FaviconService* favicon_service =
90 FaviconServiceFactory::GetForProfile(profile,
91 ServiceAccessType::EXPLICIT_ACCESS);
92 favicon::FallbackIconService* fallback_icon_service = 89 favicon::FallbackIconService* fallback_icon_service =
93 FallbackIconServiceFactory::GetForBrowserContext(profile); 90 FallbackIconServiceFactory::GetForBrowserContext(profile);
91 favicon::LargeIconService* large_icon_service =
92 LargeIconServiceFactory::GetForBrowserContext(profile);
94 93
95 // Register chrome://large-icon as a data source for large icons. 94 // Register chrome://fallback-icon as a data source for fallback icons.
96 content::URLDataSource::Add(profile,
97 new LargeIconSource(favicon_service, fallback_icon_service));
98 content::URLDataSource::Add(profile, 95 content::URLDataSource::Add(profile,
99 new FallbackIconSource(fallback_icon_service)); 96 new FallbackIconSource(fallback_icon_service));
100 97
101 // Register chrome://favicon as a data source for favicons. 98 // Register chrome://favicon as a data source for favicons.
102 content::URLDataSource::Add( 99 content::URLDataSource::Add(
103 profile, new FaviconSource(profile, FaviconSource::FAVICON)); 100 profile, new FaviconSource(profile, FaviconSource::FAVICON));
104 101
102 // Register chrome://large-icon as a data source for large icons.
103 content::URLDataSource::Add(
104 profile, new LargeIconSource(fallback_icon_service, large_icon_service));
105
105 scoped_refptr<history::TopSites> top_sites = 106 scoped_refptr<history::TopSites> top_sites =
106 TopSitesFactory::GetForProfile(profile); 107 TopSitesFactory::GetForProfile(profile);
107 if (top_sites) { 108 if (top_sites) {
108 // TopSites updates itself after a delay. This is especially noticable when 109 // TopSites updates itself after a delay. This is especially noticable when
109 // your profile is empty. Ask TopSites to update itself when we're about to 110 // your profile is empty. Ask TopSites to update itself when we're about to
110 // show the new tab page. 111 // show the new tab page.
111 top_sites->SyncWithHistory(); 112 top_sites->SyncWithHistory();
112 113
113 // Register as TopSitesObserver so that we can update ourselves when the 114 // Register as TopSitesObserver so that we can update ourselves when the
114 // TopSites changes. 115 // TopSites changes.
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 return base::MD5String(url); 287 return base::MD5String(url);
287 } 288 }
288 289
289 // static 290 // static
290 void MostVisitedHandler::RegisterProfilePrefs( 291 void MostVisitedHandler::RegisterProfilePrefs(
291 user_prefs::PrefRegistrySyncable* registry) { 292 user_prefs::PrefRegistrySyncable* registry) {
292 registry->RegisterDictionaryPref( 293 registry->RegisterDictionaryPref(
293 prefs::kNtpMostVisitedURLsBlacklist, 294 prefs::kNtpMostVisitedURLsBlacklist,
294 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 295 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
295 } 296 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698