| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/sync_sessions/sessions_sync_manager.h" | 5 #include "components/sync_sessions/sessions_sync_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 DVLOG(1) << "Associating window " << window_id << " with " | 238 DVLOG(1) << "Associating window " << window_id << " with " |
| 239 << (*i)->GetTabCount() << " tabs."; | 239 << (*i)->GetTabCount() << " tabs."; |
| 240 window_s.set_window_id(window_id); | 240 window_s.set_window_id(window_id); |
| 241 // Note: We don't bother to set selected tab index anymore. We still | 241 // Note: We don't bother to set selected tab index anymore. We still |
| 242 // consume it when receiving foreign sessions, as reading it is free, but | 242 // consume it when receiving foreign sessions, as reading it is free, but |
| 243 // it triggers too many sync cycles with too little value to make setting | 243 // it triggers too many sync cycles with too little value to make setting |
| 244 // it worthwhile. | 244 // it worthwhile. |
| 245 if ((*i)->IsTypeTabbed()) { | 245 if ((*i)->IsTypeTabbed()) { |
| 246 window_s.set_browser_type( | 246 window_s.set_browser_type( |
| 247 sync_pb::SessionWindow_BrowserType_TYPE_TABBED); | 247 sync_pb::SessionWindow_BrowserType_TYPE_TABBED); |
| 248 } else { | 248 } else if ((*i)->IsTypePopup()) { |
| 249 window_s.set_browser_type( | 249 window_s.set_browser_type( |
| 250 sync_pb::SessionWindow_BrowserType_TYPE_POPUP); | 250 sync_pb::SessionWindow_BrowserType_TYPE_POPUP); |
| 251 } else { |
| 252 // This is a custom tab within an app. These will not be restored on |
| 253 // startup if not present. |
| 254 window_s.set_browser_type( |
| 255 sync_pb::SessionWindow_BrowserType_TYPE_CUSTOM_TAB); |
| 251 } | 256 } |
| 252 | 257 |
| 253 bool found_tabs = false; | 258 bool found_tabs = false; |
| 254 for (int j = 0; j < (*i)->GetTabCount(); ++j) { | 259 for (int j = 0; j < (*i)->GetTabCount(); ++j) { |
| 255 SessionID::id_type tab_id = (*i)->GetTabIdAt(j); | 260 SessionID::id_type tab_id = (*i)->GetTabIdAt(j); |
| 256 SyncedTabDelegate* synced_tab = (*i)->GetTabAt(j); | 261 SyncedTabDelegate* synced_tab = (*i)->GetTabAt(j); |
| 257 | 262 |
| 258 // GetTabAt can return a null tab; in that case just skip it. | 263 // GetTabAt can return a null tab; in that case just skip it. |
| 259 if (!synced_tab) | 264 if (!synced_tab) |
| 260 continue; | 265 continue; |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 session_window->window_id.set_id(specifics.window_id()); | 834 session_window->window_id.set_id(specifics.window_id()); |
| 830 if (specifics.has_selected_tab_index()) | 835 if (specifics.has_selected_tab_index()) |
| 831 session_window->selected_tab_index = specifics.selected_tab_index(); | 836 session_window->selected_tab_index = specifics.selected_tab_index(); |
| 832 if (specifics.has_browser_type()) { | 837 if (specifics.has_browser_type()) { |
| 833 // TODO(skuhne): Sync data writes |BrowserType| not | 838 // TODO(skuhne): Sync data writes |BrowserType| not |
| 834 // |SessionWindow::WindowType|. This should get changed. | 839 // |SessionWindow::WindowType|. This should get changed. |
| 835 if (specifics.browser_type() == | 840 if (specifics.browser_type() == |
| 836 sync_pb::SessionWindow_BrowserType_TYPE_TABBED) { | 841 sync_pb::SessionWindow_BrowserType_TYPE_TABBED) { |
| 837 session_window->type = sessions::SessionWindow::TYPE_TABBED; | 842 session_window->type = sessions::SessionWindow::TYPE_TABBED; |
| 838 } else { | 843 } else { |
| 844 // Note: custom tabs are treated like popup windows on restore, as you can |
| 845 // restore a custom tab on a platform that doesn't support them. |
| 839 session_window->type = sessions::SessionWindow::TYPE_POPUP; | 846 session_window->type = sessions::SessionWindow::TYPE_POPUP; |
| 840 } | 847 } |
| 841 } | 848 } |
| 842 session_window->timestamp = mtime; | 849 session_window->timestamp = mtime; |
| 843 session_window->tabs.resize(specifics.tab_size()); | 850 session_window->tabs.resize(specifics.tab_size()); |
| 844 for (int i = 0; i < specifics.tab_size(); i++) { | 851 for (int i = 0; i < specifics.tab_size(); i++) { |
| 845 SessionID::id_type tab_id = specifics.tab(i); | 852 SessionID::id_type tab_id = specifics.tab(i); |
| 846 session_tracker_.PutTabInWindow(session_tag, session_window->window_id.id(), | 853 session_tracker_.PutTabInWindow(session_tag, session_window->window_id.id(), |
| 847 tab_id, i); | 854 tab_id, i); |
| 848 } | 855 } |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1125 } | 1132 } |
| 1126 | 1133 |
| 1127 // static | 1134 // static |
| 1128 std::string SessionsSyncManager::TagHashFromSpecifics( | 1135 std::string SessionsSyncManager::TagHashFromSpecifics( |
| 1129 const sync_pb::SessionSpecifics& specifics) { | 1136 const sync_pb::SessionSpecifics& specifics) { |
| 1130 return syncer::syncable::GenerateSyncableHash(syncer::SESSIONS, | 1137 return syncer::syncable::GenerateSyncableHash(syncer::SESSIONS, |
| 1131 TagFromSpecifics(specifics)); | 1138 TagFromSpecifics(specifics)); |
| 1132 } | 1139 } |
| 1133 | 1140 |
| 1134 }; // namespace sync_sessions | 1141 }; // namespace sync_sessions |
| OLD | NEW |