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 #ifndef WebPresentationClient_h | 5 #ifndef WebPresentationClient_h |
6 #define WebPresentationClient_h | 6 #define WebPresentationClient_h |
7 | 7 |
8 #include "public/platform/WebCallbacks.h" | 8 #include "public/platform/WebCallbacks.h" |
9 #include "public/platform/WebCommon.h" | 9 #include "public/platform/WebCommon.h" |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 class WebPresentationAvailabilityObserver; | 15 class WebPresentationAvailabilityObserver; |
16 class WebPresentationController; | 16 class WebPresentationController; |
17 class WebPresentationConnectionClient; | 17 class WebPresentationConnectionClient; |
18 class WebString; | 18 class WebString; |
19 struct WebPresentationError; | 19 struct WebPresentationError; |
| 20 template <typename T> |
| 21 class WebVector; |
20 | 22 |
21 // If session was created, callback's onSuccess() is invoked with the informatio
n about the | 23 // If session was created, callback's onSuccess() is invoked with the informatio
n about the |
22 // presentation session created by the embedder. Otherwise, onError() is invoked
with the error code | 24 // presentation session created by the embedder. Otherwise, onError() is invoked
with the error code |
23 // and message. | 25 // and message. |
24 using WebPresentationConnectionClientCallbacks = WebCallbacks<std::unique_ptr<We
bPresentationConnectionClient>, const WebPresentationError&>; | 26 using WebPresentationConnectionClientCallbacks = WebCallbacks<std::unique_ptr<We
bPresentationConnectionClient>, const WebPresentationError&>; |
25 | 27 |
26 // Callback for .getAvailability(). | 28 // Callback for .getAvailability(). |
27 using WebPresentationAvailabilityCallbacks = WebCallbacks<bool, const WebPresent
ationError&>; | 29 using WebPresentationAvailabilityCallbacks = WebCallbacks<bool, const WebPresent
ationError&>; |
28 | 30 |
29 // The implementation the embedder has to provide for the Presentation API to wo
rk. | 31 // The implementation the embedder has to provide for the Presentation API to wo
rk. |
| 32 // TODO(crbug.com/632623): Use WebURL instead of WebString in this API. |
30 class WebPresentationClient { | 33 class WebPresentationClient { |
31 public: | 34 public: |
32 virtual ~WebPresentationClient() { } | 35 virtual ~WebPresentationClient() { } |
33 | 36 |
34 // Passes the Blink-side delegate to the embedder. | 37 // Passes the Blink-side delegate to the embedder. |
35 virtual void setController(WebPresentationController*) = 0; | 38 virtual void setController(WebPresentationController*) = 0; |
36 | 39 |
37 // Called when the frame requests to start a new session. | 40 // Called when the frame requests to start a new session. |
38 // The ownership of the |callbacks| argument is transferred to the embedder. | 41 // The ownership of the |callbacks| argument is transferred to the embedder. |
39 virtual void startSession(const WebString& presentationUrl, WebPresentationC
onnectionClientCallbacks*) = 0; | 42 virtual void startSession(const WebVector<WebString>& presentationUrls, WebP
resentationConnectionClientCallbacks*) = 0; |
40 | 43 |
41 // Called when the frame requests to join an existing session. | 44 // Called when the frame requests to join an existing session. |
42 // The ownership of the |callbacks| argument is transferred to the embedder. | 45 // The ownership of the |callbacks| argument is transferred to the embedder. |
43 virtual void joinSession(const WebString& presentationUrl, const WebString&
presentationId, WebPresentationConnectionClientCallbacks*) = 0; | 46 virtual void joinSession(const WebVector<WebString>& presentationUrls, const
WebString& presentationId, WebPresentationConnectionClientCallbacks*) = 0; |
44 | 47 |
45 // Called when the frame requests to send String message to an existing sess
ion. | 48 // Called when the frame requests to send String message to an existing sess
ion. |
| 49 |
46 virtual void sendString(const WebString& presentationUrl, const WebString& p
resentationId, const WebString& message) = 0; | 50 virtual void sendString(const WebString& presentationUrl, const WebString& p
resentationId, const WebString& message) = 0; |
47 | 51 |
48 // Called when the frame requests to send ArrayBuffer/View data to an existi
ng session. | 52 // Called when the frame requests to send ArrayBuffer/View data to an existi
ng session. |
49 // Embedder copies the |data| and the ownership is not transferred. | 53 // Embedder copies the |data| and the ownership is not transferred. |
50 virtual void sendArrayBuffer(const WebString& presentationUrl, const WebStri
ng& presentationId, const uint8_t* data, size_t length) = 0; | 54 virtual void sendArrayBuffer(const WebString& presentationUrl, const WebStri
ng& presentationId, const uint8_t* data, size_t length) = 0; |
51 | 55 |
52 // Called when the frame requests to send Blob data to an existing session. | 56 // Called when the frame requests to send Blob data to an existing session. |
53 // Embedder copies the |data| and the ownership is not transferred. | 57 // Embedder copies the |data| and the ownership is not transferred. |
54 virtual void sendBlobData(const WebString& presentationUrl, const WebString&
presentationId, const uint8_t* data, size_t length) = 0; | 58 virtual void sendBlobData(const WebString& presentationUrl, const WebString&
presentationId, const uint8_t* data, size_t length) = 0; |
55 | 59 |
(...skipping 12 matching lines...) Expand all Loading... |
68 // observer will be notified in case of a change. The observer is | 72 // observer will be notified in case of a change. The observer is |
69 // respensible to call stopListening() before being destroyed. | 73 // respensible to call stopListening() before being destroyed. |
70 virtual void startListening(WebPresentationAvailabilityObserver*) = 0; | 74 virtual void startListening(WebPresentationAvailabilityObserver*) = 0; |
71 | 75 |
72 // Stop listening to changes in presentation displays availability. The | 76 // Stop listening to changes in presentation displays availability. The |
73 // observer will no longer be notified in case of a change. | 77 // observer will no longer be notified in case of a change. |
74 virtual void stopListening(WebPresentationAvailabilityObserver*) = 0; | 78 virtual void stopListening(WebPresentationAvailabilityObserver*) = 0; |
75 | 79 |
76 // Called when a defaultRequest has been set. It sends the url associated | 80 // Called when a defaultRequest has been set. It sends the url associated |
77 // with it for the embedder. | 81 // with it for the embedder. |
78 virtual void setDefaultPresentationUrl(const WebString&) = 0; | 82 virtual void setDefaultPresentationUrls(const WebVector<WebString>&) = 0; |
79 }; | 83 }; |
80 | 84 |
81 } // namespace blink | 85 } // namespace blink |
82 | 86 |
83 #endif // WebPresentationClient_h | 87 #endif // WebPresentationClient_h |
OLD | NEW |