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. |
| 55 // |proxy|: proxy of blink connection object initiating send String message |
| 56 // request. Does not pass ownership. |
61 virtual void sendString(const WebURL& presentationUrl, | 57 virtual void sendString(const WebURL& presentationUrl, |
62 const WebString& presentationId, | 58 const WebString& presentationId, |
63 const WebString& message) = 0; | 59 const WebString& message, |
| 60 const WebPresentationConnectionProxy*) = 0; |
64 | 61 |
65 // Called when the frame requests to send ArrayBuffer/View data to an existing | 62 // 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. | 63 // session. Embedder copies the |data| and the ownership is not transferred. |
| 64 // |proxy|: proxy of blink connection object initiating send ArrayBuffer |
| 65 // request. Does not pass ownership. |
67 virtual void sendArrayBuffer(const WebURL& presentationUrl, | 66 virtual void sendArrayBuffer(const WebURL& presentationUrl, |
68 const WebString& presentationId, | 67 const WebString& presentationId, |
69 const uint8_t* data, | 68 const uint8_t* data, |
70 size_t length) = 0; | 69 size_t length, |
| 70 const WebPresentationConnectionProxy*) = 0; |
71 | 71 |
72 // Called when the frame requests to send Blob data to an existing session. | 72 // Called when the frame requests to send Blob data to an existing session. |
73 // Embedder copies the |data| and the ownership is not transferred. | 73 // Embedder copies the |data| and the ownership is not transferred. |
| 74 // |proxy|: proxy of blink connection object initiating send Blob data |
| 75 // request. Does not pass ownership. |
74 virtual void sendBlobData(const WebURL& presentationUrl, | 76 virtual void sendBlobData(const WebURL& presentationUrl, |
75 const WebString& presentationId, | 77 const WebString& presentationId, |
76 const uint8_t* data, | 78 const uint8_t* data, |
77 size_t length) = 0; | 79 size_t length, |
| 80 const WebPresentationConnectionProxy*) = 0; |
78 | 81 |
79 // Called when the frame requests to close an existing session. | 82 // Called when the frame requests to close an existing session. |
80 virtual void closeSession(const WebURL& presentationUrl, | 83 virtual void closeSession(const WebURL& presentationUrl, |
81 const WebString& presentationId) = 0; | 84 const WebString& presentationId) = 0; |
82 | 85 |
83 // Called when the frame requests to terminate an existing session. | 86 // Called when the frame requests to terminate an existing session. |
84 virtual void terminateSession(const WebURL& presentationUrl, | 87 virtual void terminateSession(const WebURL& presentationUrl, |
85 const WebString& presentationId) = 0; | 88 const WebString& presentationId) = 0; |
86 | 89 |
87 // Called when the frame wants to know the availability of a presentation | 90 // 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; | 103 virtual void stopListening(WebPresentationAvailabilityObserver*) = 0; |
101 | 104 |
102 // Called when a defaultRequest has been set. It sends the url associated | 105 // Called when a defaultRequest has been set. It sends the url associated |
103 // with it for the embedder. | 106 // with it for the embedder. |
104 virtual void setDefaultPresentationUrls(const WebVector<WebURL>&) = 0; | 107 virtual void setDefaultPresentationUrls(const WebVector<WebURL>&) = 0; |
105 }; | 108 }; |
106 | 109 |
107 } // namespace blink | 110 } // namespace blink |
108 | 111 |
109 #endif // WebPresentationClient_h | 112 #endif // WebPresentationClient_h |
OLD | NEW |