Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(417)

Unified Diff: chrome/browser/media/router/receiver_presentation_service_delegate_impl.h

Issue 1314413005: [Presentation API] 1-UA presentation support + presenter APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase again to pick up Yuri's cl Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..0a8c160d62ec195a35b010105699c32cd25d3197
--- /dev/null
+++ b/chrome/browser/media/router/receiver_presentation_service_delegate_impl.h
@@ -0,0 +1,140 @@
+// 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/offscreen_presentation_manager.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 PresentationSessionStateObserver;
+
+// 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
miu 2015/10/07 21:51:46 OOC, why is only the main frame allowed? I could
imcheng 2015/10/10 04:39:43 It's much trickier to define behavior when multipl
+// Presentation API requests; requests made from any other frame will be
+// rejected.
+class ReceiverPresentationServiceDelegateImpl
+ : public content::WebContentsUserData<
+ ReceiverPresentationServiceDelegateImpl>,
+ public content::PresentationServiceDelegate {
+ public:
+ // Creates an instance of ReceiverPresentationServiceDelegateImpl under
+ // |web_contents|. No-op if a ReceiverPresentationServiceDelegateImpl instance
+ // already exists under |web_contents|.
+ // TODO: update comments
miu 2015/10/07 21:51:46 Please do. ;-)
imcheng 2015/10/10 04:39:43 Done.
+ 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(
+ 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_info,
+ const content::PresentationSessionMessageCallback& message_cb) override;
+ void SendMessage(
+ int render_process_id,
+ int render_frame_id,
+ const content::PresentationSessionInfo& session_info,
+ 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& callback)
+ override;
+ std::vector<content::PresentationSessionInfo> GetPresentationReceiverSessions(
+ int render_process_id,
+ int render_frame_id) override;
+
+ private:
+ friend class content::WebContentsUserData<
+ ReceiverPresentationServiceDelegateImpl>;
+
+ explicit ReceiverPresentationServiceDelegateImpl(
+ content::WebContents* web_contents,
+ const std::string& presentation_id);
+ void OnReceiverSessionAvailable(
+ scoped_ptr<OffscreenPresentationManager::OffscreenPresentationSession>
+ session);
+ bool IsMainFrame(int render_process_id, int render_frame_id);
+ OffscreenPresentationManager::OffscreenPresentationSession* FindSession(
+ const content::PresentationSessionInfo& session_info);
+
+ // Reference to the WebContents that owns this instance.
+ content::WebContents* const web_contents_;
+
+ const std::string presentation_id_;
+ OffscreenPresentationManager* const offscreen_presentation_manager_;
+ ScopedVector<OffscreenPresentationManager::OffscreenPresentationSession>
+ receiver_sessions_;
+ content::PresentationReceiverSessionAvailableCallback
+ receiver_available_callback_;
+ 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_

Powered by Google App Engine
This is Rietveld 408576698