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

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: Fix nits, rebase. 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
« no previous file with comments | « chrome/browser/sync/glue/synced_session.h ('k') | chrome/browser/sync/glue/synced_session_tracker.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5cfb4237c46d787d116ffb2577d790cbe84125b8 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,38 @@ 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++;
+ }
+ return (num_populated == 0);
}
} // namespace browser_sync
« no previous file with comments | « chrome/browser/sync/glue/synced_session.h ('k') | chrome/browser/sync/glue/synced_session_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698