ke.he | 5f426e32 | 2017-02-22 12:37:12 | [diff] [blame] | 1 | // Copyright 2017 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 | module content.mojom; |
| 6 | |
Peter Beverloo | 7815db1e0 | 2017-07-12 19:03:21 | [diff] [blame] | 7 | import "content/public/common/push_messaging_status.mojom"; |
Daniel Cheng | 7a059b0 | 2018-02-03 10:04:13 | [diff] [blame] | 8 | import "url/mojom/url.mojom"; |
ke.he | 5f426e32 | 2017-02-22 12:37:12 | [diff] [blame] | 9 | |
| 10 | // TODO(heke): The type-mapping struct and enums are duplicately defined. Need |
| 11 | // to remove/replace those defined in content or blink namespace. |
| 12 | |
| 13 | struct PushSubscriptionOptions { |
| 14 | bool user_visible_only; |
| 15 | string sender_info; |
| 16 | }; |
| 17 | |
ke.he | 5f426e32 | 2017-02-22 12:37:12 | [diff] [blame] | 18 | enum PushErrorType { |
| 19 | ABORT = 0, |
| 20 | NETWORK = 1, |
ke.he | dc9d2cf | 2017-02-28 05:07:33 | [diff] [blame] | 21 | NONE = 2, |
| 22 | NOT_ALLOWED = 3, |
| 23 | NOT_FOUND = 4, |
| 24 | NOT_SUPPORTED = 5, |
ke.he | 5f426e32 | 2017-02-22 12:37:12 | [diff] [blame] | 25 | INVALID_STATE = 6, |
ke.he | 5f426e32 | 2017-02-22 12:37:12 | [diff] [blame] | 26 | }; |
| 27 | |
ke.he | 5f426e32 | 2017-02-22 12:37:12 | [diff] [blame] | 28 | interface PushMessaging { |
| 29 | Subscribe(int32 render_frame_id, |
| 30 | int64 service_worker_registration_id, |
dominickn | 6ba3fa62 | 2017-06-16 06:14:46 | [diff] [blame] | 31 | PushSubscriptionOptions options, |
| 32 | bool user_gesture) |
ke.he | 5f426e32 | 2017-02-22 12:37:12 | [diff] [blame] | 33 | => (PushRegistrationStatus status, |
| 34 | url.mojom.Url? endpoint, |
| 35 | PushSubscriptionOptions? options, |
| 36 | array<uint8>? p256dh, |
| 37 | array<uint8>? auth); |
| 38 | |
ke.he | dc9d2cf | 2017-02-28 05:07:33 | [diff] [blame] | 39 | // We use the value of |error_type| as a flag. If |error_type| == NONE, it |
| 40 | // means no error and returns |did_unsubscribe|. Else, it means there is an |
| 41 | // error and returns |error_type| and |error_message|. |
ke.he | 5f426e32 | 2017-02-22 12:37:12 | [diff] [blame] | 42 | Unsubscribe(int64 service_worker_registration_id) |
ke.he | dc9d2cf | 2017-02-28 05:07:33 | [diff] [blame] | 43 | => (PushErrorType error_type, |
ke.he | 5f426e32 | 2017-02-22 12:37:12 | [diff] [blame] | 44 | bool did_unsubscribe, |
ke.he | 5f426e32 | 2017-02-22 12:37:12 | [diff] [blame] | 45 | string? error_message); |
| 46 | |
| 47 | GetSubscription(int64 service_worker_registration_id) |
| 48 | => (PushGetRegistrationStatus status, |
| 49 | url.mojom.Url? endpoint, |
| 50 | PushSubscriptionOptions? options, |
| 51 | array<uint8>? p256dh, |
| 52 | array<uint8>? auth); |
ke.he | 5f426e32 | 2017-02-22 12:37:12 | [diff] [blame] | 53 | }; |