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

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

Issue 9864041: Sync: Ordering of Other Devices menu should be reverse chronological. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/ntp/foreign_session_handler.cc
diff --git a/chrome/browser/ui/webui/ntp/foreign_session_handler.cc b/chrome/browser/ui/webui/ntp/foreign_session_handler.cc
index b9d9e56b9f972ef7b2de12fac6788c87d948f019..1a2f0dc737c8b19ce9cddc94bb36ea0e742dde56 100644
--- a/chrome/browser/ui/webui/ntp/foreign_session_handler.cc
+++ b/chrome/browser/ui/webui/ntp/foreign_session_handler.cc
@@ -33,6 +33,16 @@ static const size_t kMaxSessionsToShow = 10;
// Invalid value, used to note that we don't have a tab or window number.
static const int kInvalidId = -1;
+namespace {
+
+// Comparator function for use with std::sort that will sort sessions by
+// descending modified_time (i.e., most recent first).
+bool SortSessionsByRecency(const SyncedSession* s1, const SyncedSession* s2) {
+ return s1->modified_time > s2->modified_time;
+}
+
+} // namepace
+
ForeignSessionHandler::ForeignSessionHandler() {
}
@@ -100,6 +110,9 @@ void ForeignSessionHandler::HandleGetForeignSessions(const ListValue* args) {
ListValue session_list;
if (associator && associator->GetAllForeignSessions(&sessions)) {
+ // Sort sessions from most recent to least recent.
+ std::sort(sessions.begin(), sessions.end(), SortSessionsByRecency);
+
// Note: we don't own the SyncedSessions themselves.
for (size_t i = 0; i < sessions.size() && i < kMaxSessionsToShow; ++i) {
const SyncedSession* session = sessions[i];
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698