Chromium Code Reviews| Index: content/browser/presentation/presentation_service_impl.h |
| diff --git a/content/browser/presentation/presentation_service_impl.h b/content/browser/presentation/presentation_service_impl.h |
| index 1a1bb7d5348fa8b2fc951c4dd81fccafbd5af8e1..0aeed31d4b111cb635ede58a18f5fa940e75a394 100644 |
| --- a/content/browser/presentation/presentation_service_impl.h |
| +++ b/content/browser/presentation/presentation_service_impl.h |
| @@ -48,7 +48,7 @@ class RenderFrameHost; |
| class CONTENT_EXPORT PresentationServiceImpl |
| : public NON_EXPORTED_BASE(blink::mojom::PresentationService), |
| public WebContentsObserver, |
| - public PresentationServiceDelegate::Observer { |
| + public PresentationServiceDelegateBase::Observer { |
| public: |
| using NewSessionCallback = |
| base::Callback<void(blink::mojom::PresentationSessionInfoPtr, |
| @@ -95,6 +95,10 @@ class CONTENT_EXPORT PresentationServiceImpl |
| ListenForConnectionStateChangeAndChangeState); |
| FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
| ListenForConnectionClose); |
| + FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
| + SetPresentationConnection); |
| + FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
| + ReceiverPresentationServiceDelegate); |
| // Maximum number of pending JoinSession requests at any given time. |
| static const int kMaxNumQueuedSessionRequests = 10; |
| @@ -143,12 +147,17 @@ class CONTENT_EXPORT PresentationServiceImpl |
| // |render_frame_host|: The RFH this instance is associated with. |
| // |web_contents|: The WebContents to observe. |
| - // |delegate|: Where Presentation API requests are delegated to. Not owned |
| + // |controller_delegate|: Where Presentation API requests are delegated to in |
| + // controller frame. Set to null if current frame is receiver frame. Not owned |
| + // by this class. |
| + // |receiver_delegate|: Where Presentation API requests are delegated to in |
| + // receiver frame. Set to null if current frame is controller frame. Not owned |
| // by this class. |
| PresentationServiceImpl( |
| RenderFrameHost* render_frame_host, |
| WebContents* web_contents, |
| - PresentationServiceDelegate* delegate); |
| + ControllerPresentationServiceDelegate* controller_delegate, |
| + ReceiverPresentationServiceDelegate* receiver_delegate); |
|
mark a. foltz
2016/11/15 23:41:47
Can this ctor now be made private?
zhaobin
2016/11/16 18:02:42
Yes. The constructor and all functions below it ar
|
| // PresentationService implementation. |
| void SetDefaultPresentationUrls( |
| @@ -170,6 +179,9 @@ class CONTENT_EXPORT PresentationServiceImpl |
| const std::string& presentation_id) override; |
| void ListenForSessionMessages( |
| blink::mojom::PresentationSessionInfoPtr session) override; |
| + void SetPresentationConnection( |
| + blink::mojom::PresentationSessionInfoPtr session, |
| + blink::mojom::PresentationConnectionPtr connection) override; |
| // Creates a binding between this object and |request|. |
| void Bind(mojo::InterfaceRequest<blink::mojom::PresentationService> request); |
| @@ -227,13 +239,18 @@ class CONTENT_EXPORT PresentationServiceImpl |
| void ListenForConnectionStateChangeAndChangeState( |
| const PresentationSessionInfo& connection); |
| - // Passed to embedder's implementation of PresentationServiceDelegate for |
| - // later invocation when session messages arrive. |
| void OnSessionMessages( |
| const content::PresentationSessionInfo& session, |
| const ScopedVector<PresentationSessionMessage>& messages, |
| bool pass_ownership); |
| + // A callback registered to OffscreenPresentationManager when |
| + // the PresentationServiceImpl for the presentation receiver is initialized. |
| + // Calls |client_| to create a new PresentationConnection on receiver page. |
| + void OnReceiverConnectionAvailable( |
| + const content::PresentationSessionInfo& session_info, |
| + PresentationConnectionPtr&& controller_connection); |
| + |
| // Associates a JoinSession |callback| with a unique request ID and |
| // stores it in a map. |
| // Returns a positive value on success. |
| @@ -248,9 +265,19 @@ class CONTENT_EXPORT PresentationServiceImpl |
| // Returns true if this object is associated with |render_frame_host|. |
| bool FrameMatches(content::RenderFrameHost* render_frame_host) const; |
| - // Embedder-specific delegate to forward Presentation requests to. |
| - // May be null if embedder does not support Presentation API. |
| - PresentationServiceDelegate* delegate_; |
| + // Returns |controller_delegate| if current frame is controller frame; Returns |
| + // |receiver_delegate| if current frame is receiver frame. |
| + PresentationServiceDelegateBase* GetPresentationServiceDelegate(); |
| + |
| + // Embedder-specific delegate for controller to forward Presentation requests |
| + // to. Must be nullptr if current page is receiver page or |
| + // embedder does not support Presentation API . |
| + ControllerPresentationServiceDelegate* controller_delegate_; |
| + |
| + // Embedder-specific delegate for receiver to forward Presentation requests |
| + // to. Must be nullptr if current page is receiver page or |
| + // embedder does not support Presentation API. |
| + ReceiverPresentationServiceDelegate* receiver_delegate_; |
| // Proxy to the PresentationServiceClient to send results (e.g., screen |
| // availability) to. |