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..90416e31766e63df65cfa24110921c69bc741e92 |
--- /dev/null |
+++ b/chrome/browser/media/router/receiver_presentation_service_delegate_impl.h |
@@ -0,0 +1,87 @@ |
+// Copyright 2016 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> |
mark a. foltz
2016/11/15 23:41:46
Only #include <string> seems to be necessary in th
zhaobin
2016/11/16 18:02:41
Done.
|
+#include <memory> |
+#include <string> |
+#include <utility> |
+#include <vector> |
+ |
+#include "base/observer_list.h" |
mark a. foltz
2016/11/15 23:41:46
Not needed
zhaobin
2016/11/16 18:02:41
Done.
|
+ |
mark a. foltz
2016/11/15 23:41:46
Nit: extra newline
zhaobin
2016/11/16 18:02:41
Done.
|
+#include "chrome/browser/media/router/offscreen_presentation_manager.h" |
mark a. foltz
2016/11/15 23:41:46
Forward declare OffScreenPresentationManager and m
zhaobin
2016/11/16 18:02:41
Done.
|
+#include "chrome/browser/media/router/offscreen_presentation_manager_factory.h" |
mark a. foltz
2016/11/15 23:41:46
Move to .cc
zhaobin
2016/11/16 18:02:41
Done.
|
+#include "chrome/browser/media/router/presentation_service_delegate_base_impl.h" |
+#include "chrome/browser/media/router/render_frame_host_id.h" |
mark a. foltz
2016/11/15 23:41:46
Not needed?
zhaobin
2016/11/16 18:02:41
Done.
|
+#include "content/public/browser/presentation_service_delegate.h" |
+#include "content/public/browser/web_contents_user_data.h" |
+ |
+namespace content { |
+class RenderFrameHost; |
mark a. foltz
2016/11/15 23:41:46
In this list, it looks like only WebContents needs
zhaobin
2016/11/16 18:02:41
Done.
|
+class WebContents; |
+struct PresentationSessionInfo; |
+struct PresentationSessionMessage; |
+} // namespace content |
+ |
+namespace media_router { |
+ |
+// Implements the receiver side of presentation API for offscreen presentation. |
mark a. foltz
2016/11/15 23:41:46
Nit: Presentation
zhaobin
2016/11/16 18:02:41
Done.
|
+// Created with offscreen WebContents 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 WebContents is allowed to |
+// make receiver Presentation API requests; requests made from any other frame |
+// will be rejected. |
+class ReceiverPresentationServiceDelegateImpl |
+ : public content::WebContentsUserData< |
+ ReceiverPresentationServiceDelegateImpl>, |
+ public content::ReceiverPresentationServiceDelegate, |
+ public PresentationServiceDelegateBaseImpl { |
+ 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|. This class does not take ownership of |
+ // |web_contents|. |
+ static void CreateForWebContents(content::WebContents* web_contents, |
+ const std::string& presentation_id); |
+ |
+ ~ReceiverPresentationServiceDelegateImpl() override; |
+ |
+ // content::PresentationServiceDelegateBase implementation. |
+ void AddObserver( |
+ int render_process_id, |
+ int render_frame_id, |
+ content::PresentationServiceDelegateBase::Observer* observer) override; |
+ void RemoveObserver(int render_process_id, int render_frame_id) override; |
+ void Reset(int render_process_id, int render_frame_id) override; |
+ |
+ // content::ReceiverPresentationServiceDelegate implementation. |
+ void RegisterReceiverConnectionAvailableCallback( |
+ const content::ReceiverConnectionAvailableCallback& |
+ receiver_available_callback) override; |
+ |
+ private: |
+ friend class content::WebContentsUserData< |
+ ReceiverPresentationServiceDelegateImpl>; |
+ |
+ 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_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ReceiverPresentationServiceDelegateImpl); |
+}; |
+ |
+} // namespace media_router |
+ |
+#endif // CHROME_BROWSER_MEDIA_ROUTER_RECEIVER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ |