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 interface PresentationService {
30 // Called when the frame sets or changes the default presentation URL or
32 SetDefaultPresentationURL(
33 string default_presentation_url,
34 string? default_presentation_id);
36 // Returns the last screen availability state if it’s changed since the last
37 // time the method was called. The client has to call this method again when
38 // handling the result (provided via Mojo callback) to get the next update
39 // about the availability status.
40 // May start discovery of the presentation screens. The implementation might
41 // stop discovery once there are no active calls to
42 // ListenForScreenAvailability. |presentation_url| can be specified to help
43 // the implementation to filter out incompatible screens.
44 ListenForScreenAvailability(string? presentation_url) =>
45 (string? presentation_url, bool available);
47 // Called when the frame no longer listens to the |availablechange| event.
48 RemoveScreenAvailabilityListener(string? presentation_url);
50 // Called when the renderer is ready to receive the browser initiated
51 // session. If the default session is started by the embedder before this
52 // call, the embedder may queue it and run the callback when the call is
54 ListenForDefaultSessionStart()
55 => (PresentationSessionInfo defaultSessionInfo);
57 // Called when startSession() is called by the frame. The result callback
58 // will return a non-null and valid PresentationSessionInfo if starting the
59 // session succeeded, or null with a PresentationError if starting the
61 // The presentation id is always returned along with the initialized
62 // session on success.
63 // If the UA identifies a matching session (same presentation url and id),
64 // the user may choose this existing session and the page will join it
65 // rather than get a new one. An empty presentation id means that the
66 // UA will generate the presentation id.
67 StartSession(string presentation_url, string? presentation_id)
68 => (PresentationSessionInfo? sessionInfo, PresentationError? error);
70 // Called when joinSession() is called by the frame. The result callback
71 // works the same as for the method above. JoinSession will join a known
72 // session (i.e. when the page navigates or the user opens another tab)
73 // silently and without user action.
74 JoinSession(string presentation_url, string? presentation_id)
75 => (PresentationSessionInfo? sessionInfo, PresentationError? error);
77 // Called when closeSession() is called by the frame.
78 CloseSession(string presentation_url, string presentation_id);
80 // Called when the frame is ready to process the next state change. Returns
81 // the last session state if it’s changed since the last time the callback
82 // was called. Might cause the event fired with the initial state change.
83 ListenForSessionStateChange()
84 => (PresentationSessionInfo sessionInfo,
85 PresentationSessionState newState);