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 module presentation; | 5 module presentation; |
6 | 6 |
7 struct PresentationSessionInfo { | 7 struct PresentationSessionInfo { |
8 string url; | 8 string url; |
9 string id; | 9 string id; |
10 }; | 10 }; |
11 | 11 |
12 enum PresentationSessionState { | 12 enum PresentationSessionState { |
13 CONNECTED, | 13 CONNECTED, |
14 DISCONNECTED | 14 DISCONNECTED |
15 }; | 15 }; |
16 | 16 |
17 enum PresentationErrorType { | 17 enum PresentationErrorType { |
18 NO_AVAILABLE_SCREENS, | 18 NO_AVAILABLE_SCREENS, |
19 SESSION_REQUEST_CANCELLED, | 19 SESSION_REQUEST_CANCELLED, |
20 NO_PRESENTATION_FOUND, | 20 NO_PRESENTATION_FOUND, |
21 UNKNOWN, | 21 UNKNOWN, |
22 }; | 22 }; |
23 | 23 |
24 struct PresentationError { | 24 struct PresentationError { |
25 PresentationErrorType error_type; | 25 PresentationErrorType error_type; |
26 string message; | 26 string message; |
27 }; | 27 }; |
28 | 28 |
29 enum PresentationMessageType { | 29 enum PresentationMessageType { |
30 TEXT, | 30 TEXT, |
31 ARRAY_BUFFER, | 31 ARRAY_BUFFER, |
32 }; | 32 }; |
33 | 33 |
34 struct SessionMessage { | 34 struct SessionMessage { |
35 string presentation_url; | 35 string presentation_url; |
36 string presentation_id; | 36 string presentation_id; |
37 PresentationMessageType type; | 37 PresentationMessageType type; |
38 string? message; | 38 string? message; |
39 array<uint8>? data; | 39 array<uint8>? data; |
40 }; | 40 }; |
41 | 41 |
42 interface PresentationService { | 42 interface PresentationService { |
43 // Called when the frame sets or changes the default presentation URL or | 43 // Called when the frame sets or changes the default presentation URL or |
44 // presentation ID. | 44 // presentation ID. |
45 SetDefaultPresentationURL( | 45 SetDefaultPresentationURL( |
46 string default_presentation_url, | 46 string default_presentation_url, |
47 string? default_presentation_id); | 47 string? default_presentation_id); |
48 | 48 |
49 // Returns the last screen availability state if it’s changed since the last | 49 // Sets the PresentationServiceClient. |
50 // time the method was called. The client has to call this method again when | 50 SetClient(PresentationServiceClient client); |
51 // handling the result (provided via Mojo callback) to get the next update | |
52 // about the availability status. | |
53 // May start discovery of the presentation screens. The implementation might | |
54 // stop discovery once there are no active calls to | |
55 // ListenForScreenAvailability. |presentation_url| can be specified to help | |
56 // the implementation to filter out incompatible screens. | |
57 ListenForScreenAvailability(string? presentation_url) => | |
58 (string? presentation_url, bool available); | |
59 | 51 |
60 // Called when the frame no longer listens to the |availablechange| event. | 52 // Starts listening for screen availability for the current default |
61 RemoveScreenAvailabilityListener(string? presentation_url); | 53 // presentation URL. Availability results will be returned to the client |
| 54 // via PresentationServiceClient::OnScreenAvailabilityUpdated. |
| 55 ListenForScreenAvailability(); |
62 | 56 |
63 // Called when the renderer is ready to receive the browser initiated | 57 // Stops listening for screen availability for the current default |
64 // session. If the default session is started by the embedder before this | 58 // default presentation URL. The client will stop receiving availability |
65 // call, the embedder may queue it and run the callback when the call is | 59 // updates. |
66 // performed. | 60 StopListeningForScreenAvailability(); |
67 ListenForDefaultSessionStart() | |
68 => (PresentationSessionInfo? defaultSessionInfo); | |
69 | 61 |
70 // Called when startSession() is called by the frame. The result callback | 62 // Called when the renderer is ready to receive the browser initiated |
71 // will return a non-null and valid PresentationSessionInfo if starting the | 63 // session. If the default session is started by the embedder before this |
72 // session succeeded, or null with a PresentationError if starting the | 64 // call, the embedder may queue it and run the callback when the call is |
73 // session failed. | 65 // performed. |
74 // The presentation id is always returned along with the initialized | 66 ListenForDefaultSessionStart() |
75 // session on success. | 67 => (PresentationSessionInfo? defaultSessionInfo); |
76 // If the UA identifies a matching session (same presentation url and id), | |
77 // the user may choose this existing session and the page will join it | |
78 // rather than get a new one. An empty presentation id means that the | |
79 // UA will generate the presentation id. | |
80 StartSession(string presentation_url, string? presentation_id) | |
81 => (PresentationSessionInfo? sessionInfo, PresentationError? error); | |
82 | 68 |
83 // Called when joinSession() is called by the frame. The result callback | 69 // Called when startSession() is called by the frame. The result callback |
84 // works the same as for the method above. JoinSession will join a known | 70 // will return a non-null and valid PresentationSessionInfo if starting the |
85 // session (i.e. when the page navigates or the user opens another tab) | 71 // session succeeded, or null with a PresentationError if starting the |
86 // silently and without user action. | 72 // session failed. |
87 JoinSession(string presentation_url, string? presentation_id) | 73 // The presentation id is always returned along with the initialized |
88 => (PresentationSessionInfo? sessionInfo, PresentationError? error); | 74 // session on success. |
| 75 // If the UA identifies a matching session (same presentation url and id), |
| 76 // the user may choose this existing session and the page will join it |
| 77 // rather than get a new one. An empty presentation id means that the |
| 78 // UA will generate the presentation id. |
| 79 StartSession(string presentation_url, string? presentation_id) |
| 80 => (PresentationSessionInfo? sessionInfo, PresentationError? error); |
89 | 81 |
90 // Called when send() is called by the frame. The true in the | 82 // Called when joinSession() is called by the frame. The result callback |
91 // result callback notifies that the service is ready for next message. | 83 // works the same as for the method above. JoinSession will join a known |
92 // The false in the result callback notifies the renderer to stop sending | 84 // session (i.e. when the page navigates or the user opens another tab) |
93 // the send requests and invalidate all pending requests. This occurs | 85 // silently and without user action. |
94 // for eg., when frame is deleted or navigated away. | 86 JoinSession(string presentation_url, string? presentation_id) |
95 SendSessionMessage(SessionMessage message_request) => (bool success); | 87 => (PresentationSessionInfo? sessionInfo, PresentationError? error); |
96 | 88 |
97 // Called when closeSession() is called by the frame. | 89 // Called when send() is called by the frame. The true in the |
98 CloseSession(string presentation_url, string presentation_id); | 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(SessionMessage message_request) => (bool success); |
| 95 |
| 96 // Called when closeSession() is called by the frame. |
| 97 CloseSession(string presentation_url, string presentation_id); |
99 | 98 |
100 // Called when the frame is ready to process the next state change. Returns | 99 // Called when the frame is ready to process the next state change. Returns |
101 // the last session state if it’s changed since the last time the callback | 100 // the last session state if it’s changed since the last time the callback |
102 // was called. Might cause the event fired with the initial state change. | 101 // was called. Might cause the event fired with the initial state change. |
103 ListenForSessionStateChange() | 102 ListenForSessionStateChange() |
104 => (PresentationSessionInfo sessionInfo, | 103 => (PresentationSessionInfo sessionInfo, |
105 PresentationSessionState newState); | 104 PresentationSessionState newState); |
106 | 105 |
107 // Called when the frame is ready to process the next batch of messages. | 106 // Called when the frame is ready to process the next batch of messages. |
108 // When the callback carries null messages, there is an error | 107 // When the callback carries null messages, there is an error |
109 // at the presentation service side. | 108 // at the presentation service side. |
110 ListenForSessionMessages() | 109 ListenForSessionMessages() |
111 => (array<SessionMessage>? messages); | 110 => (array<SessionMessage>? messages); |
112 }; | 111 }; |
| 112 |
| 113 interface PresentationServiceClient { |
| 114 OnScreenAvailabilityUpdated(bool available); |
| 115 }; |
OLD | NEW |