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 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 device to prese nt. | |
|
whywhat
2015/07/02 22:32:38
nit: s/device to present/presentation display/
mlamouri (slow - plz ping)
2015/07/03 13:58:26
Done.
| |
| 62 // The ownership of the |callbacks| argument is transferred to the embedder. | |
| 63 virtual void getAvailability(const WebString& url, WebPresentationAvailabili tyCallbacks* callbacks) | |
| 64 { | |
| 65 // TODO(mlamouri): remove when implemented in Chromium. | |
| 66 bool result = false; | |
| 67 callbacks->onSuccess(&result); | |
| 68 delete callbacks; | |
| 69 } | |
| 70 | |
| 71 // Start listening to presentation device availabilities. The observer will | |
|
whywhat
2015/07/02 22:32:38
nit: s/presentation device availabilities/changes
mlamouri (slow - plz ping)
2015/07/03 13:58:27
Done.
| |
| 72 // be notified in case of a change. The observer is respensible to call | |
| 73 // stopListening() before being destroyed. | |
| 74 virtual void startListening(WebPresentationAvailabilityObserver*) {} | |
|
whywhat
2015/07/02 22:32:38
don't you need to pass a url here too?
mlamouri (slow - plz ping)
2015/07/03 13:58:26
I guess we could but we wouldn't use it anyway. Gi
| |
| 75 | |
| 76 // Stop listening to presentation device availabilities. The observer will | |
|
whywhat
2015/07/02 22:32:38
ditto
mlamouri (slow - plz ping)
2015/07/03 13:58:27
Done.
| |
| 77 // no longer be notified in case of a change. | |
| 78 virtual void stopListening(WebPresentationAvailabilityObserver*) {} | |
|
whywhat
2015/07/02 22:32:38
ditto
mlamouri (slow - plz ping)
2015/07/03 13:58:26
See above.
| |
| 56 }; | 79 }; |
| 57 | 80 |
| 58 } // namespace blink | 81 } // namespace blink |
| 59 | 82 |
| 60 #endif // WebPresentationClient_h | 83 #endif // WebPresentationClient_h |
| OLD | NEW |