Chromium Code Reviews| Index: chrome/browser/media/router/receiver_presentation_service_delegate_impl.h |
| diff --git a/chrome/browser/media/router/receiver_presentation_service_delegate_impl.h b/chrome/browser/media/router/receiver_presentation_service_delegate_impl.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..26818c267b863b9f31255b1fc47da7ac47ab0a63 |
| --- /dev/null |
| +++ b/chrome/browser/media/router/receiver_presentation_service_delegate_impl.h |
| @@ -0,0 +1,136 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_MEDIA_ROUTER_RECEIVER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ |
| +#define CHROME_BROWSER_MEDIA_ROUTER_RECEIVER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ |
| + |
| +#include <map> |
| + |
| +#include "base/observer_list.h" |
| +#include "chrome/browser/media/router/render_frame_host_helper.h" |
| +#include "content/public/browser/presentation_service_delegate.h" |
| +#include "content/public/browser/web_contents_user_data.h" |
| + |
| +namespace content { |
| +class RenderFrameHost; |
| +class PresentationScreenAvailabilityListener; |
| +class WebContents; |
| +struct PresentationSessionInfo; |
| +struct PresentationSessionMessage; |
| +} // namespace content |
| + |
| +namespace media_router { |
| + |
| +class MediaRoute; |
| +class MediaSinksObserver; |
| +class OffscreenPresenterContext; |
| +class PresentationFrameManager; |
| +class PresentationSessionStateObserver; |
| + |
| +// TODO(imcheng): We may be able to merge this class with PSDImpl if we decide |
| +// to re-enable presentation API in incognito mode with similar behavior in the |
| +// future. |
| +// PresentationServiceDelegate implementation for incognito tabs. |
| +// Currently, most request-type APIs are disabled, with the exception of |
| +// presenter APIs for offscreen presentation, since we use an offscreen tab |
| +// spawned |
| +// from an off-the-record profile for 1-UA mode. Messaging and state change APIs |
| +// are available for the offscreen presenter session. |
| +// It is scoped to the lifetime of a WebContents, and is managed by the |
| +// associated WebContents. |
| +class ReceiverPresentationServiceDelegateImpl |
|
miu
2015/09/27 00:22:09
naming: Personally, I disagree with the other revi
imcheng
2015/09/30 01:13:42
I don't feel strongly either way regarding Impl.
I
|
| + : public content::WebContentsUserData< |
| + ReceiverPresentationServiceDelegateImpl>, |
| + public content::PresentationServiceDelegate { |
| + public: |
| + // Retrieves the instance of ReceiverPresentationServiceDelegateImpl that was |
| + // attached |
| + // to the specified WebContents. If no instance was attached, creates one, |
| + // and attaches it to the specified WebContents. |
| + static ReceiverPresentationServiceDelegateImpl* GetOrCreateForWebContents( |
| + content::WebContents* web_contents); |
| + |
| + ~ReceiverPresentationServiceDelegateImpl() override; |
| + |
| + // content::PresentationServiceDelegate implementation. |
| + void AddObserver( |
| + int render_process_id, |
| + int render_frame_id, |
| + content::PresentationServiceDelegate::Observer* observer) override; |
| + void RemoveObserver(int render_process_id, int render_frame_id) override; |
| + bool AddScreenAvailabilityListener( |
| + int render_process_id, |
| + int render_frame_id, |
| + content::PresentationScreenAvailabilityListener* listener) override; |
| + void RemoveScreenAvailabilityListener( |
| + int render_process_id, |
| + int render_frame_id, |
| + content::PresentationScreenAvailabilityListener* listener) override; |
| + void Reset(int render_process_id, int render_frame_id) override; |
| + void SetDefaultPresentationUrl( |
| + int render_process_id, |
| + int render_frame_id, |
| + const std::string& default_presentation_url) override; |
| + void StartSession(int render_process_id, |
| + int render_frame_id, |
| + const std::string& presentation_url, |
| + const PresentationSessionSuccessCallback& success_cb, |
| + const PresentationSessionErrorCallback& error_cb) override; |
| + void JoinSession(int render_process_id, |
| + int render_frame_id, |
| + const std::string& presentation_url, |
| + const std::string& presentation_id, |
| + const PresentationSessionSuccessCallback& success_cb, |
| + const PresentationSessionErrorCallback& error_cb) override; |
| + void CloseSession(int render_process_id, |
| + int render_frame_id, |
| + const std::string& presentation_id) override; |
| + void ListenForSessionMessages( |
| + int render_process_id, |
| + int render_frame_id, |
| + const content::PresentationSessionInfo& session, |
| + const content::PresentationSessionMessageCallback& message_cb) override; |
| + void SendMessage( |
| + int render_process_id, |
| + int render_frame_id, |
| + const content::PresentationSessionInfo& session, |
| + scoped_ptr<content::PresentationSessionMessage> message, |
| + const content::SendMessageCallback& send_message_cb) override; |
| + bool ListenForSessionStateChange( |
| + int render_process_id, |
| + int render_frame_id, |
| + content::PresentationSessionStateListener* listener) override; |
| + void GetPresentationReceiverSession( |
| + int render_process_id, |
| + int render_frame_id, |
| + const content::PresentationReceiverSessionAvailableCallback& |
| + success_callback, |
| + const base::Callback<void(const std::string&)>& error_callback) override; |
| + std::vector<content::PresentationSessionInfo> GetPresentationReceiverSessions( |
| + int render_process_id, |
| + int render_frame_id) override; |
| + |
| + private: |
| + explicit ReceiverPresentationServiceDelegateImpl( |
| + content::WebContents* web_contents); |
| + friend class content::WebContentsUserData< |
| + ReceiverPresentationServiceDelegateImpl>; |
| + |
| + // Reference to the WebContents that owns this instance. |
| + content::WebContents* const web_contents_; |
| + |
| + // Initalized on construction. Destroyed when |Reset()| is called on the |
| + // main frame of |web_contents_| (i.e., navigation or other events that would |
| + // invalidate the context). |
| + scoped_ptr<OffscreenPresenterContext> offscreen_presenter_context_; |
| + |
| + std::map<RenderFrameHostId, content::PresentationServiceDelegate::Observer*> |
| + observers_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ReceiverPresentationServiceDelegateImpl); |
| +}; |
| + |
| +} // namespace media_router |
| + |
| +#endif // CHROME_BROWSER_MEDIA_ROUTER_RECEIVER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ |