| 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 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 class WebPresentationAvailabilityObserver; |
| 13 class WebPresentationController; | 14 class WebPresentationController; |
| 14 class WebPresentationSessionClient; | 15 class WebPresentationSessionClient; |
| 15 class WebString; | 16 class WebString; |
| 16 struct WebPresentationError; | 17 struct WebPresentationError; |
| 17 | 18 |
| 18 // If session was created, callback's onSuccess() is invoked with the informatio
n about the | 19 // If session was created, callback's onSuccess() is invoked with the informatio
n about the |
| 19 // presentation session created by the embedder. Otherwise, onError() is invoked
with the error code | 20 // presentation session created by the embedder. Otherwise, onError() is invoked
with the error code |
| 20 // and message. | 21 // and message. |
| 21 using WebPresentationSessionClientCallbacks = WebCallbacks<WebPresentationSessio
nClient, WebPresentationError>; | 22 using WebPresentationSessionClientCallbacks = WebCallbacks<WebPresentationSessio
nClient, WebPresentationError>; |
| 22 | 23 |
| 24 // Callback for .getAvailability(). |
| 25 using WebPresentationAvailabilityCallbacks = WebCallbacks<bool, void>; |
| 26 |
| 23 // The implementation the embedder has to provide for the Presentation API to wo
rk. | 27 // The implementation the embedder has to provide for the Presentation API to wo
rk. |
| 24 class WebPresentationClient { | 28 class WebPresentationClient { |
| 25 public: | 29 public: |
| 26 virtual ~WebPresentationClient() { } | 30 virtual ~WebPresentationClient() { } |
| 27 | 31 |
| 28 // Passes the Blink-side delegate to the embedder. | 32 // Passes the Blink-side delegate to the embedder. |
| 29 virtual void setController(WebPresentationController*) = 0; | 33 virtual void setController(WebPresentationController*) = 0; |
| 30 | 34 |
| 31 // Called when the frame attaches the first event listener to or removes the | 35 // Called when the frame attaches the first event listener to or removes the |
| 32 // last event listener from the |availablechange| event. | 36 // last event listener from the |availablechange| event. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 46 // Called when the frame requests to send ArrayBuffer/View data to an existi
ng session. | 50 // Called when the frame requests to send ArrayBuffer/View data to an existi
ng session. |
| 47 // Embedder copies the |data| and the ownership is not transferred. | 51 // Embedder copies the |data| and the ownership is not transferred. |
| 48 virtual void sendArrayBuffer(const WebString& presentationUrl, const WebStri
ng& presentationId, const uint8_t* data, size_t length) = 0; | 52 virtual void sendArrayBuffer(const WebString& presentationUrl, const WebStri
ng& presentationId, const uint8_t* data, size_t length) = 0; |
| 49 | 53 |
| 50 // Called when the frame requests to send Blob data to an existing session. | 54 // Called when the frame requests to send Blob data to an existing session. |
| 51 // Embedder copies the |data| and the ownership is not transferred. | 55 // Embedder copies the |data| and the ownership is not transferred. |
| 52 virtual void sendBlobData(const WebString& presentationUrl, const WebString&
presentationId, const uint8_t* data, size_t length) = 0; | 56 virtual void sendBlobData(const WebString& presentationUrl, const WebString&
presentationId, const uint8_t* data, size_t length) = 0; |
| 53 | 57 |
| 54 // Called when the frame requests to close an existing session. | 58 // Called when the frame requests to close an existing session. |
| 55 virtual void closeSession(const WebString& url, const WebString& presentatio
nId) = 0; | 59 virtual void closeSession(const WebString& url, const WebString& presentatio
nId) = 0; |
| 60 |
| 61 // Called when the frame wants to know the availability of a presentation |
| 62 // display. |
| 63 // The ownership of the |callbacks| argument is transferred to the embedder. |
| 64 virtual void getAvailability(const WebString& url, WebPresentationAvailabili
tyCallbacks* callbacks) |
| 65 { |
| 66 // TODO(mlamouri): remove when implemented in Chromium. |
| 67 bool* result = new bool(false); |
| 68 callbacks->onSuccess(result); |
| 69 delete callbacks; |
| 70 } |
| 71 |
| 72 // Start listening to changes in presentation displays availability. The |
| 73 // observer will be notified in case of a change. The observer is |
| 74 // respensible to call stopListening() before being destroyed. |
| 75 virtual void startListening(WebPresentationAvailabilityObserver*) {} |
| 76 |
| 77 // Stop listening to changes in presentation displays availability. The |
| 78 // observer will no longer be notified in case of a change. |
| 79 virtual void stopListening(WebPresentationAvailabilityObserver*) {} |
| 56 }; | 80 }; |
| 57 | 81 |
| 58 } // namespace blink | 82 } // namespace blink |
| 59 | 83 |
| 60 #endif // WebPresentationClient_h | 84 #endif // WebPresentationClient_h |
| OLD | NEW |