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 3 // found in the LICENSE file. 4 // 5 // Sync protocol datatype extension for push notifications.. 6 7 // Update proto_value_conversions{.h,.cc,_unittest.cc} if you change 8 // any fields in this file. 9 10 syntax = "proto2"; 11 12 option optimize_for = LITE_RUNTIME; 13 option retain_unknown_fields = true; 14 15 package sync_pb; 16 17 import "synced_notification_render.proto"; 18 19 // This message allows clients to identify a notification they have created. 20 message SyncedNotificationIdentifier { 21 // The application that the notification is a part of. 22 optional string app_id = 1; 23 24 // Notifications with the same coalescing key (isolated to the same app_id) 25 // will be grouped together when fetched. 26 optional string coalescing_key = 2; 27 } 28 29 message SyncedNotificationCreator { 30 // The gaia id of the creator. If a notification does not have a clear 31 // creator, skip this and follow the directions below to use a system creator. 32 optional int64 gaia_id = 1; 33 34 // Indicates that the creator is a "system" creator. Example of these are 35 // notifications sent to the user where the addressee is "Google", such as the 36 // "You have violated our TOS, and have 3 days to fix it or you'll lose your 37 // account" notifications. If is_system is set, gaia_id must not be set and 38 // instead the app_id field must be set. 39 optional bool is_system = 2; 40 41 // Only set this in the system-creator case. 42 optional string app_id = 3; 43 } 44 45 message SyncedNotificationRecipients { 46 repeated int64 gaia_id = 1; 47 48 // For now, only support gaia id recipients. Add more recipient types via 49 // 'repeated Type other_type = X' when necessary. 50 } 51 52 message SyncedNotification { 53 // A secondary type that is isolated within the same app_id. 54 // 55 // NOTE: For ASBE support purposes this must be in the format [A-Za-z_]+. 56 optional string type = 1; 57 58 // Whatever string the client entered during creation. If no external_id is 59 // specified, the notification can no longer be identified individually for 60 // fetching/deleting, etc... 61 optional string external_id = 2; 62 63 // The creator of the notification. 64 optional SyncedNotificationCreator creator = 3; 65 66 // Client specific data. 67 optional MapData client_data = 4; 68 } 69 70 message CoalescedSyncedNotification { 71 // An opaque string key used to identify individual coalesced notifications. 72 optional string key = 1; 73 74 optional string app_id = 2; 75 76 // All the notifications that are grouped together. 77 repeated SyncedNotification notification = 3; 78 79 // Data that is used directly by endpoints to render notifications in the case 80 // where no "native" app can handle the notification. 81 optional SyncedNotificationRenderInfo render_info = 4; 82 83 // Read state will be per coalesced notification. 84 enum ReadState { 85 UNREAD = 1; 86 READ = 2; 87 DISMISSED = 3; 88 SEEN = 4; 89 } 90 optional ReadState read_state = 5; 91 92 // The time when the LATEST notification of the coalesced notification is 93 // created (in milliseconds since the linux epoch). 94 // This is called updated_version in the server side protobuf. 95 optional uint64 creation_time_msec = 6; 96 97 enum Priority { 98 INVISIBLE = 1; 99 LOW = 2; 100 HIGH = 3; 101 // We will most likely add at least one more priority in the near future. 102 }; 103 optional Priority priority = 7; 104 105 // Security token that is to be used when making a PerformUserAction request 106 // when any user action within this coalesced notification is triggered. 107 optional string user_action_token = 8; 108 109 // This field corresponds to catchup_version in entity, which represents the 110 // version entity was last modified. Note that the 111 // Entity.last_modified_version will be actually the last creation version. 112 // See comments in updated_version. 113 optional uint64 last_modified_version = 9; 114 115 // Clients should use this field to order the notifications. Currently this is 116 // calculated from (priority, updated_version) pair. 117 optional uint64 sort_version = 10; 118 } 119 120 message SyncedNotificationList { 121 repeated CoalescedSyncedNotification coalesced_notification = 1; 122 } 123 124 // MapData, Data, and ListData are used to sending aribitrary payloads 125 // between instances of applications using Synced Notifications. The 126 // schema atop MapData will be defined by the client application. 127 message MapData { 128 message Entry { 129 optional string key = 1; 130 optional Data value = 2; 131 }; 132 repeated Entry entry = 1; 133 }; 134 135 message Data { 136 optional bool boolean_value = 1; 137 optional int32 int_value = 2; 138 optional double float_value = 3; 139 optional string string_value = 4; 140 optional ListData list_value = 5; 141 optional MapData map_value = 6; 142 }; 143 144 message ListData { 145 repeated Data value = 1; 146 }; 147 148 // The RenderContext encapsulates data about the device that is displaying the 149 // notification. In the future, RenderContext might include data like the 150 // location of the user. 151 message RenderContext { 152 // The type of the device. This will be used to decide the resolution as well 153 // as the size of the image returned with the response. 154 // The server will try to find the closest matching resource to use. 155 // The android densities are from 156 // http://developer.android.com/guide/practices/screens_support.html 157 enum DeviceType { 158 UNKNOWN = 0; 159 IOS_NON_RETINA = 1; 160 IOS_RETINA = 2; 161 ANDROID_MDPI = 3; 162 ANDROID_HDPI = 4; 163 ANDROID_XHDPI = 5; 164 ANDROID_TVDPI = 6; 165 DESKTOP_NON_RETINA = 7; 166 DESKTOP_RETINA = 8; 167 ANDROID_XXHDPI = 9; 168 CHROME_1X = 10; 169 CHROME_2X = 11; 170 } 171 172 optional DeviceType device_type = 1; 173 174 // The locale to render the notifications in. 175 optional string language_code = 2; 176 }; 177 178 // List of AppIds and whether to treat the list as a Whitelist or Blacklist. 179 message AppList { 180 enum Type { 181 // Specified app_ids are supported. 182 WHITELIST = 1; 183 // Specified app_ids are not supported. 184 BLACKLIST = 2; 185 } 186 187 // Whether to treat the app_id list as a Whitelist or Blacklist. 188 optional Type type = 1 [default = WHITELIST]; 189 190 // List of AppIds. 191 repeated string app_id = 2; 192 }; 193 194 message ServerContext { 195 // render_context encapsulates data about the device that is displaying the 196 // notifications. 197 optional RenderContext render_context = 1; 198 199 // List of AppIds and whether it is a blacklist or whitelist. 200 // This field needs to be set only when the set of apps enabled on a client 201 // changes. In the server response, this field will get cleared. 202 optional AppList app_list = 2; 203 204 // The view that the device has registered with. It is obtained from guns 205 // based on the app_list specified above. 206 optional string view_id = 3; 207 };