| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 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 // TODO(crbug.com/647290): Rename "Session" to "Connection" | |
| 6 | |
| 7 module blink.mojom; | |
| 8 | |
| 9 import "url/mojo/url.mojom"; | |
| 10 | |
| 11 struct PresentationSessionInfo { | |
| 12 url.mojom.Url url; | |
| 13 string id; | |
| 14 }; | |
| 15 | |
| 16 enum PresentationConnectionState { | |
| 17 CONNECTING, | |
| 18 CONNECTED, | |
| 19 CLOSED, | |
| 20 TERMINATED | |
| 21 }; | |
| 22 | |
| 23 enum PresentationConnectionCloseReason { | |
| 24 CONNECTION_ERROR, | |
| 25 CLOSED, | |
| 26 WENT_AWAY | |
| 27 }; | |
| 28 | |
| 29 enum PresentationErrorType { | |
| 30 NO_AVAILABLE_SCREENS, | |
| 31 SESSION_REQUEST_CANCELLED, | |
| 32 NO_PRESENTATION_FOUND, | |
| 33 UNKNOWN, | |
| 34 }; | |
| 35 | |
| 36 struct PresentationError { | |
| 37 PresentationErrorType error_type; | |
| 38 string message; | |
| 39 }; | |
| 40 | |
| 41 enum PresentationMessageType { | |
| 42 TEXT, | |
| 43 BINARY, | |
| 44 }; | |
| 45 | |
| 46 struct ConnectionMessage { | |
| 47 PresentationMessageType type; | |
| 48 // Used when message type is TEXT. | |
| 49 string? message; | |
| 50 // Used when message type is BINARY. | |
| 51 // TODO(lethalantidote): Make this a mojo union. | |
| 52 // See https://crbug.com/632623. | |
| 53 array<uint8>? data; | |
| 54 }; | |
| 55 | |
| 56 interface PresentationService { | |
| 57 // Sets the PresentationServiceClient. | |
| 58 SetClient(PresentationServiceClient client); | |
| 59 | |
| 60 // Called when the frame sets or changes the default presentation URLs. | |
| 61 // When the default presentation is started on this frame, | |
| 62 // PresentationServiceClient::OnDefaultSessionStarted will be invoked. | |
| 63 SetDefaultPresentationUrls(array<url.mojom.Url> presentation_urls); | |
| 64 | |
| 65 // Starts listening for screen availability for presentation of | |
| 66 // |availability_url|. Availability results will be returned to the client via | |
| 67 // PresentationServiceClient::OnScreenAvailabilityUpdated. | |
| 68 ListenForScreenAvailability(url.mojom.Url availability_url); | |
| 69 | |
| 70 // Stops listening for screen availability for the presentation of |url|. The | |
| 71 // PresentationServiceClient will stop receiving availability updates for | |
| 72 // |url|. | |
| 73 StopListeningForScreenAvailability(url.mojom.Url availability_url); | |
| 74 | |
| 75 // Called when startSession() is called by the frame. The result callback | |
| 76 // will return a non-null and valid PresentationSessionInfo if starting the | |
| 77 // session succeeded, or null with a PresentationError if starting the | |
| 78 // session failed. | |
| 79 // The presentation id returned in |sessionInfo| on success is generated by | |
| 80 // the UA. | |
| 81 // If the UA identifies a matching session (same presentation url), the user | |
| 82 // may choose this existing session and the page will join it rather than get | |
| 83 // a new one. | |
| 84 StartSession(array<url.mojom.Url> presentation_urls) | |
| 85 => (PresentationSessionInfo? sessionInfo, PresentationError? error); | |
| 86 | |
| 87 // Called when joinSession() is called by the frame. The result callback | |
| 88 // works the same as for the method above. JoinSession will join a known | |
| 89 // session (i.e. when the page navigates or the user opens another tab) | |
| 90 // silently and without user action. | |
| 91 JoinSession(array<url.mojom.Url> presentation_urls, string? presentation_id) | |
| 92 => (PresentationSessionInfo? sessionInfo, PresentationError? error); | |
| 93 | |
| 94 // Called when send() is called by the frame. The true in the | |
| 95 // result callback notifies that the service is ready for next message. | |
| 96 // The false in the result callback notifies the renderer to stop sending | |
| 97 // the send requests and invalidate all pending requests. This occurs | |
| 98 // for eg., when frame is deleted or navigated away. | |
| 99 SendConnectionMessage(PresentationSessionInfo sessionInfo, | |
| 100 ConnectionMessage message_request) => (bool success); | |
| 101 | |
| 102 // Called when close() is called by the frame. | |
| 103 CloseConnection(url.mojom.Url presentation_url, string presentation_id); | |
| 104 | |
| 105 // Called when terminate() is called by the frame. | |
| 106 Terminate(url.mojom.Url presentation_url, string presentation_id); | |
| 107 | |
| 108 // Starts listening for messages for session with |sessionInfo|. | |
| 109 // Messages will be received in | |
| 110 // PresentationServiceClient::OnConnectionMessagesReceived. | |
| 111 // This is called after a presentation session is created. | |
| 112 ListenForConnectionMessages(PresentationSessionInfo sessionInfo); | |
| 113 }; | |
| 114 | |
| 115 interface PresentationServiceClient { | |
| 116 // Called when the client tries to listen for screen availability changes for | |
| 117 // presentation of |url| but it is not supported by the device or underlying | |
| 118 // platform. This can also be called if the device is currently in a mode | |
| 119 // where it can't do screen discoveries (eg. low battery). | |
| 120 OnScreenAvailabilityNotSupported(url.mojom.Url url); | |
| 121 | |
| 122 // Called when the client is listening for screen availability for | |
| 123 // presentation of |url| and the state changes. When the client starts to | |
| 124 // listen for screen availability, this method will always be called to give | |
| 125 // the current known state. It will then be called to notify of state updates. | |
| 126 OnScreenAvailabilityUpdated(url.mojom.Url url, bool available); | |
| 127 | |
| 128 // Called when the state of PresentationConnection |connection| started on | |
| 129 // this frame has changed to |newState|. | |
| 130 OnConnectionStateChanged(PresentationSessionInfo connection, | |
| 131 PresentationConnectionState newState); | |
| 132 | |
| 133 // Caled when the state of |connection| started on this frame has changed to | |
| 134 // CLOSED. | |
| 135 OnConnectionClosed(PresentationSessionInfo connection, | |
| 136 PresentationConnectionCloseReason reason, | |
| 137 string message); | |
| 138 | |
| 139 // See PresentationService::ListenForConnectionMessages. | |
| 140 OnConnectionMessagesReceived(PresentationSessionInfo sessionInfo, | |
| 141 array<ConnectionMessage> messages); | |
| 142 | |
| 143 // See PresentationService::SetDefaultPresentationURL. | |
| 144 OnDefaultSessionStarted(PresentationSessionInfo sessionInfo); | |
| 145 | |
| 146 // See PresentationService::OnReceiverConnectionAvailable. | |
| 147 OnReceiverConnectionAvailable(PresentationSessionInfo sessionInfo); | |
| 148 }; | |
| OLD | NEW |