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

Unified Diff: chrome/browser/history/top_sites.cc

Issue 5088001: Add pyauto hook for getting and manipulating the data underneath the NTP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/test/functional
Patch Set: change hook, remove ntp_model Created 10 years, 1 month 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: chrome/browser/history/top_sites.cc
diff --git a/chrome/browser/history/top_sites.cc b/chrome/browser/history/top_sites.cc
index 8bdfe340f55137be2f2306364313fcb213dc564e..4cfc121b84bf4c1c6e7311dcb837ab147f1bcedb 100644
--- a/chrome/browser/history/top_sites.cc
+++ b/chrome/browser/history/top_sites.cc
@@ -440,6 +440,23 @@ void TopSites::DiffMostVisited(const MostVisitedURLList& old_list,
}
}
+CancelableRequestProvider::Handle TopSites::StartQueryForMostVisited() {
+ if (!profile_)
sky 2010/11/17 16:31:00 DCHECK(loaded_). Any pyauto test needing top site
kkania 2010/11/17 22:16:08 Done.
+ return NULL;
+
+ CancelableRequestProvider::Handle request_handle = NULL;
+ HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
+ // |hs| may be null during unit tests.
+ if (hs) {
+ request_handle = hs->QueryMostVisitedURLs(
sky 2010/11/17 16:31:00 return hs->...
kkania 2010/11/17 22:16:08 Done.
+ num_results_to_request_from_history(),
+ kDaysOfHistory,
+ &cancelable_consumer_,
+ NewCallback(this, &TopSites::OnTopSitesAvailableFromHistory));
+ }
+ return request_handle;
sky 2010/11/17 16:31:00 return NULL
kkania 2010/11/17 22:16:08 Done.
+}
+
TopSites::~TopSites() {
}
@@ -533,19 +550,8 @@ void TopSites::AddTemporaryThumbnail(const GURL& url,
temp_images_.push_back(image);
}
-void TopSites::StartQueryForMostVisited() {
- if (!profile_)
- return;
-
- HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
- // |hs| may be null during unit tests.
- if (hs) {
- hs->QueryMostVisitedURLs(
- num_results_to_request_from_history(),
- kDaysOfHistory,
- &cancelable_consumer_,
- NewCallback(this, &TopSites::OnTopSitesAvailableFromHistory));
- }
+void TopSites::TimerFired() {
+ StartQueryForMostVisited();
}
// static
@@ -844,7 +850,7 @@ void TopSites::RestartQueryForTopSitesTimer(base::TimeDelta delta) {
timer_start_time_ = base::TimeTicks::Now();
timer_.Stop();
- timer_.Start(delta, this, &TopSites::StartQueryForMostVisited);
+ timer_.Start(delta, this, &TopSites::TimerFired);
}
void TopSites::OnHistoryMigrationWrittenToDisk(TopSitesBackend::Handle handle) {
@@ -902,6 +908,12 @@ void TopSites::OnTopSitesAvailableFromHistory(
CancelableRequestProvider::Handle handle,
MostVisitedURLList pages) {
SetTopSites(pages);
+
+ // Used only in testing.
+ NotificationService::current()->Notify(
+ NotificationType::TOP_SITES_UPDATED,
+ Source<TopSites>(this),
+ Details<CancelableRequestProvider::Handle>(&handle));
}
} // namespace history

Powered by Google App Engine
This is Rietveld 408576698