Chromium Code Reviews| 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> class WebVector; | |
| 20 | 21 |
| 21 // If session was created, callback's onSuccess() is invoked with the informatio n about the | 22 // 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 | 23 // presentation session created by the embedder. Otherwise, onError() is invoked with the error code |
| 23 // and message. | 24 // and message. |
| 24 using WebPresentationConnectionClientCallbacks = WebCallbacks<std::unique_ptr<We bPresentationConnectionClient>, const WebPresentationError&>; | 25 using WebPresentationConnectionClientCallbacks = WebCallbacks<std::unique_ptr<We bPresentationConnectionClient>, const WebPresentationError&>; |
| 25 | 26 |
| 26 // Callback for .getAvailability(). | 27 // Callback for .getAvailability(). |
| 27 using WebPresentationAvailabilityCallbacks = WebCallbacks<bool, const WebPresent ationError&>; | 28 using WebPresentationAvailabilityCallbacks = WebCallbacks<bool, const WebPresent ationError&>; |
| 28 | 29 |
| 29 // The implementation the embedder has to provide for the Presentation API to wo rk. | 30 // The implementation the embedder has to provide for the Presentation API to wo rk. |
| 30 class WebPresentationClient { | 31 class WebPresentationClient { |
| 31 public: | 32 public: |
| 32 virtual ~WebPresentationClient() { } | 33 virtual ~WebPresentationClient() { } |
| 33 | 34 |
| 34 // Passes the Blink-side delegate to the embedder. | 35 // Passes the Blink-side delegate to the embedder. |
| 35 virtual void setController(WebPresentationController*) = 0; | 36 virtual void setController(WebPresentationController*) = 0; |
| 36 | 37 |
| 37 // Called when the frame requests to start a new session. | 38 // Called when the frame requests to start a new session. |
| 38 // The ownership of the |callbacks| argument is transferred to the embedder. | 39 // The ownership of the |callbacks| argument is transferred to the embedder. |
| 39 virtual void startSession(const WebString& presentationUrl, WebPresentationC onnectionClientCallbacks*) = 0; | 40 virtual void startSession(const WebVector<WebString>& presentationUrls, WebP resentationConnectionClientCallbacks*) = 0; |
| 40 | 41 |
| 41 // Called when the frame requests to join an existing session. | 42 // Called when the frame requests to join an existing session. |
| 42 // The ownership of the |callbacks| argument is transferred to the embedder. | 43 // The ownership of the |callbacks| argument is transferred to the embedder. |
| 43 virtual void joinSession(const WebString& presentationUrl, const WebString& presentationId, WebPresentationConnectionClientCallbacks*) = 0; | 44 virtual void joinSession(const WebVector<WebString>& presentationUrls, const WebString& presentationId, WebPresentationConnectionClientCallbacks*) = 0; |
| 44 | 45 |
| 45 // Called when the frame requests to send String message to an existing sess ion. | 46 // Called when the frame requests to send String message to an existing sess ion. |
| 46 virtual void sendString(const WebString& presentationUrl, const WebString& p resentationId, const WebString& message) = 0; | 47 virtual void sendString(const WebString& presentationUrl, const WebString& p resentationId, const WebString& message) = 0; |
| 47 | 48 |
| 48 // Called when the frame requests to send ArrayBuffer/View data to an existi ng session. | 49 // 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. | 50 // 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; | 51 virtual void sendArrayBuffer(const WebString& presentationUrl, const WebStri ng& presentationId, const uint8_t* data, size_t length) = 0; |
| 51 | 52 |
| 52 // Called when the frame requests to send Blob data to an existing session. | 53 // Called when the frame requests to send Blob data to an existing session. |
| 53 // Embedder copies the |data| and the ownership is not transferred. | 54 // 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; | 55 virtual void sendBlobData(const WebString& presentationUrl, const WebString& presentationId, const uint8_t* data, size_t length) = 0; |
| 55 | 56 |
| 56 // Called when the frame requests to close an existing session. | 57 // Called when the frame requests to close an existing session. |
| 57 virtual void closeSession(const WebString& presentationUrl, const WebString& presentationId) = 0; | 58 virtual void closeSession(const WebString& presentationUrl, const WebString& presentationId) = 0; |
| 58 | 59 |
| 59 // Called when the frame requests to terminate an existing session. | 60 // Called when the frame requests to terminate an existing session. |
| 60 virtual void terminateSession(const WebString& presentationUrl, const WebStr ing& presentationId) = 0; | 61 virtual void terminateSession(const WebString& presentationUrl, const WebStr ing& presentationId) = 0; |
| 61 | 62 |
| 62 // Called when the frame wants to know the availability of a presentation | 63 // Called when the frame wants to know the availability of a presentation |
| 63 // display for |availabilityUrl|. The ownership of the callbacks argument | 64 // display for |availabilityUrl|. The ownership of the callbacks argument |
|
mlamouri (slow - plz ping)
2016/07/19 12:45:03
nit: |availabilityUrls|
mark a. foltz
2016/07/19 17:38:47
Done.
| |
| 64 // is transferred to the embedder. | 65 // is transferred to the embedder. |
| 65 virtual void getAvailability(const WebString& availabilityUrl, WebPresentati onAvailabilityCallbacks*) = 0; | 66 virtual void getAvailability(const WebVector<WebString>& availabilityUrls, W ebPresentationAvailabilityCallbacks*) = 0; |
| 66 | 67 |
| 67 // Start listening to changes in presentation displays availability. The | 68 // Start listening to changes in presentation displays availability. The |
| 68 // observer will be notified in case of a change. The observer is | 69 // observer will be notified in case of a change. The observer is |
| 69 // respensible to call stopListening() before being destroyed. | 70 // respensible to call stopListening() before being destroyed. |
| 70 virtual void startListening(WebPresentationAvailabilityObserver*) = 0; | 71 virtual void startListening(WebPresentationAvailabilityObserver*) = 0; |
| 71 | 72 |
| 72 // Stop listening to changes in presentation displays availability. The | 73 // Stop listening to changes in presentation displays availability. The |
| 73 // observer will no longer be notified in case of a change. | 74 // observer will no longer be notified in case of a change. |
| 74 virtual void stopListening(WebPresentationAvailabilityObserver*) = 0; | 75 virtual void stopListening(WebPresentationAvailabilityObserver*) = 0; |
| 75 | 76 |
| 76 // Called when a defaultRequest has been set. It sends the url associated | 77 // Called when a defaultRequest has been set. It sends the urls associated |
| 77 // with it for the embedder. | 78 // with it for the embedder. |
| 78 virtual void setDefaultPresentationUrl(const WebString&) = 0; | 79 virtual void setDefaultPresentationUrls(const WebVector<WebString>&) = 0; |
| 79 }; | 80 }; |
| 80 | 81 |
| 81 } // namespace blink | 82 } // namespace blink |
| 82 | 83 |
| 83 #endif // WebPresentationClient_h | 84 #endif // WebPresentationClient_h |
| OLD | NEW |