OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """An implementation of the server side of the Chromium sync protocol. | 5 """An implementation of the server side of the Chromium sync protocol. |
6 | 6 |
7 The details of the protocol are described mostly by comments in the protocol | 7 The details of the protocol are described mostly by comments in the protocol |
8 buffer definition at chrome/browser/sync/protocol/sync.proto. | 8 buffer definition at chrome/browser/sync/protocol/sync.proto. |
9 """ | 9 """ |
10 | 10 |
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 """ | 928 """ |
929 | 929 |
930 nigori_tag = "google_chrome_nigori" | 930 nigori_tag = "google_chrome_nigori" |
931 nigori_original = self._entries.get(self._ServerTagToId(nigori_tag)) | 931 nigori_original = self._entries.get(self._ServerTagToId(nigori_tag)) |
932 if (nigori_original.specifics.nigori.sync_tabs): | 932 if (nigori_original.specifics.nigori.sync_tabs): |
933 return | 933 return |
934 nigori_new = copy.deepcopy(nigori_original) | 934 nigori_new = copy.deepcopy(nigori_original) |
935 nigori_new.specifics.nigori.sync_tabs = True | 935 nigori_new.specifics.nigori.sync_tabs = True |
936 self._SaveEntry(nigori_new) | 936 self._SaveEntry(nigori_new) |
937 | 937 |
| 938 def TriggerSyncTabFavicons(self): |
| 939 """Set the 'sync_tab_favicons' field to this account's nigori node. |
| 940 |
| 941 If the field is not currently set, will write a new nigori node entry |
| 942 with the field set. Else does nothing. |
| 943 """ |
| 944 |
| 945 nigori_tag = "google_chrome_nigori" |
| 946 nigori_original = self._entries.get(self._ServerTagToId(nigori_tag)) |
| 947 if (nigori_original.specifics.nigori.sync_tab_favicons): |
| 948 return |
| 949 nigori_new = copy.deepcopy(nigori_original) |
| 950 nigori_new.specifics.nigori.sync_tab_favicons = True |
| 951 self._SaveEntry(nigori_new) |
| 952 |
938 def TriggerCreateSyncedBookmarks(self): | 953 def TriggerCreateSyncedBookmarks(self): |
939 """Create the Synced Bookmarks folder under the Bookmarks permanent item. | 954 """Create the Synced Bookmarks folder under the Bookmarks permanent item. |
940 | 955 |
941 Clients will then receive the Synced Bookmarks folder on future | 956 Clients will then receive the Synced Bookmarks folder on future |
942 GetUpdates, and new bookmarks can be added within the Synced Bookmarks | 957 GetUpdates, and new bookmarks can be added within the Synced Bookmarks |
943 folder. | 958 folder. |
944 """ | 959 """ |
945 | 960 |
946 synced_bookmarks_spec, = [spec for spec in self._PERMANENT_ITEM_SPECS | 961 synced_bookmarks_spec, = [spec for spec in self._PERMANENT_ITEM_SPECS |
947 if spec.tag == "synced_bookmarks"] | 962 if spec.tag == "synced_bookmarks"] |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 200, | 1104 200, |
1090 '<html><title>Transient error</title><H1>Transient error</H1></html>') | 1105 '<html><title>Transient error</title><H1>Transient error</H1></html>') |
1091 | 1106 |
1092 def HandleSetSyncTabs(self): | 1107 def HandleSetSyncTabs(self): |
1093 """Set the 'sync_tab' field of the nigori node for this account.""" | 1108 """Set the 'sync_tab' field of the nigori node for this account.""" |
1094 self.account.TriggerSyncTabs() | 1109 self.account.TriggerSyncTabs() |
1095 return ( | 1110 return ( |
1096 200, | 1111 200, |
1097 '<html><title>Sync Tabs</title><H1>Sync Tabs</H1></html>') | 1112 '<html><title>Sync Tabs</title><H1>Sync Tabs</H1></html>') |
1098 | 1113 |
| 1114 def HandleSetSyncTabFavicons(self): |
| 1115 """Set the 'sync_tab_favicons' field of the nigori node for this account.""" |
| 1116 self.account.TriggerSyncTabFavicons() |
| 1117 return ( |
| 1118 200, |
| 1119 '<html><title>Sync Tabs Favicons</title> ' |
| 1120 '<H1>Sync Tab Favicons</H1></html>') |
| 1121 |
1099 def HandleCreateSyncedBookmarks(self): | 1122 def HandleCreateSyncedBookmarks(self): |
1100 """Create the Synced Bookmarks folder under Bookmarks.""" | 1123 """Create the Synced Bookmarks folder under Bookmarks.""" |
1101 self.account.TriggerCreateSyncedBookmarks() | 1124 self.account.TriggerCreateSyncedBookmarks() |
1102 return ( | 1125 return ( |
1103 200, | 1126 200, |
1104 '<html><title>Synced Bookmarks</title><H1>Synced Bookmarks</H1></html>') | 1127 '<html><title>Synced Bookmarks</title><H1>Synced Bookmarks</H1></html>') |
1105 | 1128 |
1106 def HandleCommand(self, query, raw_request): | 1129 def HandleCommand(self, query, raw_request): |
1107 """Decode and handle a sync command from a raw input of bytes. | 1130 """Decode and handle a sync command from a raw input of bytes. |
1108 | 1131 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 | 1278 |
1256 update_sieve.CheckMigrationState() | 1279 update_sieve.CheckMigrationState() |
1257 | 1280 |
1258 new_timestamp, entries, remaining = self.account.GetChanges(update_sieve) | 1281 new_timestamp, entries, remaining = self.account.GetChanges(update_sieve) |
1259 | 1282 |
1260 update_response.changes_remaining = remaining | 1283 update_response.changes_remaining = remaining |
1261 for entry in entries: | 1284 for entry in entries: |
1262 reply = update_response.entries.add() | 1285 reply = update_response.entries.add() |
1263 reply.CopyFrom(entry) | 1286 reply.CopyFrom(entry) |
1264 update_sieve.SaveProgress(new_timestamp, update_response) | 1287 update_sieve.SaveProgress(new_timestamp, update_response) |
OLD | NEW |