Index: chrome/browser/history/top_sites_factory.cc |
diff --git a/chrome/browser/history/top_sites_factory.cc b/chrome/browser/history/top_sites_factory.cc |
index b0e77b55ee94eb28289c986fa513eafb6cd28dba..c88f4ec37be292b9f340a1162acc906c9c54812f 100644 |
--- a/chrome/browser/history/top_sites_factory.cc |
+++ b/chrome/browser/history/top_sites_factory.cc |
@@ -4,11 +4,51 @@ |
#include "chrome/browser/history/top_sites_factory.h" |
+#include "base/macros.h" |
#include "base/memory/singleton.h" |
#include "chrome/browser/history/top_sites_impl.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/common/chrome_constants.h" |
+#include "chrome/grit/chromium_strings.h" |
+#include "chrome/grit/generated_resources.h" |
+#include "chrome/grit/locale_settings.h" |
#include "components/keyed_service/content/browser_context_dependency_manager.h" |
+#include "content/public/browser/browser_thread.h" |
+#include "grit/theme_resources.h" |
+#include "ui/base/l10n/l10n_util.h" |
+#include "url/gurl.h" |
+ |
+namespace { |
+ |
+struct RawPrepopulatedPage { |
+ int url_id; // The resource for the page URL. |
+ int title_id; // The resource for the page title. |
+ int favicon_id; // The raw data resource for the favicon. |
+ int thumbnail_id; // The raw data resource for the thumbnail. |
+ SkColor color; // The best color to highlight the page (should roughly |
+ // match favicon). |
+}; |
+ |
+const RawPrepopulatedPage kRawPrepopulatedPages[] = { |
+#if !defined(OS_ANDROID) |
+ { |
+ IDS_CHROME_WELCOME_URL, |
+ IDS_NEW_TAB_CHROME_WELCOME_PAGE_TITLE, |
+ IDR_PRODUCT_LOGO_16, |
+ IDR_NEWTAB_CHROME_WELCOME_PAGE_THUMBNAIL, |
+ SkColorSetRGB(0, 147, 60), |
+ }, |
+ { |
+ IDS_WEBSTORE_URL, |
+ IDS_EXTENSION_WEB_STORE_TITLE, |
+ IDR_WEBSTORE_ICON_16, |
+ IDR_NEWTAB_WEBSTORE_THUMBNAIL, |
+ SkColorSetRGB(63, 132, 197), |
+ } |
+#endif |
+}; |
+ |
+} // namespace |
// static |
scoped_refptr<history::TopSites> TopSitesFactory::GetForProfile( |
@@ -40,9 +80,21 @@ TopSitesFactory::~TopSitesFactory() { |
scoped_refptr<RefcountedKeyedService> TopSitesFactory::BuildServiceInstanceFor( |
content::BrowserContext* context) const { |
- history::TopSitesImpl* top_sites = |
- new history::TopSitesImpl(static_cast<Profile*>(context)); |
- top_sites->Init(context->GetPath().Append(chrome::kTopSitesFilename)); |
+ history::PrepopulatedPageList prepopulated_pages; |
+ prepopulated_pages.resize(arraysize(kRawPrepopulatedPages)); |
+ for (size_t i = 0; i < arraysize(kRawPrepopulatedPages); ++i) { |
droger
2015/01/27 10:08:36
optional nit:
use some temporary variable here for
sdefresne
2015/01/27 13:55:16
Done.
|
+ prepopulated_pages[i] = history::PrepopulatedPage( |
+ GURL(l10n_util::GetStringUTF8(kRawPrepopulatedPages[i].url_id)), |
+ l10n_util::GetStringUTF16(kRawPrepopulatedPages[i].title_id), |
+ kRawPrepopulatedPages[i].favicon_id, |
+ kRawPrepopulatedPages[i].thumbnail_id, kRawPrepopulatedPages[i].color); |
+ } |
+ |
+ history::TopSitesImpl* top_sites = new history::TopSitesImpl( |
+ static_cast<Profile*>(context), prepopulated_pages); |
+ top_sites->Init(context->GetPath().Append(chrome::kTopSitesFilename), |
+ content::BrowserThread::GetMessageLoopProxyForThread( |
+ content::BrowserThread::DB)); |
return make_scoped_refptr(top_sites); |
} |