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 CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ | 5 #ifndef CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ |
6 #define CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ | 6 #define CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/scoped_vector.h" |
9 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
10 #include "content/common/presentation/presentation_service.mojom.h" | 11 #include "content/common/presentation/presentation_service.mojom.h" |
11 #include "content/public/renderer/render_frame_observer.h" | 12 #include "content/public/renderer/render_frame_observer.h" |
| 13 #include "content/renderer/presentation/presentation_session_dispatcher.h" |
12 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nClient.h" | 14 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nClient.h" |
13 | 15 |
| 16 namespace blink { |
| 17 class WebString; |
| 18 } // namespace blink |
| 19 |
14 namespace content { | 20 namespace content { |
15 | 21 |
16 // PresentationDispatcher is a delegate for Presentation API messages used by | 22 // PresentationDispatcher is a delegate for Presentation API messages used by |
17 // Blink. It forwards the calls to the Mojo PresentationService. | 23 // Blink. It forwards the calls to the Mojo PresentationService. |
18 class CONTENT_EXPORT PresentationDispatcher | 24 class CONTENT_EXPORT PresentationDispatcher |
19 : public RenderFrameObserver, | 25 : public RenderFrameObserver, |
20 public NON_EXPORTED_BASE(blink::WebPresentationClient) { | 26 public NON_EXPORTED_BASE(blink::WebPresentationClient) { |
21 public: | 27 public: |
22 explicit PresentationDispatcher(RenderFrame* render_frame); | 28 explicit PresentationDispatcher(RenderFrame* render_frame); |
23 ~PresentationDispatcher() override; | 29 ~PresentationDispatcher() override; |
24 | 30 |
25 private: | 31 private: |
26 // WebPresentationClient implementation. | 32 // WebPresentationClient implementation. |
27 virtual void setController( | 33 virtual void setController( |
28 blink::WebPresentationController* controller); | 34 blink::WebPresentationController* controller); |
29 virtual void updateAvailableChangeWatched(bool watched); | 35 virtual void updateAvailableChangeWatched(bool watched); |
| 36 virtual void startSession( |
| 37 const blink::WebString& presentationUrl, |
| 38 const blink::WebString& presentationId, |
| 39 blink::WebPresentationSessionClientCallbacks* callback); |
| 40 virtual void joinSession( |
| 41 const blink::WebString& presentationUrl, |
| 42 const blink::WebString& presentationId, |
| 43 blink::WebPresentationSessionClientCallbacks* callback); |
30 | 44 |
31 void OnScreenAvailabilityChanged(bool available); | 45 void OnScreenAvailabilityChanged(bool available); |
| 46 void OnSessionCreated( |
| 47 blink::WebPresentationSessionClientCallbacks* callback, |
| 48 presentation::PresentationSessionInfoPtr session_info, |
| 49 presentation::PresentationErrorPtr error); |
32 | 50 |
33 void ConnectToPresentationServiceIfNeeded(); | 51 void ConnectToPresentationServiceIfNeeded(); |
34 | 52 |
35 // Used as a weak reference. Can be null since lifetime is bound to the frame. | 53 // Used as a weak reference. Can be null since lifetime is bound to the frame. |
36 blink::WebPresentationController* controller_; | 54 blink::WebPresentationController* controller_; |
37 presentation::PresentationServicePtr presentation_service_; | 55 presentation::PresentationServicePtr presentation_service_; |
| 56 |
| 57 // Wrappers around the PresentationSessionPtr corresponding to each Javascript |
| 58 // PresentationSession object passed back to the frame. |
| 59 // TODO(avayvod): Switch to base::IDMap when the lookup by presentation id is |
| 60 // needed. |
| 61 using PresentationSessionDispatchers = |
| 62 ScopedVector<PresentationSessionDispatcher>; |
| 63 PresentationSessionDispatchers presentation_session_dispatchers_; |
38 }; | 64 }; |
39 | 65 |
40 } // namespace content | 66 } // namespace content |
41 | 67 |
42 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ | 68 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ |
OLD | NEW |