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 struct WebPresentationError; | 17 struct WebPresentationError; |
| 18 class WebPresentationConnectionCallbacks; |
| 19 class WebPresentationConnectionProxy; |
18 class WebPresentationReceiver; | 20 class WebPresentationReceiver; |
19 struct WebPresentationSessionInfo; | |
20 class WebString; | 21 class WebString; |
21 class WebURL; | 22 class WebURL; |
22 template <typename T> | 23 template <typename T> |
23 class WebVector; | 24 class WebVector; |
24 | 25 |
25 // If session was created, callback's onSuccess() is invoked with the | |
26 // information about the presentation session created by the embedder. | |
27 // Otherwise, onError() is invoked with the error code and message. | |
28 using WebPresentationConnectionCallback = | |
29 WebCallbacks<const WebPresentationSessionInfo&, | |
30 const WebPresentationError&>; | |
31 | |
32 // Callback for .getAvailability(). | 26 // Callback for .getAvailability(). |
33 using WebPresentationAvailabilityCallbacks = | 27 using WebPresentationAvailabilityCallbacks = |
34 WebCallbacks<bool, const WebPresentationError&>; | 28 WebCallbacks<bool, const WebPresentationError&>; |
35 | 29 |
36 // The implementation the embedder has to provide for the Presentation API to | 30 // The implementation the embedder has to provide for the Presentation API to |
37 // work. | 31 // work. |
38 class WebPresentationClient { | 32 class WebPresentationClient { |
39 public: | 33 public: |
40 virtual ~WebPresentationClient() {} | 34 virtual ~WebPresentationClient() {} |
41 | 35 |
42 // Passes the Blink-side delegate to the embedder. | 36 // Passes the Blink-side delegate to the embedder. |
43 virtual void setController(WebPresentationController*) = 0; | 37 virtual void setController(WebPresentationController*) = 0; |
44 | 38 |
45 // Passes the Blink-side delegate to the embedder. | 39 // Passes the Blink-side delegate to the embedder. |
46 virtual void setReceiver(WebPresentationReceiver*) = 0; | 40 virtual void setReceiver(WebPresentationReceiver*) = 0; |
47 | 41 |
48 // Called when the frame requests to start a new session. | 42 // Called when the frame requests to start a new session. |
49 virtual void startSession( | 43 virtual void startSession( |
50 const WebVector<WebURL>& presentationUrls, | 44 const WebVector<WebURL>& presentationUrls, |
51 std::unique_ptr<WebPresentationConnectionCallback>) = 0; | 45 std::unique_ptr<WebPresentationConnectionCallbacks>) = 0; |
52 | 46 |
53 // Called when the frame requests to join an existing session. | 47 // Called when the frame requests to join an existing session. |
54 virtual void joinSession( | 48 virtual void joinSession( |
55 const WebVector<WebURL>& presentationUrls, | 49 const WebVector<WebURL>& presentationUrls, |
56 const WebString& presentationId, | 50 const WebString& presentationId, |
57 std::unique_ptr<WebPresentationConnectionCallback>) = 0; | 51 std::unique_ptr<WebPresentationConnectionCallbacks>) = 0; |
58 | 52 |
59 // Called when the frame requests to send String message to an existing | 53 // Called when the frame requests to send String message to an existing |
60 // session. | 54 // session. |
61 virtual void sendString(const WebURL& presentationUrl, | 55 virtual void sendString(const WebURL& presentationUrl, |
62 const WebString& presentationId, | 56 const WebString& presentationId, |
63 const WebString& message) = 0; | 57 const WebString& message, |
| 58 const WebPresentationConnectionProxy*) = 0; |
64 | 59 |
65 // Called when the frame requests to send ArrayBuffer/View data to an existing | 60 // Called when the frame requests to send ArrayBuffer/View data to an existing |
66 // session. Embedder copies the |data| and the ownership is not transferred. | 61 // session. Embedder copies the |data| and the ownership is not transferred. |
67 virtual void sendArrayBuffer(const WebURL& presentationUrl, | 62 virtual void sendArrayBuffer(const WebURL& presentationUrl, |
68 const WebString& presentationId, | 63 const WebString& presentationId, |
69 const uint8_t* data, | 64 const uint8_t* data, |
70 size_t length) = 0; | 65 size_t length, |
| 66 const WebPresentationConnectionProxy*) = 0; |
71 | 67 |
72 // Called when the frame requests to send Blob data to an existing session. | 68 // Called when the frame requests to send Blob data to an existing session. |
73 // Embedder copies the |data| and the ownership is not transferred. | 69 // Embedder copies the |data| and the ownership is not transferred. |
74 virtual void sendBlobData(const WebURL& presentationUrl, | 70 virtual void sendBlobData(const WebURL& presentationUrl, |
75 const WebString& presentationId, | 71 const WebString& presentationId, |
76 const uint8_t* data, | 72 const uint8_t* data, |
77 size_t length) = 0; | 73 size_t length, |
| 74 const WebPresentationConnectionProxy*) = 0; |
78 | 75 |
79 // Called when the frame requests to close an existing session. | 76 // Called when the frame requests to close an existing session. |
80 virtual void closeSession(const WebURL& presentationUrl, | 77 virtual void closeSession(const WebURL& presentationUrl, |
81 const WebString& presentationId) = 0; | 78 const WebString& presentationId) = 0; |
82 | 79 |
83 // Called when the frame requests to terminate an existing session. | 80 // Called when the frame requests to terminate an existing session. |
84 virtual void terminateSession(const WebURL& presentationUrl, | 81 virtual void terminateSession(const WebURL& presentationUrl, |
85 const WebString& presentationId) = 0; | 82 const WebString& presentationId) = 0; |
86 | 83 |
87 // Called when the frame wants to know the availability of a presentation | 84 // Called when the frame wants to know the availability of a presentation |
(...skipping 12 matching lines...) Expand all Loading... |
100 virtual void stopListening(WebPresentationAvailabilityObserver*) = 0; | 97 virtual void stopListening(WebPresentationAvailabilityObserver*) = 0; |
101 | 98 |
102 // Called when a defaultRequest has been set. It sends the url associated | 99 // Called when a defaultRequest has been set. It sends the url associated |
103 // with it for the embedder. | 100 // with it for the embedder. |
104 virtual void setDefaultPresentationUrls(const WebVector<WebURL>&) = 0; | 101 virtual void setDefaultPresentationUrls(const WebVector<WebURL>&) = 0; |
105 }; | 102 }; |
106 | 103 |
107 } // namespace blink | 104 } // namespace blink |
108 | 105 |
109 #endif // WebPresentationClient_h | 106 #endif // WebPresentationClient_h |
OLD | NEW |