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

Unified Diff: components/history/core/browser/top_sites.h

Issue 870063002: Componentize TopSites, TopSitesBackend, TopSitesDatabase (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@815983002
Patch Set: 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
Index: components/history/core/browser/top_sites.h
diff --git a/chrome/browser/history/top_sites.h b/components/history/core/browser/top_sites.h
similarity index 86%
rename from chrome/browser/history/top_sites.h
rename to components/history/core/browser/top_sites.h
index c27c1dce5749c22ccccbe2c5e34cb46283bbcd05..6302cfe47dec105a3fb52a3e7a805e52a61a4306 100644
--- a/chrome/browser/history/top_sites.h
+++ b/components/history/core/browser/top_sites.h
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_HISTORY_TOP_SITES_H_
-#define CHROME_BROWSER_HISTORY_TOP_SITES_H_
+#ifndef COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_H_
+#define COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_H_
+
+#include <vector>
#include "base/basictypes.h"
#include "base/callback.h"
@@ -14,12 +16,10 @@
#include "components/history/core/browser/top_sites_observer.h"
#include "components/history/core/common/thumbnail_score.h"
#include "components/keyed_service/core/refcounted_keyed_service.h"
-#include "content/public/browser/notification_observer.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/image/image.h"
class GURL;
-class Profile;
namespace base {
class FilePath;
@@ -31,20 +31,35 @@ namespace history {
class TopSitesCache;
+// PrepopulatedPage stores information for prepopulated page for the
+// initial run.
+struct PrepopulatedPage {
+ PrepopulatedPage();
+ PrepopulatedPage(const GURL& url,
+ const base::string16& title,
+ int favicon_id,
+ int thumbnail_id,
+ SkColor color);
+
+ MostVisitedURL url; // The prepopulated page URL and title.
droger 2015/01/27 10:08:37 Should this be: MostVisitedURL most_visited; or Mo
sdefresne 2015/01/27 13:55:16 Done.
+ 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).
+};
+
+typedef std::vector<PrepopulatedPage> PrepopulatedPageList;
+
// Interface for TopSites, which stores the data for the top "most visited"
// sites. This includes a cache of the most visited data from history, as well
// as the corresponding thumbnails of those sites.
//
// Some methods should only be called from the UI thread (see method
// descriptions below). All others are assumed to be threadsafe.
-class TopSites : public RefcountedKeyedService,
- public content::NotificationObserver {
+class TopSites : public RefcountedKeyedService {
public:
TopSites();
- // Initializes TopSites.
- static TopSites* Create(Profile* profile, const base::FilePath& db_name);
-
// Sets the given thumbnail for the given URL. Returns true if the thumbnail
// was updated. False means either the URL wasn't known to us, or we felt
// that our current thumbnail was superior to the given one. Should be called
@@ -145,7 +160,7 @@ class TopSites : public RefcountedKeyedService,
virtual bool loaded() const = 0;
// Returns the set of prepopulate pages.
- virtual MostVisitedURLList GetPrepopulatePages() = 0;
+ virtual PrepopulatedPageList GetPrepopulatedPages() = 0;
// Adds or updates a |url| for which we should force the capture of a
// thumbnail next time it's visited. If there is already a non-forced URL
@@ -154,19 +169,6 @@ class TopSites : public RefcountedKeyedService,
// called from the UI thread.
virtual bool AddForcedURL(const GURL& url, const base::Time& time) = 0;
- struct PrepopulatedPage {
- // The string resource for the url.
- int url_id;
- // The string resource for the page title.
- int title_id;
- // The raw data resource for the favicon.
- int favicon_id;
- // The raw data resource for the thumbnail.
- int thumbnail_id;
- // The best color to highlight the page (should roughly match favicon).
- SkColor color;
- };
-
// Add Observer to the list.
void AddObserver(TopSitesObserver* observer);
@@ -183,14 +185,6 @@ class TopSites : public RefcountedKeyedService,
friend class base::RefCountedThreadSafe<TopSites>;
};
-#if defined(OS_ANDROID)
-const int kPrepopulatedPagesCount = 0;
-#else
-const int kPrepopulatedPagesCount = 2;
-#endif
-extern const TopSites::PrepopulatedPage
- kPrepopulatedPages[kPrepopulatedPagesCount];
-
} // namespace history
-#endif // CHROME_BROWSER_HISTORY_TOP_SITES_H_
+#endif // COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_H_

Powered by Google App Engine
This is Rietveld 408576698