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 |
11 import cgi | 11 import cgi |
12 import copy | 12 import copy |
13 import operator | 13 import operator |
14 import pickle | 14 import pickle |
15 import random | 15 import random |
16 import string | 16 import string |
17 import sys | 17 import sys |
18 import threading | 18 import threading |
19 import time | 19 import time |
20 import urlparse | 20 import urlparse |
21 | 21 |
22 import app_notification_specifics_pb2 | 22 import app_notification_specifics_pb2 |
23 import app_setting_specifics_pb2 | 23 import app_setting_specifics_pb2 |
24 import app_specifics_pb2 | 24 import app_specifics_pb2 |
25 import autofill_specifics_pb2 | 25 import autofill_specifics_pb2 |
26 import bookmark_specifics_pb2 | 26 import bookmark_specifics_pb2 |
27 import get_updates_caller_info_pb2 | 27 import get_updates_caller_info_pb2 |
28 import extension_setting_specifics_pb2 | 28 import extension_setting_specifics_pb2 |
29 import extension_specifics_pb2 | 29 import extension_specifics_pb2 |
| 30 import history_delete_directive_specifics_pb2 |
30 import nigori_specifics_pb2 | 31 import nigori_specifics_pb2 |
31 import password_specifics_pb2 | 32 import password_specifics_pb2 |
32 import preference_specifics_pb2 | 33 import preference_specifics_pb2 |
33 import search_engine_specifics_pb2 | 34 import search_engine_specifics_pb2 |
34 import session_specifics_pb2 | 35 import session_specifics_pb2 |
35 import sync_pb2 | 36 import sync_pb2 |
36 import sync_enums_pb2 | 37 import sync_enums_pb2 |
37 import theme_specifics_pb2 | 38 import theme_specifics_pb2 |
38 import typed_url_specifics_pb2 | 39 import typed_url_specifics_pb2 |
39 | 40 |
40 # An enumeration of the various kinds of data that can be synced. | 41 # An enumeration of the various kinds of data that can be synced. |
41 # Over the wire, this enumeration is not used: a sync object's type is | 42 # Over the wire, this enumeration is not used: a sync object's type is |
42 # inferred by which EntitySpecifics field it has. But in the context | 43 # inferred by which EntitySpecifics field it has. But in the context |
43 # of a program, it is useful to have an enumeration. | 44 # of a program, it is useful to have an enumeration. |
44 ALL_TYPES = ( | 45 ALL_TYPES = ( |
45 TOP_LEVEL, # The type of the 'Google Chrome' folder. | 46 TOP_LEVEL, # The type of the 'Google Chrome' folder. |
46 APPS, | 47 APPS, |
47 APP_NOTIFICATION, | 48 APP_NOTIFICATION, |
48 APP_SETTINGS, | 49 APP_SETTINGS, |
49 AUTOFILL, | 50 AUTOFILL, |
50 AUTOFILL_PROFILE, | 51 AUTOFILL_PROFILE, |
51 BOOKMARK, | 52 BOOKMARK, |
52 EXTENSIONS, | 53 EXTENSIONS, |
| 54 HISTORY_DELETE_DIRECTIVE, |
53 NIGORI, | 55 NIGORI, |
54 PASSWORD, | 56 PASSWORD, |
55 PREFERENCE, | 57 PREFERENCE, |
56 SEARCH_ENGINE, | 58 SEARCH_ENGINE, |
57 SESSION, | 59 SESSION, |
58 THEME, | 60 THEME, |
59 TYPED_URL, | 61 TYPED_URL, |
60 EXTENSION_SETTINGS) = range(16) | 62 EXTENSION_SETTINGS) = range(17) |
61 | 63 |
62 # An eumeration on the frequency at which the server should send errors | 64 # An eumeration on the frequency at which the server should send errors |
63 # to the client. This would be specified by the url that triggers the error. | 65 # to the client. This would be specified by the url that triggers the error. |
64 # Note: This enum should be kept in the same order as the enum in sync_test.h. | 66 # Note: This enum should be kept in the same order as the enum in sync_test.h. |
65 SYNC_ERROR_FREQUENCY = ( | 67 SYNC_ERROR_FREQUENCY = ( |
66 ERROR_FREQUENCY_NONE, | 68 ERROR_FREQUENCY_NONE, |
67 ERROR_FREQUENCY_ALWAYS, | 69 ERROR_FREQUENCY_ALWAYS, |
68 ERROR_FREQUENCY_TWO_THIRDS) = range(3) | 70 ERROR_FREQUENCY_TWO_THIRDS) = range(3) |
69 | 71 |
70 # Well-known server tag of the top level 'Google Chrome' folder. | 72 # Well-known server tag of the top level 'Google Chrome' folder. |
71 TOP_LEVEL_FOLDER_TAG = 'google_chrome' | 73 TOP_LEVEL_FOLDER_TAG = 'google_chrome' |
72 | 74 |
73 # Given a sync type from ALL_TYPES, find the FieldDescriptor corresponding | 75 # Given a sync type from ALL_TYPES, find the FieldDescriptor corresponding |
74 # to that datatype. Note that TOP_LEVEL has no such token. | 76 # to that datatype. Note that TOP_LEVEL has no such token. |
75 SYNC_TYPE_FIELDS = sync_pb2.EntitySpecifics.DESCRIPTOR.fields_by_name | 77 SYNC_TYPE_FIELDS = sync_pb2.EntitySpecifics.DESCRIPTOR.fields_by_name |
76 SYNC_TYPE_TO_DESCRIPTOR = { | 78 SYNC_TYPE_TO_DESCRIPTOR = { |
77 APP_NOTIFICATION: SYNC_TYPE_FIELDS['app_notification'], | 79 APP_NOTIFICATION: SYNC_TYPE_FIELDS['app_notification'], |
78 APP_SETTINGS: SYNC_TYPE_FIELDS['app_setting'], | 80 APP_SETTINGS: SYNC_TYPE_FIELDS['app_setting'], |
79 APPS: SYNC_TYPE_FIELDS['app'], | 81 APPS: SYNC_TYPE_FIELDS['app'], |
80 AUTOFILL: SYNC_TYPE_FIELDS['autofill'], | 82 AUTOFILL: SYNC_TYPE_FIELDS['autofill'], |
81 AUTOFILL_PROFILE: SYNC_TYPE_FIELDS['autofill_profile'], | 83 AUTOFILL_PROFILE: SYNC_TYPE_FIELDS['autofill_profile'], |
82 BOOKMARK: SYNC_TYPE_FIELDS['bookmark'], | 84 BOOKMARK: SYNC_TYPE_FIELDS['bookmark'], |
83 EXTENSION_SETTINGS: SYNC_TYPE_FIELDS['extension_setting'], | 85 EXTENSION_SETTINGS: SYNC_TYPE_FIELDS['extension_setting'], |
84 EXTENSIONS: SYNC_TYPE_FIELDS['extension'], | 86 EXTENSIONS: SYNC_TYPE_FIELDS['extension'], |
| 87 HISTORY_DELETE_DIRECTIVE: SYNC_TYPE_FIELDS['history_delete_directive'], |
85 NIGORI: SYNC_TYPE_FIELDS['nigori'], | 88 NIGORI: SYNC_TYPE_FIELDS['nigori'], |
86 PASSWORD: SYNC_TYPE_FIELDS['password'], | 89 PASSWORD: SYNC_TYPE_FIELDS['password'], |
87 PREFERENCE: SYNC_TYPE_FIELDS['preference'], | 90 PREFERENCE: SYNC_TYPE_FIELDS['preference'], |
88 SEARCH_ENGINE: SYNC_TYPE_FIELDS['search_engine'], | 91 SEARCH_ENGINE: SYNC_TYPE_FIELDS['search_engine'], |
89 SESSION: SYNC_TYPE_FIELDS['session'], | 92 SESSION: SYNC_TYPE_FIELDS['session'], |
90 THEME: SYNC_TYPE_FIELDS['theme'], | 93 THEME: SYNC_TYPE_FIELDS['theme'], |
91 TYPED_URL: SYNC_TYPE_FIELDS['typed_url'], | 94 TYPED_URL: SYNC_TYPE_FIELDS['typed_url'], |
92 } | 95 } |
93 | 96 |
94 # The parent ID used to indicate a top-level node. | 97 # The parent ID used to indicate a top-level node. |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 PermanentItem('google_chrome_autofill_profiles', name='Autofill Profiles', | 433 PermanentItem('google_chrome_autofill_profiles', name='Autofill Profiles', |
431 parent_tag='google_chrome', sync_type=AUTOFILL_PROFILE), | 434 parent_tag='google_chrome', sync_type=AUTOFILL_PROFILE), |
432 PermanentItem('google_chrome_app_settings', | 435 PermanentItem('google_chrome_app_settings', |
433 name='App Settings', | 436 name='App Settings', |
434 parent_tag='google_chrome', sync_type=APP_SETTINGS), | 437 parent_tag='google_chrome', sync_type=APP_SETTINGS), |
435 PermanentItem('google_chrome_extension_settings', | 438 PermanentItem('google_chrome_extension_settings', |
436 name='Extension Settings', | 439 name='Extension Settings', |
437 parent_tag='google_chrome', sync_type=EXTENSION_SETTINGS), | 440 parent_tag='google_chrome', sync_type=EXTENSION_SETTINGS), |
438 PermanentItem('google_chrome_extensions', name='Extensions', | 441 PermanentItem('google_chrome_extensions', name='Extensions', |
439 parent_tag='google_chrome', sync_type=EXTENSIONS), | 442 parent_tag='google_chrome', sync_type=EXTENSIONS), |
| 443 PermanentItem('google_chrome_history_delete_directives', |
| 444 name='History Delete Directives', |
| 445 parent_tag='google_chrome', |
| 446 sync_type=HISTORY_DELETE_DIRECTIVE), |
440 PermanentItem('google_chrome_passwords', name='Passwords', | 447 PermanentItem('google_chrome_passwords', name='Passwords', |
441 parent_tag='google_chrome', sync_type=PASSWORD), | 448 parent_tag='google_chrome', sync_type=PASSWORD), |
442 PermanentItem('google_chrome_search_engines', name='Search Engines', | 449 PermanentItem('google_chrome_search_engines', name='Search Engines', |
443 parent_tag='google_chrome', sync_type=SEARCH_ENGINE), | 450 parent_tag='google_chrome', sync_type=SEARCH_ENGINE), |
444 PermanentItem('google_chrome_sessions', name='Sessions', | 451 PermanentItem('google_chrome_sessions', name='Sessions', |
445 parent_tag='google_chrome', sync_type=SESSION), | 452 parent_tag='google_chrome', sync_type=SESSION), |
446 PermanentItem('google_chrome_themes', name='Themes', | 453 PermanentItem('google_chrome_themes', name='Themes', |
447 parent_tag='google_chrome', sync_type=THEME), | 454 parent_tag='google_chrome', sync_type=THEME), |
448 PermanentItem('google_chrome_typed_urls', name='Typed URLs', | 455 PermanentItem('google_chrome_typed_urls', name='Typed URLs', |
449 parent_tag='google_chrome', sync_type=TYPED_URL), | 456 parent_tag='google_chrome', sync_type=TYPED_URL), |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 new_timestamp, entries, remaining = self.account.GetChanges(update_sieve) | 1277 new_timestamp, entries, remaining = self.account.GetChanges(update_sieve) |
1271 | 1278 |
1272 update_response.changes_remaining = remaining | 1279 update_response.changes_remaining = remaining |
1273 for entry in entries: | 1280 for entry in entries: |
1274 reply = update_response.entries.add() | 1281 reply = update_response.entries.add() |
1275 reply.CopyFrom(entry) | 1282 reply.CopyFrom(entry) |
1276 update_sieve.SaveProgress(new_timestamp, update_response) | 1283 update_sieve.SaveProgress(new_timestamp, update_response) |
1277 | 1284 |
1278 if update_request.need_encryption_key: | 1285 if update_request.need_encryption_key: |
1279 update_response.encryption_key = self.account.GetKey() | 1286 update_response.encryption_key = self.account.GetKey() |
OLD | NEW |