| 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 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 using WebPresentationAvailabilityCallbacks = WebCallbacks<bool, void>; | 25 using WebPresentationAvailabilityCallbacks = WebCallbacks<bool, void>; |
| 26 | 26 |
| 27 // 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. |
| 28 class WebPresentationClient { | 28 class WebPresentationClient { |
| 29 public: | 29 public: |
| 30 virtual ~WebPresentationClient() { } | 30 virtual ~WebPresentationClient() { } |
| 31 | 31 |
| 32 // Passes the Blink-side delegate to the embedder. | 32 // Passes the Blink-side delegate to the embedder. |
| 33 virtual void setController(WebPresentationController*) = 0; | 33 virtual void setController(WebPresentationController*) = 0; |
| 34 | 34 |
| 35 // Called when the frame attaches the first event listener to or removes the | |
| 36 // last event listener from the |availablechange| event. | |
| 37 virtual void updateAvailableChangeWatched(bool watched) = 0; | |
| 38 | |
| 39 // Called when the frame requests to start a new session. | 35 // Called when the frame requests to start a new session. |
| 40 // The ownership of the |callbacks| argument is transferred to the embedder. | 36 // The ownership of the |callbacks| argument is transferred to the embedder. |
| 41 virtual void startSession(const WebString& presentationUrl, const WebString&
presentationId, WebPresentationSessionClientCallbacks*) = 0; | 37 virtual void startSession(const WebString& presentationUrl, const WebString&
presentationId, WebPresentationSessionClientCallbacks*) = 0; |
| 42 | 38 |
| 43 // Called when the frame requests to join an existing session. | 39 // Called when the frame requests to join an existing session. |
| 44 // The ownership of the |callbacks| argument is transferred to the embedder. | 40 // The ownership of the |callbacks| argument is transferred to the embedder. |
| 45 virtual void joinSession(const WebString& presentationUrl, const WebString&
presentationId, WebPresentationSessionClientCallbacks*) = 0; | 41 virtual void joinSession(const WebString& presentationUrl, const WebString&
presentationId, WebPresentationSessionClientCallbacks*) = 0; |
| 46 | 42 |
| 47 // Called when the frame requests to send String message to an existing sess
ion. | 43 // Called when the frame requests to send String message to an existing sess
ion. |
| 48 virtual void sendString(const WebString& presentationUrl, const WebString& p
resentationId, const WebString& message) = 0; | 44 virtual void sendString(const WebString& presentationUrl, const WebString& p
resentationId, const WebString& message) = 0; |
| 49 | 45 |
| 50 // Called when the frame requests to send ArrayBuffer/View data to an existi
ng session. | 46 // Called when the frame requests to send ArrayBuffer/View data to an existi
ng session. |
| 51 // Embedder copies the |data| and the ownership is not transferred. | 47 // Embedder copies the |data| and the ownership is not transferred. |
| 52 virtual void sendArrayBuffer(const WebString& presentationUrl, const WebStri
ng& presentationId, const uint8_t* data, size_t length) = 0; | 48 virtual void sendArrayBuffer(const WebString& presentationUrl, const WebStri
ng& presentationId, const uint8_t* data, size_t length) = 0; |
| 53 | 49 |
| 54 // Called when the frame requests to send Blob data to an existing session. | 50 // Called when the frame requests to send Blob data to an existing session. |
| 55 // Embedder copies the |data| and the ownership is not transferred. | 51 // Embedder copies the |data| and the ownership is not transferred. |
| 56 virtual void sendBlobData(const WebString& presentationUrl, const WebString&
presentationId, const uint8_t* data, size_t length) = 0; | 52 virtual void sendBlobData(const WebString& presentationUrl, const WebString&
presentationId, const uint8_t* data, size_t length) = 0; |
| 57 | 53 |
| 58 // Called when the frame requests to close an existing session. | 54 // Called when the frame requests to close an existing session. |
| 59 virtual void closeSession(const WebString& url, const WebString& presentatio
nId) = 0; | 55 virtual void closeSession(const WebString& url, const WebString& presentatio
nId) = 0; |
| 60 | 56 |
| 61 // Called when the frame wants to know the availability of a presentation | 57 // Called when the frame wants to know the availability of a presentation |
| 62 // display. | 58 // display. |
| 63 // The ownership of the |callbacks| argument is transferred to the embedder. | 59 // The ownership of the |callbacks| argument is transferred to the embedder. |
| 64 virtual void getAvailability(const WebString& url, WebPresentationAvailabili
tyCallbacks* callbacks) | 60 virtual void getAvailability(const WebString& url, WebPresentationAvailabili
tyCallbacks*) = 0; |
| 65 { | |
| 66 // TODO(mlamouri): remove when implemented in Chromium. | |
| 67 bool* result = new bool(false); | |
| 68 callbacks->onSuccess(result); | |
| 69 delete callbacks; | |
| 70 } | |
| 71 | 61 |
| 72 // Start listening to changes in presentation displays availability. The | 62 // Start listening to changes in presentation displays availability. The |
| 73 // observer will be notified in case of a change. The observer is | 63 // observer will be notified in case of a change. The observer is |
| 74 // respensible to call stopListening() before being destroyed. | 64 // respensible to call stopListening() before being destroyed. |
| 75 virtual void startListening(WebPresentationAvailabilityObserver*) {} | 65 virtual void startListening(WebPresentationAvailabilityObserver*) = 0; |
| 76 | 66 |
| 77 // Stop listening to changes in presentation displays availability. The | 67 // Stop listening to changes in presentation displays availability. The |
| 78 // observer will no longer be notified in case of a change. | 68 // observer will no longer be notified in case of a change. |
| 79 virtual void stopListening(WebPresentationAvailabilityObserver*) {} | 69 virtual void stopListening(WebPresentationAvailabilityObserver*) = 0; |
| 80 }; | 70 }; |
| 81 | 71 |
| 82 } // namespace blink | 72 } // namespace blink |
| 83 | 73 |
| 84 #endif // WebPresentationClient_h | 74 #endif // WebPresentationClient_h |
| OLD | NEW |