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

Unified Diff: chrome/browser/sync/glue/synced_session.cc

Issue 7966020: [Sync] Fix Session's handling of windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments Created 9 years, 2 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: chrome/browser/sync/glue/synced_session.cc
diff --git a/chrome/browser/sync/glue/synced_session.cc b/chrome/browser/sync/glue/synced_session.cc
index b1b3c304bf42da4c5ee47befdb301a773b451513..f21c9791831780d5f88966e75ee5c4b753735b9a 100644
--- a/chrome/browser/sync/glue/synced_session.cc
+++ b/chrome/browser/sync/glue/synced_session.cc
@@ -6,6 +6,7 @@
#include "base/stl_util.h"
#include "chrome/browser/sessions/session_types.h"
+#include "chrome/common/url_constants.h"
namespace browser_sync {
@@ -14,7 +15,40 @@ SyncedSession::SyncedSession() : session_tag("invalid"),
}
SyncedSession::~SyncedSession() {
- STLDeleteElements(&windows);
+ STLDeleteContainerPairSecondPointers(windows.begin(), windows.end());
+}
+
+// Note: if you modify this, make sure you modify IsValidTab in
+// SessionModelAssociator.
+bool IsValidSessionTab(const SessionTab& tab) {
+ if (tab.navigations.empty())
+ return false;
+ int selected_index = tab.current_navigation_index;
+ selected_index = std::max(
+ 0,
+ std::min(selected_index,
+ static_cast<int>(tab.navigations.size() - 1)));
+ if (selected_index == 0 &&
+ tab.navigations.size() == 1 &&
+ tab.navigations.at(selected_index).virtual_url().GetOrigin() ==
+ GURL(chrome::kChromeUINewTabURL)) {
+ // This is a new tab with no further history, skip.
+ return false;
+ }
+ return true;
+}
+
+bool SessionWindowHasNoTabsToSync(const SessionWindow& window) {
+ int num_populated = 0;
+ for (std::vector<SessionTab*>::const_iterator i = window.tabs.begin();
+ i != window.tabs.end(); ++i) {
+ const SessionTab* tab = *i;
+ if (IsValidSessionTab(*tab))
+ num_populated++;
+ }
+ if (num_populated == 0)
akalin 2011/10/03 18:50:21 return (num_populated == 0);
Nicolas Zea 2011/10/03 19:36:15 Done.
+ return true;
+ return false;
}
} // namespace browser_sync

Powered by Google App Engine
This is Rietveld 408576698