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.
5 #ifndef WebPresentationClient_h
6 #define WebPresentationClient_h
8 #include "public/platform/WebCallbacks.h"
9 #include "public/platform/WebCommon.h"
10 #include "public/platform/WebPassOwnPtr.h"
14 class WebPresentationAvailabilityObserver
;
15 class WebPresentationController
;
16 class WebPresentationSessionClient
;
18 struct WebPresentationError
;
20 // If session was created, callback's onSuccess() is invoked with the information about the
21 // presentation session created by the embedder. Otherwise, onError() is invoked with the error code
23 using WebPresentationSessionClientCallbacks
= WebCallbacks
<WebPassOwnPtr
<WebPresentationSessionClient
>, const WebPresentationError
&>;
25 // Callback for .getAvailability().
26 using WebPresentationAvailabilityCallbacks
= WebCallbacks
<bool, const WebPresentationError
&>;
28 // The implementation the embedder has to provide for the Presentation API to work.
29 class WebPresentationClient
{
31 virtual ~WebPresentationClient() { }
33 // Passes the Blink-side delegate to the embedder.
34 virtual void setController(WebPresentationController
*) = 0;
36 // Called when the frame requests to start a new session.
37 // The ownership of the |callbacks| argument is transferred to the embedder.
38 virtual void startSession(const WebString
& presentationUrl
, WebPresentationSessionClientCallbacks
*) = 0;
40 // Called when the frame requests to join an existing session.
41 // The ownership of the |callbacks| argument is transferred to the embedder.
42 virtual void joinSession(const WebString
& presentationUrl
, const WebString
& presentationId
, WebPresentationSessionClientCallbacks
*) = 0;
44 // Called when the frame requests to send String message to an existing session.
45 virtual void sendString(const WebString
& presentationUrl
, const WebString
& presentationId
, const WebString
& message
) = 0;
47 // Called when the frame requests to send ArrayBuffer/View data to an existing session.
48 // Embedder copies the |data| and the ownership is not transferred.
49 virtual void sendArrayBuffer(const WebString
& presentationUrl
, const WebString
& presentationId
, const uint8_t* data
, size_t length
) = 0;
51 // Called when the frame requests to send Blob data to an existing session.
52 // Embedder copies the |data| and the ownership is not transferred.
53 virtual void sendBlobData(const WebString
& presentationUrl
, const WebString
& presentationId
, const uint8_t* data
, size_t length
) = 0;
55 // Called when the frame requests to close an existing session.
56 virtual void closeSession(const WebString
& presentationUrl
, const WebString
& presentationId
) = 0;
58 // Called when the frame wants to know the availability of a presentation
59 // display for |availabilityUrl|. The ownership of the callbacks argument
60 // is transferred to the embedder.
61 virtual void getAvailability(const WebString
& availabilityUrl
, WebPresentationAvailabilityCallbacks
*) = 0;
63 // Start listening to changes in presentation displays availability. The
64 // observer will be notified in case of a change. The observer is
65 // respensible to call stopListening() before being destroyed.
66 virtual void startListening(WebPresentationAvailabilityObserver
*) = 0;
68 // Stop listening to changes in presentation displays availability. The
69 // observer will no longer be notified in case of a change.
70 virtual void stopListening(WebPresentationAvailabilityObserver
*) = 0;
72 // Called when a defaultRequest has been set. It sends the url associated
73 // with it for the embedder.
74 virtual void setDefaultPresentationUrl(const WebString
&) = 0;
79 #endif // WebPresentationClient_h