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..510f2559a5004987465df16d24276458506b19c0 |
--- /dev/null |
+++ b/chrome/browser/media/router/receiver_presentation_service_delegate_impl.h |
@@ -0,0 +1,138 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
mark a. foltz
2016/10/08 00:33:42
Update copyright
zhaobin
2016/10/12 02:27:33
Done.
|
+// 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 <memory> |
+#include <string> |
+#include <utility> |
+#include <vector> |
+ |
+#include "base/observer_list.h" |
+#include "chrome/browser/media/router/offscreen_presentation_manager.h" |
+#include "chrome/browser/media/router/offscreen_presentation_manager_factory.h" |
+#include "chrome/browser/media/router/render_frame_host_id.h" |
+#include "content/public/browser/presentation_service_delegate.h" |
+#include "content/public/browser/web_contents_user_data.h" |
+ |
+namespace content { |
+class RenderFrameHost; |
+class WebContents; |
+struct PresentationSessionInfo; |
+struct PresentationSessionMessage; |
+} // namespace content |
+ |
+namespace media_router { |
+ |
+// Implements the receiver side of presentation API for offscreen presentations. |
+// Created under the offscreen tab WebContents when the tab is created for an |
+// offscreen presentation. Each instance is tied to a single offscreen |
+// presentation whose ID is given during construction. As such, the receiver |
+// APIs are contextual with the offscreen presentation. |
+// Only the main frame of the offscreen tab is allowed to make receiver |
+// Presentation API requests; requests made from any other frame will be |
+// rejected. |
mark a. foltz
2016/10/08 00:33:42
Nice :)
zhaobin
2016/10/12 02:27:33
Derek writes this :)
|
+class ReceiverPresentationServiceDelegateImpl |
+ : public content::WebContentsUserData< |
+ ReceiverPresentationServiceDelegateImpl>, |
+ public content::PresentationServiceDelegate { |
+ public: |
+ // Creates an instance of ReceiverPresentationServiceDelegateImpl under |
+ // |web_contents| and registers it as the receiver of the offscreen |
+ // presentation |presentation_id| with OffscreenPresentationManager. |
+ // No-op if a ReceiverPresentationServiceDelegateImpl instance already |
+ // exists under |web_contents|. |
+ static void CreateForWebContents(content::WebContents* web_contents, |
+ const std::string& presentation_id); |
+ |
+ ~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( |
mark a. foltz
2016/10/08 00:33:42
None of these (through JoinSession) are really req
zhaobin
2016/10/12 02:27:33
Will not split presentation service for now. May d
|
+ 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 SetDefaultPresentationUrls( |
+ int render_process_id, |
+ int render_frame_id, |
+ const std::vector<std::string>& default_presentation_urls, |
+ const content::PresentationSessionStartedCallback& callback) override; |
+ void StartSession( |
+ int render_process_id, |
+ int render_frame_id, |
+ const std::vector<std::string>& presentation_urls, |
+ const content::PresentationSessionStartedCallback& success_cb, |
+ const content::PresentationSessionErrorCallback& error_cb) override; |
+ void JoinSession( |
+ int render_process_id, |
+ int render_frame_id, |
+ const std::vector<std::string>& presentation_urls, |
+ const std::string& presentation_id, |
+ const content::PresentationSessionStartedCallback& success_cb, |
+ const content::PresentationSessionErrorCallback& error_cb) override; |
+ void CloseConnection(int render_process_id, |
+ int render_frame_id, |
+ const std::string& presentation_id) override; |
+ void Terminate(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_info, |
+ const content::PresentationSessionMessageCallback& message_cb) override; |
+ void SendMessage(int render_process_id, |
+ int render_frame_id, |
+ const content::PresentationSessionInfo& session_info, |
+ std::unique_ptr<content::PresentationSessionMessage> message, |
+ const SendMessageCallback& send_message_cb) override; |
+ void ListenForConnectionStateChange( |
+ int render_process_id, |
+ int render_frame_id, |
+ const content::PresentationSessionInfo& connection, |
+ const content::PresentationConnectionStateChangedCallback& |
+ state_changed_cb) override; |
+ void RegisterReceiverAvailableCallback( |
+ const content::ReceiverConnectionAvailableCallback& |
+ receiver_available_callback) override; |
+ void RegisterOffscreenPresentationConnection( |
+ int render_process_id, |
+ int render_frame_id, |
+ const content::PresentationSessionInfo& session, |
+ content::PresentationConnectionPtr connection) override; |
+ |
+ private: |
+ friend class content::WebContentsUserData< |
+ ReceiverPresentationServiceDelegateImpl>; |
+ |
+ explicit ReceiverPresentationServiceDelegateImpl( |
+ content::WebContents* web_contents, |
+ const std::string& presentation_id); |
+ |
+ // Reference to the WebContents that owns this instance. |
+ content::WebContents* const web_contents_; |
+ |
+ const std::string presentation_id_; |
+ OffscreenPresentationManager* const offscreen_presentation_manager_; |
+ 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_ |