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