Index: chrome/browser/ui/android/tab_model/tab_model.cc |
diff --git a/chrome/browser/ui/android/tab_model/tab_model.cc b/chrome/browser/ui/android/tab_model/tab_model.cc |
index 9ecf3722826323e598d2d3b35a94519b198c3d51..ba3591bc484bdf751d15420232674da7a440e8dc 100644 |
--- a/chrome/browser/ui/android/tab_model/tab_model.cc |
+++ b/chrome/browser/ui/android/tab_model/tab_model.cc |
@@ -8,12 +8,15 @@ |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/search_engines/search_terms_data.h" |
+#include "chrome/browser/sync/glue/synced_tab_delegate.h" |
#include "chrome/browser/sync/glue/synced_window_delegate_android.h" |
#include "chrome/browser/ui/toolbar/toolbar_model_impl.h" |
#include "chrome/common/chrome_notification_types.h" |
#include "content/public/browser/notification_service.h" |
using content::NotificationService; |
+using browser_sync::SyncedTabDelegate; |
+using browser_sync::SyncedWindowDelegate; |
TabModel::TabModel(Profile* profile) |
: profile_(profile), |
@@ -36,6 +39,9 @@ TabModel::TabModel(Profile* profile) |
content::Source<Profile>(profile_)); |
registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CREATED, |
content::NotificationService::AllSources()); |
+ registrar_.Add(this, |
+ chrome::NOTIFICATION_SESSION_SYNC_ID_GENERATED, |
+ content::NotificationService::AllSources()); |
} else { |
is_off_the_record_ = false; |
} |
@@ -130,6 +136,24 @@ void TabModel::Observe( |
profile_ = profile; |
} |
break; |
+ case chrome::NOTIFICATION_SESSION_SYNC_ID_GENERATED: { |
+ content::Details<const SyncedTabDelegate> tab(details); |
+ const SyncedWindowDelegate* sync_window_delegate = |
+ SyncedWindowDelegate::FindSyncedWindowDelegateWithId( |
+ tab->GetWindowId().id()); |
+ if (sync_window_delegate) { |
+ const int tab_count = sync_window_delegate->GetTabCount(); |
+ for (int i = 0; i < tab_count; ++i) { |
+ SyncedTabDelegate* sync_tab = sync_window_delegate->GetTabAt(i); |
+ // This may seem redundant, but it ensure Sync id is set in java. |
+ if (sync_tab && sync_tab->IsTabInMemory() && |
+ sync_tab->GetSyncSessionId() == tab->GetSyncSessionId()) { |
+ sync_tab->SetSyncSessionId(tab->GetSyncSessionId()); |
+ break; |
+ } |
+ } |
+ } |
+ } break; |
default: |
NOTREACHED(); |
} |