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 }; |
(...skipping 24 matching lines...) Expand all Loading... |
35 struct SessionMessage { | 35 struct SessionMessage { |
36 PresentationMessageType type; | 36 PresentationMessageType type; |
37 // Used when message type is TEXT. | 37 // Used when message type is TEXT. |
38 string? message; | 38 string? message; |
39 // Used when message type is ARRAY_BUFFER or BLOB. | 39 // Used when message type is ARRAY_BUFFER or BLOB. |
40 array<uint8>? data; | 40 array<uint8>? data; |
41 }; | 41 }; |
42 | 42 |
43 interface PresentationService { | 43 interface PresentationService { |
44 // Called when the frame sets or changes the default presentation URL. | 44 // Called when the frame sets or changes the default presentation URL. |
| 45 // When the default presentation is started on this frame, |
| 46 // PresentationServiceClient::OnDefaultPresentationStarted will be invoked. |
45 SetDefaultPresentationURL(string url); | 47 SetDefaultPresentationURL(string url); |
46 | 48 |
47 // Sets the PresentationServiceClient. | 49 // Sets the PresentationServiceClient. |
48 SetClient(PresentationServiceClient client); | 50 SetClient(PresentationServiceClient client); |
49 | 51 |
50 // Starts listening for screen availability for presentation of | 52 // Starts listening for screen availability for presentation of |
51 // |url|. Availability results will be returned to the client via | 53 // |url|. Availability results will be returned to the client via |
52 // PresentationServiceClient::OnScreenAvailabilityUpdated. | 54 // PresentationServiceClient::OnScreenAvailabilityUpdated. |
53 ListenForScreenAvailability(string url); | 55 ListenForScreenAvailability(string url); |
54 | 56 |
55 // Stops listening for screen availability for the presentation of |url|. The | 57 // Stops listening for screen availability for the presentation of |url|. The |
56 // PresentationServiceClient will stop receiving availability updates for | 58 // PresentationServiceClient will stop receiving availability updates for |
57 // |url|. | 59 // |url|. |
58 StopListeningForScreenAvailability(string url); | 60 StopListeningForScreenAvailability(string url); |
59 | 61 |
60 // Called when the renderer is ready to receive the browser initiated | |
61 // session. If the default session is started by the embedder before this | |
62 // call, the embedder may queue it and run the callback when the call is | |
63 // performed. | |
64 ListenForDefaultSessionStart() | |
65 => (PresentationSessionInfo? defaultSessionInfo); | |
66 | |
67 // Called when startSession() is called by the frame. The result callback | 62 // Called when startSession() is called by the frame. The result callback |
68 // will return a non-null and valid PresentationSessionInfo if starting the | 63 // will return a non-null and valid PresentationSessionInfo if starting the |
69 // session succeeded, or null with a PresentationError if starting the | 64 // session succeeded, or null with a PresentationError if starting the |
70 // session failed. | 65 // session failed. |
71 // The presentation id returned in |sessionInfo| on success is generated by | 66 // The presentation id returned in |sessionInfo| on success is generated by |
72 // the UA. | 67 // the UA. |
73 // If the UA identifies a matching session (same presentation url), the user | 68 // If the UA identifies a matching session (same presentation url), the user |
74 // may choose this existing session and the page will join it rather than get | 69 // may choose this existing session and the page will join it rather than get |
75 // a new one. | 70 // a new one. |
76 StartSession(string presentation_url) | 71 StartSession(string presentation_url) |
77 => (PresentationSessionInfo? sessionInfo, PresentationError? error); | 72 => (PresentationSessionInfo? sessionInfo, PresentationError? error); |
78 | 73 |
79 // Called when joinSession() is called by the frame. The result callback | 74 // Called when joinSession() is called by the frame. The result callback |
80 // works the same as for the method above. JoinSession will join a known | 75 // works the same as for the method above. JoinSession will join a known |
81 // session (i.e. when the page navigates or the user opens another tab) | 76 // session (i.e. when the page navigates or the user opens another tab) |
82 // silently and without user action. | 77 // silently and without user action. |
83 JoinSession(string presentation_url, string? presentation_id) | 78 JoinSession(string presentation_url, string? presentation_id) |
84 => (PresentationSessionInfo? sessionInfo, PresentationError? error); | 79 => (PresentationSessionInfo? sessionInfo, PresentationError? error); |
85 | 80 |
86 // Called when send() is called by the frame. The true in the | 81 // Called when send() is called by the frame. The true in the |
87 // result callback notifies that the service is ready for next message. | 82 // result callback notifies that the service is ready for next message. |
88 // The false in the result callback notifies the renderer to stop sending | 83 // The false in the result callback notifies the renderer to stop sending |
89 // the send requests and invalidate all pending requests. This occurs | 84 // the send requests and invalidate all pending requests. This occurs |
90 // for eg., when frame is deleted or navigated away. | 85 // for eg., when frame is deleted or navigated away. |
91 SendSessionMessage(PresentationSessionInfo sessionInfo, SessionMessage message
_request) => (bool success); | 86 SendSessionMessage(PresentationSessionInfo sessionInfo, |
| 87 SessionMessage message_request) => (bool success); |
92 | 88 |
93 // Called when closeSession() is called by the frame. | 89 // Called when closeSession() is called by the frame. |
94 CloseSession(string presentation_url, string presentation_id); | 90 CloseSession(string presentation_url, string presentation_id); |
95 | 91 |
96 // Starts listening for state changes for session with |sessionInfo|. | 92 // Starts listening for state changes for session with |sessionInfo|. |
97 // When state change occurs, PresentationServiceClient::OnSessionStateChanged | 93 // When state change occurs, PresentationServiceClient::OnSessionStateChanged |
98 // will be invoked with the session and its new state. | 94 // will be invoked with the session and its new state. |
99 // This is called after a presentation session is created. | 95 // This is called after a presentation session is created. |
100 ListenForSessionStateChange(PresentationSessionInfo sessionInfo); | 96 ListenForSessionStateChange(PresentationSessionInfo sessionInfo); |
101 | 97 |
102 // Starts listening for messages for session with |sessionInfo|. | 98 // Starts listening for messages for session with |sessionInfo|. |
103 // Messages will be received in | 99 // Messages will be received in |
104 // PresentationServiceClient::OnSessionMessagesReceived. | 100 // PresentationServiceClient::OnSessionMessagesReceived. |
105 // This is called after a presentation session is created. | 101 // This is called after a presentation session is created. |
106 ListenForSessionMessages(PresentationSessionInfo sessionInfo); | 102 ListenForSessionMessages(PresentationSessionInfo sessionInfo); |
| 103 |
| 104 // Returns a PresentationSessionInfo object for this frame, if it is the main |
| 105 // frame of an offscreen presentation. Otherwise returns null. |
| 106 // The PresentationSessionInfo object returned will have url set to empty, and |
| 107 // id set to the ID of the offscreen presentation. |
| 108 // If a receiver presentation session never becomes available, null will be |
| 109 // returned right before this request becomes invalid (e.g., due to frame |
| 110 // deletion, frame navigation). |
| 111 GetPresentationReceiverSession() => (PresentationSessionInfo? session_info); |
107 }; | 112 }; |
108 | 113 |
109 interface PresentationServiceClient { | 114 interface PresentationServiceClient { |
110 // Called when the client tries to listen for screen availability changes for | 115 // Called when the client tries to listen for screen availability changes for |
111 // presentation of |url| but it is not supported by the device or underlying | 116 // presentation of |url| but it is not supported by the device or underlying |
112 // platform. This can also be called if the device is currently in a mode | 117 // platform. This can also be called if the device is currently in a mode |
113 // where it can't do screen discoveries (eg. low battery). | 118 // where it can't do screen discoveries (eg. low battery). |
114 OnScreenAvailabilityNotSupported(string url); | 119 OnScreenAvailabilityNotSupported(string url); |
115 | 120 |
116 // Called when the client is listening for screen availability for | 121 // Called when the client is listening for screen availability for |
117 // presentation of |url| and the state changes. When the client starts to | 122 // presentation of |url| and the state changes. When the client starts to |
118 // listen for screen availability, this method will always be called to give | 123 // listen for screen availability, this method will always be called to give |
119 // the current known state. It will then be called to notify of state updates. | 124 // the current known state. It will then be called to notify of state updates. |
120 OnScreenAvailabilityUpdated(string url, bool available); | 125 OnScreenAvailabilityUpdated(string url, bool available); |
121 | 126 |
122 // See PresentationService::ListenForSessionStateChange. | 127 // See PresentationService::ListenForSessionStateChange. |
123 OnSessionStateChanged(PresentationSessionInfo sessionInfo, | 128 OnSessionStateChanged(PresentationSessionInfo sessionInfo, |
124 PresentationSessionState newState); | 129 PresentationSessionState newState); |
125 | 130 |
126 // See PresentationService::ListenForSessionMessages. | 131 // See PresentationService::ListenForSessionMessages. |
127 OnSessionMessagesReceived(PresentationSessionInfo sessionInfo, array<SessionMe
ssage> messages); | 132 OnSessionMessagesReceived(PresentationSessionInfo sessionInfo, array<SessionMe
ssage> messages); |
| 133 |
| 134 // See PresentationService::SetDefaultPresentationURL. |
| 135 OnDefaultPresentationStarted(PresentationSessionInfo sessionInfo); |
128 }; | 136 }; |
OLD | NEW |