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.
7 struct PresentationSessionInfo {
12 enum PresentationSessionState {
17 enum PresentationErrorType {
19 SESSION_REQUEST_CANCELLED,
20 NO_PRESENTATION_FOUND,
24 struct PresentationError {
25 PresentationErrorType error_type;
29 enum PresentationMessageType {
35 struct SessionMessage {
36 string presentation_url;
37 string presentation_id;
38 PresentationMessageType type;
39 // Used when message type is TEXT.
41 // Used when message type is ARRAY_BUFFER or BLOB.
45 interface PresentationService {
46 // Called when the frame sets or changes the default presentation URL or
48 SetDefaultPresentationURL(
49 string default_presentation_url,
50 string? default_presentation_id);
52 // Sets the PresentationServiceClient.
53 SetClient(PresentationServiceClient client);
55 // Starts listening for screen availability for the current default
56 // presentation URL. Availability results will be returned to the client
57 // via PresentationServiceClient::OnScreenAvailabilityUpdated.
58 ListenForScreenAvailability();
60 // Stops listening for screen availability for the current default
61 // default presentation URL. The client will stop receiving availability
63 StopListeningForScreenAvailability();
65 // Called when the renderer is ready to receive the browser initiated
66 // session. If the default session is started by the embedder before this
67 // call, the embedder may queue it and run the callback when the call is
69 ListenForDefaultSessionStart()
70 => (PresentationSessionInfo? defaultSessionInfo);
72 // Called when startSession() is called by the frame. The result callback
73 // will return a non-null and valid PresentationSessionInfo if starting the
74 // session succeeded, or null with a PresentationError if starting the
76 // The presentation id is always returned along with the initialized
77 // session on success.
78 // If the UA identifies a matching session (same presentation url and id),
79 // the user may choose this existing session and the page will join it
80 // rather than get a new one. An empty presentation id means that the
81 // UA will generate the presentation id.
82 StartSession(string presentation_url, string? presentation_id)
83 => (PresentationSessionInfo? sessionInfo, PresentationError? error);
85 // Called when joinSession() is called by the frame. The result callback
86 // works the same as for the method above. JoinSession will join a known
87 // session (i.e. when the page navigates or the user opens another tab)
88 // silently and without user action.
89 JoinSession(string presentation_url, string? presentation_id)
90 => (PresentationSessionInfo? sessionInfo, PresentationError? error);
92 // Called when send() is called by the frame. The true in the
93 // result callback notifies that the service is ready for next message.
94 // The false in the result callback notifies the renderer to stop sending
95 // the send requests and invalidate all pending requests. This occurs
96 // for eg., when frame is deleted or navigated away.
97 SendSessionMessage(SessionMessage message_request) => (bool success);
99 // Called when closeSession() is called by the frame.
100 CloseSession(string presentation_url, string presentation_id);
102 // Called when the frame is ready to process the next state change. Returns
103 // the last session state if it’s changed since the last time the callback
104 // was called. Might cause the event fired with the initial state change.
105 ListenForSessionStateChange()
106 => (PresentationSessionInfo sessionInfo,
107 PresentationSessionState newState);
109 // Called when the frame is ready to process the next batch of messages.
110 // When the callback carries null messages, there is an error
111 // at the presentation service side.
112 ListenForSessionMessages()
113 => (array<SessionMessage>? messages);
116 interface PresentationServiceClient {
117 OnScreenAvailabilityUpdated(bool available);