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

Unified Diff: chrome/browser/ui/webui/ntp/favicon_webui_handler.cc

Issue 870063002: Componentize TopSites, TopSitesBackend, TopSitesDatabase (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@815983002
Patch Set: Fix typo Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/favicon_source.cc ('k') | chrome/browser/ui/webui/ntp/most_visited_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/ntp/favicon_webui_handler.cc
diff --git a/chrome/browser/ui/webui/ntp/favicon_webui_handler.cc b/chrome/browser/ui/webui/ntp/favicon_webui_handler.cc
index 20cfe1aadcfb132c1145a288e3068e70f53b2171..a07e6599f8131096c956fd2fa9fd66d35c41c588 100644
--- a/chrome/browser/ui/webui/ntp/favicon_webui_handler.cc
+++ b/chrome/browser/ui/webui/ntp/favicon_webui_handler.cc
@@ -13,9 +13,10 @@
#include "chrome/browser/extensions/extension_icon_manager.h"
#include "chrome/browser/favicon/favicon_service.h"
#include "chrome/browser/favicon/favicon_service_factory.h"
-#include "chrome/browser/history/top_sites.h"
+#include "chrome/browser/history/top_sites_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/url_constants.h"
+#include "components/history/core/browser/top_sites.h"
#include "content/public/browser/web_ui.h"
#include "extensions/browser/extension_registry.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -96,16 +97,19 @@ void FaviconWebUIHandler::HandleGetFaviconDominantColor(
return;
GURL url(path);
- // Intercept requests for prepopulated pages.
- for (size_t i = 0; i < history::kPrepopulatedPagesCount; i++) {
- if (url.spec() ==
- l10n_util::GetStringUTF8(history::kPrepopulatedPages[i].url_id)) {
- base::StringValue dom_id_value(dom_id);
- scoped_ptr<base::StringValue> color(
- SkColorToCss(history::kPrepopulatedPages[i].color));
- web_ui()->CallJavascriptFunction("ntp.setFaviconDominantColor",
- dom_id_value, *color);
- return;
+ // Intercept requests for prepopulated pages if TopSites exists.
+ scoped_refptr<history::TopSites> top_sites =
+ TopSitesFactory::GetForProfile(Profile::FromWebUI(web_ui()));
+ if (top_sites) {
+ for (const auto& prepopulated_page : top_sites->GetPrepopulatedPages()) {
+ if (url == prepopulated_page.most_visited.url) {
+ base::StringValue dom_id_value(dom_id);
+ scoped_ptr<base::StringValue> color(
+ SkColorToCss(prepopulated_page.color));
+ web_ui()->CallJavascriptFunction("ntp.setFaviconDominantColor",
+ dom_id_value, *color);
+ return;
+ }
}
}
« no previous file with comments | « chrome/browser/ui/webui/favicon_source.cc ('k') | chrome/browser/ui/webui/ntp/most_visited_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698