OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_SYNC_GLUE_SYNCED_SESSION_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_SYNCED_SESSION_H_ |
6 #define CHROME_BROWSER_SYNC_GLUE_SYNCED_SESSION_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_SYNCED_SESSION_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include <map> |
9 #include <string> | 10 #include <string> |
10 #include <vector> | |
11 | 11 |
| 12 #include "chrome/browser/sessions/session_id.h" |
| 13 |
| 14 struct SessionTab; |
12 struct SessionWindow; | 15 struct SessionWindow; |
13 | 16 |
14 namespace browser_sync { | 17 namespace browser_sync { |
15 | 18 |
16 // Defines a synced session for use by session sync. A synced session is a | 19 // Defines a synced session for use by session sync. A synced session is a |
17 // list of windows along with a unique session identifer (tag) and meta-data | 20 // list of windows along with a unique session identifer (tag) and meta-data |
18 // about the device being synced. | 21 // about the device being synced. |
19 struct SyncedSession { | 22 struct SyncedSession { |
| 23 typedef std::map<SessionID::id_type, SessionWindow*> SyncedWindowMap; |
| 24 |
20 // The type of device. | 25 // The type of device. |
21 enum DeviceType { | 26 enum DeviceType { |
22 TYPE_UNSET = 0, | 27 TYPE_UNSET = 0, |
23 TYPE_WIN = 1, | 28 TYPE_WIN = 1, |
24 TYPE_MACOSX = 2, | 29 TYPE_MACOSX = 2, |
25 TYPE_LINUX = 3, | 30 TYPE_LINUX = 3, |
26 TYPE_CHROMEOS = 4, | 31 TYPE_CHROMEOS = 4, |
27 TYPE_OTHER = 5 | 32 TYPE_OTHER = 5 |
28 }; | 33 }; |
29 | 34 |
30 SyncedSession(); | 35 SyncedSession(); |
31 ~SyncedSession(); | 36 ~SyncedSession(); |
32 | 37 |
33 // Unique tag for each session. | 38 // Unique tag for each session. |
34 std::string session_tag; | 39 std::string session_tag; |
35 // User-visible name | 40 // User-visible name |
36 std::string session_name; | 41 std::string session_name; |
| 42 |
| 43 // Type of device this session is from. |
37 DeviceType device_type; | 44 DeviceType device_type; |
38 std::vector<SessionWindow*> windows; | 45 |
| 46 // Map of windows that make up this session. Windowws are owned by the session |
| 47 // itself and free'd on destruction. |
| 48 SyncedWindowMap windows; |
| 49 |
| 50 private: |
| 51 DISALLOW_COPY_AND_ASSIGN(SyncedSession); |
39 }; | 52 }; |
40 | 53 |
| 54 // Control which foreign tabs we're interested in syncing/displaying. Checks |
| 55 // that the tab has navigations and is not a new tab (url == NTP). |
| 56 // Note: A new tab page with back/forward history is valid. |
| 57 bool IsValidSessionTab(const SessionTab& tab); |
| 58 |
| 59 // Checks whether the window has tabs to sync. If no tabs to sync, it returns |
| 60 // true, false otherwise. |
| 61 bool SessionWindowHasNoTabsToSync(const SessionWindow& window); |
| 62 |
41 } // namespace browser_sync | 63 } // namespace browser_sync |
42 | 64 |
43 #endif // CHROME_BROWSER_SYNC_GLUE_SYNCED_SESSION_H_ | 65 #endif // CHROME_BROWSER_SYNC_GLUE_SYNCED_SESSION_H_ |
OLD | NEW |