| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // This API is designed to be used with Chrome Sync. | |
| 6 namespace syncedNotificationsPrivate { | |
| 7 | |
| 8 // Potential sync change types. | |
| 9 enum ChangeType { | |
| 10 added, | |
| 11 updated, | |
| 12 deleted | |
| 13 }; | |
| 14 | |
| 15 // Whether or not to resync all data items if the data type context changes. | |
| 16 enum RefreshRequest { | |
| 17 refresh_needed, | |
| 18 no_refresh | |
| 19 }; | |
| 20 | |
| 21 enum SyncDataType { | |
| 22 synced_notification, | |
| 23 app_info | |
| 24 }; | |
| 25 | |
| 26 dictionary SyncData { | |
| 27 SyncDataType datatype; | |
| 28 // |dataItem| will be a binary protobuf which matches the backend | |
| 29 // for the datatype. | |
| 30 ArrayBuffer dataItem; | |
| 31 }; | |
| 32 | |
| 33 // Datatype that represents a single sync change to a notification or an app | |
| 34 // info. | |
| 35 dictionary SyncChange { | |
| 36 SyncData data; | |
| 37 ChangeType changeType; | |
| 38 }; | |
| 39 | |
| 40 // Gets an array of SyncChange objects representing the current sync state. | |
| 41 // chrome.runtime.lastError contains any errors; if that is the case then | |
| 42 // changes should be undefined. | |
| 43 callback GetInitialDataCallback = void (SyncData[] changes); | |
| 44 // Called on completion or error of the sync operation. lastError contains an | |
| 45 // error message if required. | |
| 46 callback SyncOperationCallback = void (); | |
| 47 | |
| 48 interface Functions { | |
| 49 | |
| 50 // Gets all data from sync representing the current state (for use at | |
| 51 // startup). This returns both Synced Notifications and AppInfos (with the | |
| 52 // datatype enum set appropriately). Can return undefined, in which case | |
| 53 // LastError will be set. This means sync is unavailable at this time. | |
| 54 static void getInitialData(SyncDataType type, | |
| 55 GetInitialDataCallback callback); | |
| 56 | |
| 57 // Sends a changed (read state) notification back up to sync. To keep the | |
| 58 // sync from needing to understand the protocol, we send the whole object, | |
| 59 // not just the new read state. | |
| 60 static void updateNotification(ArrayBuffer changedNotification, | |
| 61 SyncOperationCallback callback); | |
| 62 | |
| 63 // Sets the (e.g.) Locale and DPI scale factor and list of sending services, | |
| 64 // encoded as a binary protobuf. Sync will persist these values for this | |
| 65 // and future sessions. | |
| 66 static void setRenderContext(RefreshRequest refresh, | |
| 67 ArrayBuffer dataTypeContext, | |
| 68 SyncOperationCallback callback); | |
| 69 | |
| 70 }; | |
| 71 | |
| 72 interface Events { | |
| 73 // Called by sync when we get new notifications or app infos from the | |
| 74 // server. | |
| 75 static void onDataChanges(SyncChange[] changes); | |
| 76 | |
| 77 // Called by sync when sync becomes available. This can be used to get the | |
| 78 // initial data for the app as soon as sync starts up, even if that is not | |
| 79 // soon after chrome startup. | |
| 80 static void onSyncStartup(); | |
| 81 }; | |
| 82 | |
| 83 }; | |
| OLD | NEW |