Index: chrome/browser/sync/glue/synced_session_tracker.cc |
diff --git a/chrome/browser/sync/glue/synced_session_tracker.cc b/chrome/browser/sync/glue/synced_session_tracker.cc |
index 1a31dca5341c6d966b59b17e7128326d2228837c..fa50e312698559a24b7aa7298ae38cac2534c4a0 100644 |
--- a/chrome/browser/sync/glue/synced_session_tracker.cc |
+++ b/chrome/browser/sync/glue/synced_session_tracker.cc |
@@ -7,13 +7,33 @@ |
#include "base/logging.h" |
#include "base/stl_util.h" |
#include "base/strings/utf_string_conversions.h" |
-#include "chrome/browser/sync/glue/synced_session_util.h" |
+#include "components/sync_sessions/sync_sessions_client.h" |
namespace browser_sync { |
-SyncedSessionTracker::SyncedSessionTracker() { |
+namespace { |
+ |
+// Helper for iterating through all tabs within a window, and all navigations |
+// within a tab, to find if there's a valid syncable url. |
+bool ShouldSyncSessionWindow( |
+ sync_sessions::SyncSessionsClient* sessions_client, |
+ const sessions::SessionWindow& window) { |
+ for (auto* tab : window.tabs) { |
pavely
2015/10/16 21:55:20
Optional comment:
I think in both "for" loops you
Bernhard Bauer
2015/10/19 08:20:57
+1 for spelling out types.
Nicolas Zea
2015/10/20 23:14:41
Done.
Nicolas Zea
2015/10/20 23:14:41
Acknowledged.
|
+ for (auto&& navigation : tab->navigations) { |
+ if (sessions_client->ShouldSyncURL(navigation.virtual_url())) { |
+ return true; |
+ } |
+ } |
+ } |
+ return false; |
} |
+} // namespace |
+ |
+SyncedSessionTracker::SyncedSessionTracker( |
+ sync_sessions::SyncSessionsClient* sessions_client) |
+ : sessions_client_(sessions_client) {} |
+ |
SyncedSessionTracker::~SyncedSessionTracker() { |
Clear(); |
} |
@@ -37,7 +57,7 @@ bool SyncedSessionTracker::LookupAllForeignSessions( |
for (sync_driver::SyncedSession::SyncedWindowMap::const_iterator iter = |
foreign_session->windows.begin(); |
iter != foreign_session->windows.end(); ++iter) { |
- if (ShouldSyncSessionWindow(*(iter->second))) { |
+ if (ShouldSyncSessionWindow(sessions_client_, *(iter->second))) { |
found_tabs = true; |
break; |
} |