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 |
11 import base64 | 11 import base64 |
12 import cgi | 12 import cgi |
13 import copy | 13 import copy |
14 import google.protobuf.text_format | 14 import google.protobuf.text_format |
15 import hashlib | 15 import hashlib |
16 import operator | 16 import operator |
17 import pickle | 17 import pickle |
18 import random | 18 import random |
19 import string | 19 import string |
20 import sys | 20 import sys |
21 import threading | 21 import threading |
22 import time | 22 import time |
23 import urlparse | 23 import urlparse |
24 import uuid | 24 import uuid |
25 | 25 |
26 import app_list_specifics_pb2 | 26 import app_list_specifics_pb2 |
27 import app_notification_specifics_pb2 | 27 import app_notification_specifics_pb2 |
28 import app_setting_specifics_pb2 | 28 import app_setting_specifics_pb2 |
29 import app_specifics_pb2 | 29 import app_specifics_pb2 |
| 30 import arc_package_specifics_pb2 |
30 import article_specifics_pb2 | 31 import article_specifics_pb2 |
31 import autofill_specifics_pb2 | 32 import autofill_specifics_pb2 |
32 import bookmark_specifics_pb2 | 33 import bookmark_specifics_pb2 |
33 import client_commands_pb2 | 34 import client_commands_pb2 |
34 import dictionary_specifics_pb2 | 35 import dictionary_specifics_pb2 |
35 import get_updates_caller_info_pb2 | 36 import get_updates_caller_info_pb2 |
36 import extension_setting_specifics_pb2 | 37 import extension_setting_specifics_pb2 |
37 import extension_specifics_pb2 | 38 import extension_specifics_pb2 |
38 import favicon_image_specifics_pb2 | 39 import favicon_image_specifics_pb2 |
39 import favicon_tracking_specifics_pb2 | 40 import favicon_tracking_specifics_pb2 |
(...skipping 19 matching lines...) Expand all Loading... |
59 # An enumeration of the various kinds of data that can be synced. | 60 # An enumeration of the various kinds of data that can be synced. |
60 # Over the wire, this enumeration is not used: a sync object's type is | 61 # Over the wire, this enumeration is not used: a sync object's type is |
61 # inferred by which EntitySpecifics field it has. But in the context | 62 # inferred by which EntitySpecifics field it has. But in the context |
62 # of a program, it is useful to have an enumeration. | 63 # of a program, it is useful to have an enumeration. |
63 ALL_TYPES = ( | 64 ALL_TYPES = ( |
64 TOP_LEVEL, # The type of the 'Google Chrome' folder. | 65 TOP_LEVEL, # The type of the 'Google Chrome' folder. |
65 APPS, | 66 APPS, |
66 APP_LIST, | 67 APP_LIST, |
67 APP_NOTIFICATION, | 68 APP_NOTIFICATION, |
68 APP_SETTINGS, | 69 APP_SETTINGS, |
| 70 ARC_PACKAGE, |
69 ARTICLE, | 71 ARTICLE, |
70 AUTOFILL, | 72 AUTOFILL, |
71 AUTOFILL_PROFILE, | 73 AUTOFILL_PROFILE, |
72 AUTOFILL_WALLET, | 74 AUTOFILL_WALLET, |
73 AUTOFILL_WALLET_METADATA, | 75 AUTOFILL_WALLET_METADATA, |
74 BOOKMARK, | 76 BOOKMARK, |
75 DEVICE_INFO, | 77 DEVICE_INFO, |
76 DICTIONARY, | 78 DICTIONARY, |
77 EXPERIMENTS, | 79 EXPERIMENTS, |
78 EXTENSIONS, | 80 EXTENSIONS, |
79 HISTORY_DELETE_DIRECTIVE, | 81 HISTORY_DELETE_DIRECTIVE, |
80 MANAGED_USER_SETTING, | 82 MANAGED_USER_SETTING, |
81 MANAGED_USER_SHARED_SETTING, | 83 MANAGED_USER_SHARED_SETTING, |
82 MANAGED_USER_WHITELIST, | 84 MANAGED_USER_WHITELIST, |
83 MANAGED_USER, | 85 MANAGED_USER, |
84 NIGORI, | 86 NIGORI, |
85 PASSWORD, | 87 PASSWORD, |
86 PREFERENCE, | 88 PREFERENCE, |
87 PRIORITY_PREFERENCE, | 89 PRIORITY_PREFERENCE, |
88 SEARCH_ENGINE, | 90 SEARCH_ENGINE, |
89 SESSION, | 91 SESSION, |
90 SYNCED_NOTIFICATION, | 92 SYNCED_NOTIFICATION, |
91 SYNCED_NOTIFICATION_APP_INFO, | 93 SYNCED_NOTIFICATION_APP_INFO, |
92 THEME, | 94 THEME, |
93 TYPED_URL, | 95 TYPED_URL, |
94 EXTENSION_SETTINGS, | 96 EXTENSION_SETTINGS, |
95 FAVICON_IMAGES, | 97 FAVICON_IMAGES, |
96 FAVICON_TRACKING, | 98 FAVICON_TRACKING, |
97 WIFI_CREDENTIAL) = range(34) | 99 WIFI_CREDENTIAL) = range(35) |
98 | 100 |
99 # An enumeration on the frequency at which the server should send errors | 101 # An enumeration on the frequency at which the server should send errors |
100 # to the client. This would be specified by the url that triggers the error. | 102 # to the client. This would be specified by the url that triggers the error. |
101 # Note: This enum should be kept in the same order as the enum in sync_test.h. | 103 # Note: This enum should be kept in the same order as the enum in sync_test.h. |
102 SYNC_ERROR_FREQUENCY = ( | 104 SYNC_ERROR_FREQUENCY = ( |
103 ERROR_FREQUENCY_NONE, | 105 ERROR_FREQUENCY_NONE, |
104 ERROR_FREQUENCY_ALWAYS, | 106 ERROR_FREQUENCY_ALWAYS, |
105 ERROR_FREQUENCY_TWO_THIRDS) = range(3) | 107 ERROR_FREQUENCY_TWO_THIRDS) = range(3) |
106 | 108 |
107 # Well-known server tag of the top level 'Google Chrome' folder. | 109 # Well-known server tag of the top level 'Google Chrome' folder. |
108 TOP_LEVEL_FOLDER_TAG = 'google_chrome' | 110 TOP_LEVEL_FOLDER_TAG = 'google_chrome' |
109 | 111 |
110 # Given a sync type from ALL_TYPES, find the FieldDescriptor corresponding | 112 # Given a sync type from ALL_TYPES, find the FieldDescriptor corresponding |
111 # to that datatype. Note that TOP_LEVEL has no such token. | 113 # to that datatype. Note that TOP_LEVEL has no such token. |
112 SYNC_TYPE_FIELDS = sync_pb2.EntitySpecifics.DESCRIPTOR.fields_by_name | 114 SYNC_TYPE_FIELDS = sync_pb2.EntitySpecifics.DESCRIPTOR.fields_by_name |
113 SYNC_TYPE_TO_DESCRIPTOR = { | 115 SYNC_TYPE_TO_DESCRIPTOR = { |
114 APP_LIST: SYNC_TYPE_FIELDS['app_list'], | 116 APP_LIST: SYNC_TYPE_FIELDS['app_list'], |
115 APP_NOTIFICATION: SYNC_TYPE_FIELDS['app_notification'], | 117 APP_NOTIFICATION: SYNC_TYPE_FIELDS['app_notification'], |
116 APP_SETTINGS: SYNC_TYPE_FIELDS['app_setting'], | 118 APP_SETTINGS: SYNC_TYPE_FIELDS['app_setting'], |
117 APPS: SYNC_TYPE_FIELDS['app'], | 119 APPS: SYNC_TYPE_FIELDS['app'], |
| 120 ARC_PACKAGE: SYNC_TYPE_FIELDS['arc_package'], |
118 ARTICLE: SYNC_TYPE_FIELDS['article'], | 121 ARTICLE: SYNC_TYPE_FIELDS['article'], |
119 AUTOFILL: SYNC_TYPE_FIELDS['autofill'], | 122 AUTOFILL: SYNC_TYPE_FIELDS['autofill'], |
120 AUTOFILL_PROFILE: SYNC_TYPE_FIELDS['autofill_profile'], | 123 AUTOFILL_PROFILE: SYNC_TYPE_FIELDS['autofill_profile'], |
121 AUTOFILL_WALLET: SYNC_TYPE_FIELDS['autofill_wallet'], | 124 AUTOFILL_WALLET: SYNC_TYPE_FIELDS['autofill_wallet'], |
122 AUTOFILL_WALLET_METADATA: SYNC_TYPE_FIELDS['wallet_metadata'], | 125 AUTOFILL_WALLET_METADATA: SYNC_TYPE_FIELDS['wallet_metadata'], |
123 BOOKMARK: SYNC_TYPE_FIELDS['bookmark'], | 126 BOOKMARK: SYNC_TYPE_FIELDS['bookmark'], |
124 DEVICE_INFO: SYNC_TYPE_FIELDS['device_info'], | 127 DEVICE_INFO: SYNC_TYPE_FIELDS['device_info'], |
125 DICTIONARY: SYNC_TYPE_FIELDS['dictionary'], | 128 DICTIONARY: SYNC_TYPE_FIELDS['dictionary'], |
126 EXPERIMENTS: SYNC_TYPE_FIELDS['experiments'], | 129 EXPERIMENTS: SYNC_TYPE_FIELDS['experiments'], |
127 EXTENSION_SETTINGS: SYNC_TYPE_FIELDS['extension_setting'], | 130 EXTENSION_SETTINGS: SYNC_TYPE_FIELDS['extension_setting'], |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 _PERMANENT_ITEM_SPECS = [ | 498 _PERMANENT_ITEM_SPECS = [ |
496 PermanentItem('google_chrome_apps', name='Apps', | 499 PermanentItem('google_chrome_apps', name='Apps', |
497 parent_tag=ROOT_ID, sync_type=APPS), | 500 parent_tag=ROOT_ID, sync_type=APPS), |
498 PermanentItem('google_chrome_app_list', name='App List', | 501 PermanentItem('google_chrome_app_list', name='App List', |
499 parent_tag=ROOT_ID, sync_type=APP_LIST), | 502 parent_tag=ROOT_ID, sync_type=APP_LIST), |
500 PermanentItem('google_chrome_app_notifications', name='App Notifications', | 503 PermanentItem('google_chrome_app_notifications', name='App Notifications', |
501 parent_tag=ROOT_ID, sync_type=APP_NOTIFICATION), | 504 parent_tag=ROOT_ID, sync_type=APP_NOTIFICATION), |
502 PermanentItem('google_chrome_app_settings', | 505 PermanentItem('google_chrome_app_settings', |
503 name='App Settings', | 506 name='App Settings', |
504 parent_tag=ROOT_ID, sync_type=APP_SETTINGS), | 507 parent_tag=ROOT_ID, sync_type=APP_SETTINGS), |
| 508 PermanentItem('google_chrome_arc_package', name='Arc Package', |
| 509 parent_tag=ROOT_ID, sync_type=ARC_PACKAGE), |
505 PermanentItem('google_chrome_bookmarks', name='Bookmarks', | 510 PermanentItem('google_chrome_bookmarks', name='Bookmarks', |
506 parent_tag=ROOT_ID, sync_type=BOOKMARK), | 511 parent_tag=ROOT_ID, sync_type=BOOKMARK), |
507 PermanentItem('bookmark_bar', name='Bookmark Bar', | 512 PermanentItem('bookmark_bar', name='Bookmark Bar', |
508 parent_tag='google_chrome_bookmarks', sync_type=BOOKMARK), | 513 parent_tag='google_chrome_bookmarks', sync_type=BOOKMARK), |
509 PermanentItem('other_bookmarks', name='Other Bookmarks', | 514 PermanentItem('other_bookmarks', name='Other Bookmarks', |
510 parent_tag='google_chrome_bookmarks', sync_type=BOOKMARK), | 515 parent_tag='google_chrome_bookmarks', sync_type=BOOKMARK), |
511 PermanentItem('synced_bookmarks', name='Synced Bookmarks', | 516 PermanentItem('synced_bookmarks', name='Synced Bookmarks', |
512 parent_tag='google_chrome_bookmarks', sync_type=BOOKMARK, | 517 parent_tag='google_chrome_bookmarks', sync_type=BOOKMARK, |
513 create_by_default=False), | 518 create_by_default=False), |
514 PermanentItem('google_chrome_autofill', name='Autofill', | 519 PermanentItem('google_chrome_autofill', name='Autofill', |
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1627 | 1632 |
1628 Args: | 1633 Args: |
1629 sessions_commit_delay_seconds: The desired sync delay time for sessions. | 1634 sessions_commit_delay_seconds: The desired sync delay time for sessions. |
1630 """ | 1635 """ |
1631 if not self._client_command: | 1636 if not self._client_command: |
1632 self._client_command = client_commands_pb2.ClientCommand() | 1637 self._client_command = client_commands_pb2.ClientCommand() |
1633 | 1638 |
1634 self._client_command.sessions_commit_delay_seconds = \ | 1639 self._client_command.sessions_commit_delay_seconds = \ |
1635 sessions_commit_delay_seconds | 1640 sessions_commit_delay_seconds |
1636 return self._client_command | 1641 return self._client_command |
OLD | NEW |