| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 14 matching lines...) Expand all Loading... |
| 25 import autofill_specifics_pb2 | 25 import autofill_specifics_pb2 |
| 26 import bookmark_specifics_pb2 | 26 import bookmark_specifics_pb2 |
| 27 import dictionary_specifics_pb2 | 27 import dictionary_specifics_pb2 |
| 28 import get_updates_caller_info_pb2 | 28 import get_updates_caller_info_pb2 |
| 29 import extension_setting_specifics_pb2 | 29 import extension_setting_specifics_pb2 |
| 30 import extension_specifics_pb2 | 30 import extension_specifics_pb2 |
| 31 import history_delete_directive_specifics_pb2 | 31 import history_delete_directive_specifics_pb2 |
| 32 import nigori_specifics_pb2 | 32 import nigori_specifics_pb2 |
| 33 import password_specifics_pb2 | 33 import password_specifics_pb2 |
| 34 import preference_specifics_pb2 | 34 import preference_specifics_pb2 |
| 35 import priority_preference_specifics_pb2 |
| 35 import search_engine_specifics_pb2 | 36 import search_engine_specifics_pb2 |
| 36 import session_specifics_pb2 | 37 import session_specifics_pb2 |
| 37 import sync_pb2 | 38 import sync_pb2 |
| 38 import sync_enums_pb2 | 39 import sync_enums_pb2 |
| 39 import synced_notification_specifics_pb2 | 40 import synced_notification_specifics_pb2 |
| 40 import theme_specifics_pb2 | 41 import theme_specifics_pb2 |
| 41 import typed_url_specifics_pb2 | 42 import typed_url_specifics_pb2 |
| 42 | 43 |
| 43 # An enumeration of the various kinds of data that can be synced. | 44 # An enumeration of the various kinds of data that can be synced. |
| 44 # Over the wire, this enumeration is not used: a sync object's type is | 45 # Over the wire, this enumeration is not used: a sync object's type is |
| 45 # inferred by which EntitySpecifics field it has. But in the context | 46 # inferred by which EntitySpecifics field it has. But in the context |
| 46 # of a program, it is useful to have an enumeration. | 47 # of a program, it is useful to have an enumeration. |
| 47 ALL_TYPES = ( | 48 ALL_TYPES = ( |
| 48 TOP_LEVEL, # The type of the 'Google Chrome' folder. | 49 TOP_LEVEL, # The type of the 'Google Chrome' folder. |
| 49 APPS, | 50 APPS, |
| 50 APP_NOTIFICATION, | 51 APP_NOTIFICATION, |
| 51 APP_SETTINGS, | 52 APP_SETTINGS, |
| 52 AUTOFILL, | 53 AUTOFILL, |
| 53 AUTOFILL_PROFILE, | 54 AUTOFILL_PROFILE, |
| 54 BOOKMARK, | 55 BOOKMARK, |
| 55 DEVICE_INFO, | 56 DEVICE_INFO, |
| 56 DICTIONARY, | 57 DICTIONARY, |
| 57 EXPERIMENTS, | 58 EXPERIMENTS, |
| 58 EXTENSIONS, | 59 EXTENSIONS, |
| 59 HISTORY_DELETE_DIRECTIVE, | 60 HISTORY_DELETE_DIRECTIVE, |
| 60 NIGORI, | 61 NIGORI, |
| 61 PASSWORD, | 62 PASSWORD, |
| 62 PREFERENCE, | 63 PREFERENCE, |
| 64 PRIORITY_PREFERENCE, |
| 63 SEARCH_ENGINE, | 65 SEARCH_ENGINE, |
| 64 SESSION, | 66 SESSION, |
| 65 SYNCED_NOTIFICATION, | 67 SYNCED_NOTIFICATION, |
| 66 THEME, | 68 THEME, |
| 67 TYPED_URL, | 69 TYPED_URL, |
| 68 EXTENSION_SETTINGS) = range(21) | 70 EXTENSION_SETTINGS) = range(22) |
| 69 | 71 |
| 70 # An enumeration on the frequency at which the server should send errors | 72 # An enumeration on the frequency at which the server should send errors |
| 71 # to the client. This would be specified by the url that triggers the error. | 73 # to the client. This would be specified by the url that triggers the error. |
| 72 # Note: This enum should be kept in the same order as the enum in sync_test.h. | 74 # Note: This enum should be kept in the same order as the enum in sync_test.h. |
| 73 SYNC_ERROR_FREQUENCY = ( | 75 SYNC_ERROR_FREQUENCY = ( |
| 74 ERROR_FREQUENCY_NONE, | 76 ERROR_FREQUENCY_NONE, |
| 75 ERROR_FREQUENCY_ALWAYS, | 77 ERROR_FREQUENCY_ALWAYS, |
| 76 ERROR_FREQUENCY_TWO_THIRDS) = range(3) | 78 ERROR_FREQUENCY_TWO_THIRDS) = range(3) |
| 77 | 79 |
| 78 # Well-known server tag of the top level 'Google Chrome' folder. | 80 # Well-known server tag of the top level 'Google Chrome' folder. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 90 BOOKMARK: SYNC_TYPE_FIELDS['bookmark'], | 92 BOOKMARK: SYNC_TYPE_FIELDS['bookmark'], |
| 91 DEVICE_INFO: SYNC_TYPE_FIELDS['device_info'], | 93 DEVICE_INFO: SYNC_TYPE_FIELDS['device_info'], |
| 92 DICTIONARY: SYNC_TYPE_FIELDS['dictionary'], | 94 DICTIONARY: SYNC_TYPE_FIELDS['dictionary'], |
| 93 EXPERIMENTS: SYNC_TYPE_FIELDS['experiments'], | 95 EXPERIMENTS: SYNC_TYPE_FIELDS['experiments'], |
| 94 EXTENSION_SETTINGS: SYNC_TYPE_FIELDS['extension_setting'], | 96 EXTENSION_SETTINGS: SYNC_TYPE_FIELDS['extension_setting'], |
| 95 EXTENSIONS: SYNC_TYPE_FIELDS['extension'], | 97 EXTENSIONS: SYNC_TYPE_FIELDS['extension'], |
| 96 HISTORY_DELETE_DIRECTIVE: SYNC_TYPE_FIELDS['history_delete_directive'], | 98 HISTORY_DELETE_DIRECTIVE: SYNC_TYPE_FIELDS['history_delete_directive'], |
| 97 NIGORI: SYNC_TYPE_FIELDS['nigori'], | 99 NIGORI: SYNC_TYPE_FIELDS['nigori'], |
| 98 PASSWORD: SYNC_TYPE_FIELDS['password'], | 100 PASSWORD: SYNC_TYPE_FIELDS['password'], |
| 99 PREFERENCE: SYNC_TYPE_FIELDS['preference'], | 101 PREFERENCE: SYNC_TYPE_FIELDS['preference'], |
| 102 PRIORITY_PREFERENCE: SYNC_TYPE_FIELDS['priority_preference'], |
| 100 SEARCH_ENGINE: SYNC_TYPE_FIELDS['search_engine'], | 103 SEARCH_ENGINE: SYNC_TYPE_FIELDS['search_engine'], |
| 101 SESSION: SYNC_TYPE_FIELDS['session'], | 104 SESSION: SYNC_TYPE_FIELDS['session'], |
| 102 SYNCED_NOTIFICATION: SYNC_TYPE_FIELDS["synced_notification"], | 105 SYNCED_NOTIFICATION: SYNC_TYPE_FIELDS["synced_notification"], |
| 103 THEME: SYNC_TYPE_FIELDS['theme'], | 106 THEME: SYNC_TYPE_FIELDS['theme'], |
| 104 TYPED_URL: SYNC_TYPE_FIELDS['typed_url'], | 107 TYPED_URL: SYNC_TYPE_FIELDS['typed_url'], |
| 105 } | 108 } |
| 106 | 109 |
| 107 # The parent ID used to indicate a top-level node. | 110 # The parent ID used to indicate a top-level node. |
| 108 ROOT_ID = '0' | 111 ROOT_ID = '0' |
| 109 | 112 |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 PermanentItem('google_chrome_history_delete_directives', | 469 PermanentItem('google_chrome_history_delete_directives', |
| 467 name='History Delete Directives', | 470 name='History Delete Directives', |
| 468 parent_tag=ROOT_ID, | 471 parent_tag=ROOT_ID, |
| 469 sync_type=HISTORY_DELETE_DIRECTIVE), | 472 sync_type=HISTORY_DELETE_DIRECTIVE), |
| 470 PermanentItem('google_chrome_nigori', name='Nigori', | 473 PermanentItem('google_chrome_nigori', name='Nigori', |
| 471 parent_tag=ROOT_ID, sync_type=NIGORI), | 474 parent_tag=ROOT_ID, sync_type=NIGORI), |
| 472 PermanentItem('google_chrome_passwords', name='Passwords', | 475 PermanentItem('google_chrome_passwords', name='Passwords', |
| 473 parent_tag=ROOT_ID, sync_type=PASSWORD), | 476 parent_tag=ROOT_ID, sync_type=PASSWORD), |
| 474 PermanentItem('google_chrome_preferences', name='Preferences', | 477 PermanentItem('google_chrome_preferences', name='Preferences', |
| 475 parent_tag=ROOT_ID, sync_type=PREFERENCE), | 478 parent_tag=ROOT_ID, sync_type=PREFERENCE), |
| 479 PermanentItem('google_chrome_priority_preferences', |
| 480 name='Priority Preferences', |
| 481 parent_tag=ROOT_ID, sync_type=PRIORITY_PREFERENCE), |
| 476 PermanentItem('google_chrome_synced_notifications', | 482 PermanentItem('google_chrome_synced_notifications', |
| 477 name='Synced Notifications', | 483 name='Synced Notifications', |
| 478 parent_tag=ROOT_ID, sync_type=SYNCED_NOTIFICATION), | 484 parent_tag=ROOT_ID, sync_type=SYNCED_NOTIFICATION), |
| 479 PermanentItem('google_chrome_search_engines', name='Search Engines', | 485 PermanentItem('google_chrome_search_engines', name='Search Engines', |
| 480 parent_tag=ROOT_ID, sync_type=SEARCH_ENGINE), | 486 parent_tag=ROOT_ID, sync_type=SEARCH_ENGINE), |
| 481 PermanentItem('google_chrome_sessions', name='Sessions', | 487 PermanentItem('google_chrome_sessions', name='Sessions', |
| 482 parent_tag=ROOT_ID, sync_type=SESSION), | 488 parent_tag=ROOT_ID, sync_type=SESSION), |
| 483 PermanentItem('google_chrome_themes', name='Themes', | 489 PermanentItem('google_chrome_themes', name='Themes', |
| 484 parent_tag=ROOT_ID, sync_type=THEME), | 490 parent_tag=ROOT_ID, sync_type=THEME), |
| 485 PermanentItem('google_chrome_typed_urls', name='Typed URLs', | 491 PermanentItem('google_chrome_typed_urls', name='Typed URLs', |
| (...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 sending_nigori_node = False | 1372 sending_nigori_node = False |
| 1367 for entry in entries: | 1373 for entry in entries: |
| 1368 if entry.name == 'Nigori': | 1374 if entry.name == 'Nigori': |
| 1369 sending_nigori_node = True | 1375 sending_nigori_node = True |
| 1370 reply = update_response.entries.add() | 1376 reply = update_response.entries.add() |
| 1371 reply.CopyFrom(entry) | 1377 reply.CopyFrom(entry) |
| 1372 update_sieve.SaveProgress(new_timestamp, update_response) | 1378 update_sieve.SaveProgress(new_timestamp, update_response) |
| 1373 | 1379 |
| 1374 if update_request.need_encryption_key or sending_nigori_node: | 1380 if update_request.need_encryption_key or sending_nigori_node: |
| 1375 update_response.encryption_keys.extend(self.account.GetKeystoreKeys()) | 1381 update_response.encryption_keys.extend(self.account.GetKeystoreKeys()) |
| OLD | NEW |