| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // TODO(crbug.com/647290): Rename "Session" to "Connection" | |
| 6 | |
| 7 module blink.mojom; | 5 module blink.mojom; |
| 8 | 6 |
| 9 import "url/mojo/url.mojom"; | 7 import "url/mojo/url.mojom"; |
| 10 | 8 |
| 11 struct PresentationSessionInfo { | 9 struct PresentationInfo { |
| 12 url.mojom.Url url; | 10 url.mojom.Url url; |
| 13 string id; | 11 string id; |
| 14 }; | 12 }; |
| 15 | 13 |
| 16 enum PresentationConnectionState { | 14 enum PresentationConnectionState { |
| 17 CONNECTING, | 15 CONNECTING, |
| 18 CONNECTED, | 16 CONNECTED, |
| 19 CLOSED, | 17 CLOSED, |
| 20 TERMINATED | 18 TERMINATED |
| 21 }; | 19 }; |
| 22 | 20 |
| 23 enum PresentationConnectionCloseReason { | 21 enum PresentationConnectionCloseReason { |
| 24 CONNECTION_ERROR, | 22 CONNECTION_ERROR, |
| 25 CLOSED, | 23 CLOSED, |
| 26 WENT_AWAY | 24 WENT_AWAY |
| 27 }; | 25 }; |
| 28 | 26 |
| 29 enum PresentationErrorType { | 27 enum PresentationErrorType { |
| 30 NO_AVAILABLE_SCREENS, | 28 NO_AVAILABLE_SCREENS, |
| 31 SESSION_REQUEST_CANCELLED, | 29 PRESENTATION_REQUEST_CANCELLED, |
| 32 NO_PRESENTATION_FOUND, | 30 NO_PRESENTATION_FOUND, |
| 33 PREVIOUS_START_IN_PROGRESS, | 31 PREVIOUS_START_IN_PROGRESS, |
| 34 UNKNOWN, | 32 UNKNOWN, |
| 35 }; | 33 }; |
| 36 | 34 |
| 37 struct PresentationError { | 35 struct PresentationError { |
| 38 PresentationErrorType error_type; | 36 PresentationErrorType error_type; |
| 39 string message; | 37 string message; |
| 40 }; | 38 }; |
| 41 | 39 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 59 }; | 57 }; |
| 60 | 58 |
| 61 interface PresentationService { | 59 interface PresentationService { |
| 62 // Sets the PresentationServiceClient. | 60 // Sets the PresentationServiceClient. |
| 63 SetClient(PresentationServiceClient client); | 61 SetClient(PresentationServiceClient client); |
| 64 | 62 |
| 65 ///////////// Functions here are for the controller part of the API. ///////// | 63 ///////////// Functions here are for the controller part of the API. ///////// |
| 66 | 64 |
| 67 // Called when the frame sets or changes the default presentation URLs. | 65 // Called when the frame sets or changes the default presentation URLs. |
| 68 // When the default presentation is started on this frame, | 66 // When the default presentation is started on this frame, |
| 69 // PresentationServiceClient::OnDefaultSessionStarted will be invoked. | 67 // PresentationServiceClient::OnDefaultPresentationStarted will be invoked. |
| 70 SetDefaultPresentationUrls(array<url.mojom.Url> presentation_urls); | 68 SetDefaultPresentationUrls(array<url.mojom.Url> presentation_urls); |
| 71 | 69 |
| 72 // Starts listening for screen availability for presentation of | 70 // Starts listening for screen availability for presentation of |
| 73 // |availability_url|. Availability results will be returned to the client via | 71 // |availability_url|. Availability results will be returned to the client via |
| 74 // PresentationServiceClient::OnScreenAvailabilityUpdated. | 72 // PresentationServiceClient::OnScreenAvailabilityUpdated. |
| 75 ListenForScreenAvailability(url.mojom.Url availability_url); | 73 ListenForScreenAvailability(url.mojom.Url availability_url); |
| 76 | 74 |
| 77 // Stops listening for screen availability for the presentation of |url|. The | 75 // Stops listening for screen availability for the presentation of |url|. The |
| 78 // PresentationServiceClient will stop receiving availability updates for | 76 // PresentationServiceClient will stop receiving availability updates for |
| 79 // |url|. | 77 // |url|. |
| 80 StopListeningForScreenAvailability(url.mojom.Url availability_url); | 78 StopListeningForScreenAvailability(url.mojom.Url availability_url); |
| 81 | 79 |
| 82 // Called when startSession() is called by the frame. The result callback | 80 // Called when start() is called by the frame. The result callback |
| 83 // will return a non-null and valid PresentationSessionInfo if starting the | 81 // will return a non-null and valid PresentationInfo if starting the |
| 84 // session succeeded, or null with a PresentationError if starting the | 82 // presentation succeeded, or null with a PresentationError if starting the |
| 85 // session failed. | 83 // presentation failed. |
| 86 // The presentation id returned in |sessionInfo| on success is generated by | 84 StartPresentation(array<url.mojom.Url> presentation_urls) |
| 87 // the UA. | 85 => (PresentationInfo? presentation_info, PresentationError? error); |
| 88 // If the UA identifies a matching session (same presentation url), the user | |
| 89 // may choose this existing session and the page will join it rather than get | |
| 90 // a new one. | |
| 91 StartSession(array<url.mojom.Url> presentation_urls) | |
| 92 => (PresentationSessionInfo? sessionInfo, PresentationError? error); | |
| 93 | 86 |
| 94 // Called when joinSession() is called by the frame. The result callback | 87 // Called when reconnect() is called by the frame. The result callback |
| 95 // works the same as for the method above. JoinSession will join a known | 88 // works the same as for the method above. reconnect() will create a new |
| 96 // session (i.e. when the page navigates or the user opens another tab) | 89 // connection to a presentation with the matching URL and id. |
| 97 // silently and without user action. | 90 ReconnectPresentation(array<url.mojom.Url> presentation_urls, string? presenta
tion_id) |
| 98 JoinSession(array<url.mojom.Url> presentation_urls, string? presentation_id) | 91 => (PresentationInfo? presentation_info, PresentationError? error); |
| 99 => (PresentationSessionInfo? sessionInfo, PresentationError? error); | |
| 100 | 92 |
| 101 // Called in StartSession's callback function for offscreen presentation only. | 93 // Called in StartPresentation's callback function for offscreen presentation
only. |
| 102 // It passes in controlling frame's PresentationConnection and | 94 // It passes in controlling frame's PresentationConnection and |
| 103 // PresentationConnectionRequest to PresentationService. | 95 // PresentationConnectionRequest to PresentationService. |
| 104 SetPresentationConnection( | 96 SetPresentationConnection( |
| 105 PresentationSessionInfo sessionInfo, | 97 PresentationInfo presentation_info, |
| 106 PresentationConnection controller_connection_ptr, | 98 PresentationConnection controller_connection_ptr, |
| 107 PresentationConnection& receiver_connection_request); | 99 PresentationConnection& receiver_connection_request); |
| 108 | 100 |
| 109 ////////////////////////////////////////////////////////////////////////////// | 101 ////////////////////////////////////////////////////////////////////////////// |
| 110 // Called when close() is called by the frame. | 102 // Called when close() is called by the frame. |
| 111 CloseConnection(url.mojom.Url presentation_url, string presentation_id); | 103 CloseConnection(url.mojom.Url presentation_url, string presentation_id); |
| 112 | 104 |
| 113 // Called when terminate() is called by the frame. | 105 // Called when terminate() is called by the frame. |
| 114 Terminate(url.mojom.Url presentation_url, string presentation_id); | 106 Terminate(url.mojom.Url presentation_url, string presentation_id); |
| 115 | 107 |
| 116 // Starts listening for messages for session with |sessionInfo|. | 108 // Starts listening for messages on the presentation identified by |presentati
on_info|. |
| 117 // Messages will be received in | 109 // Messages will be received in |
| 118 // PresentationServiceClient::OnConnectionMessagesReceived. | 110 // PresentationServiceClient::OnConnectionMessagesReceived. |
| 119 // This is called after a presentation session is created. | 111 // This is called after a connection has been established to the presentation |
| 120 ListenForConnectionMessages(PresentationSessionInfo sessionInfo); | 112 // from the frame. |
| 121 }; | 113 ListenForConnectionMessages(PresentationInfo presentation_info); |
| 114 }; |
| 122 | 115 |
| 123 interface PresentationServiceClient { | 116 interface PresentationServiceClient { |
| 124 | 117 ////////// This API is implemented by a controlling frame. ///////////////// |
| 125 ////////////Functions here are called only on the controlling page./////////// | |
| 126 | 118 |
| 127 // Called when the client tries to listen for screen availability changes for | 119 // Called when the client tries to listen for screen availability changes for |
| 128 // presentation of |url| but it is not supported by the device or underlying | 120 // presentation of |url| but it is not supported by the device or underlying |
| 129 // platform. This can also be called if the device is currently in a mode | 121 // platform. This can also be called if the device is currently in a mode |
| 130 // where it can't do screen discoveries (eg. low battery). | 122 // where it can't do screen discoveries (eg. low battery). |
| 131 OnScreenAvailabilityNotSupported(url.mojom.Url url); | 123 OnScreenAvailabilityNotSupported(url.mojom.Url url); |
| 132 | 124 |
| 133 // Called when the client is listening for screen availability for | 125 // Called when the client is listening for screen availability for |
| 134 // presentation of |url| and the state changes. When the client starts to | 126 // presentation of |url| and the state changes. When the client starts to |
| 135 // listen for screen availability, this method will always be called to give | 127 // listen for screen availability, this method will always be called to give |
| 136 // the current known state. It will then be called to notify of state updates. | 128 // the current known state. It will then be called to notify of state updates. |
| 137 OnScreenAvailabilityUpdated(url.mojom.Url url, bool available); | 129 OnScreenAvailabilityUpdated(url.mojom.Url url, bool available); |
| 138 | 130 |
| 139 // See PresentationService::SetDefaultPresentationURL. | 131 // See PresentationService::SetDefaultPresentationURL. |
| 140 OnDefaultSessionStarted(PresentationSessionInfo sessionInfo); | 132 OnDefaultPresentationStarted(PresentationInfo presentation_info); |
| 141 | 133 |
| 142 ////////////////////////////////////////////////////////////////////////////// | 134 ////////// This API is implemented by an offscreen presentation frame. ///// |
| 135 |
| 136 // Called on a presentation receiver when a connection for |presentation_info| |
| 137 // is available from the controlling page. |
| 138 OnReceiverConnectionAvailable( |
| 139 PresentationInfo presentation_info, |
| 140 PresentationConnection controller_connection_ptr, |
| 141 PresentationConnection& receiver_connection_request); |
| 142 |
| 143 ////////// This API is implemented by both frame types. //////////////////// |
| 143 | 144 |
| 144 // Called when the state of PresentationConnection |connection| started on | 145 // Called when the state of PresentationConnection |connection| started on |
| 145 // this frame has changed to |newState|. | 146 // this frame has changed to |newState|. |
| 146 OnConnectionStateChanged(PresentationSessionInfo connection, | 147 OnConnectionStateChanged(PresentationInfo presentation_info, |
| 147 PresentationConnectionState newState); | 148 PresentationConnectionState newState); |
| 148 | 149 |
| 149 // Caled when the state of |connection| started on this frame has changed to | 150 // Caled when the state of |presentation_info| started on this frame has chang
ed to |
| 150 // CLOSED. | 151 // CLOSED. |
| 151 OnConnectionClosed(PresentationSessionInfo connection, | 152 OnConnectionClosed(PresentationInfo presentation_info, |
| 152 PresentationConnectionCloseReason reason, | 153 PresentationConnectionCloseReason reason, |
| 153 string message); | 154 string message); |
| 154 | 155 |
| 155 // See PresentationService::ListenForConnectionMessages. | 156 // See PresentationService::ListenForConnectionMessages. |
| 156 OnConnectionMessagesReceived(PresentationSessionInfo sessionInfo, | 157 OnConnectionMessagesReceived(PresentationInfo presentation_info, |
| 157 array<PresentationConnectionMessage> messages); | 158 array<PresentationConnectionMessage> messages); |
| 158 | 159 |
| 159 // Called on a presentation receiver when presentation connection is available | 160 |
| 160 // from the controlling page. | |
| 161 OnReceiverConnectionAvailable( | |
| 162 PresentationSessionInfo sessionInfo, | |
| 163 PresentationConnection controller_connection_ptr, | |
| 164 PresentationConnection& receiver_connection_request); | |
| 165 }; | 161 }; |
| OLD | NEW |