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 |