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

Side by Side 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: addressed yuri's comments #16 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_RECEIVER_PRESENTATION_SERVICE_DELEGATE_IMPL_ H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_RECEIVER_PRESENTATION_SERVICE_DELEGATE_IMPL_ H_
7
8 #include <map>
9
10 #include "base/observer_list.h"
11 #include "chrome/browser/media/router/offscreen_presentation_manager.h"
12 #include "chrome/browser/media/router/render_frame_host_helper.h"
13 #include "content/public/browser/presentation_service_delegate.h"
14 #include "content/public/browser/web_contents_user_data.h"
15
16 namespace content {
17 class RenderFrameHost;
18 class PresentationScreenAvailabilityListener;
19 class WebContents;
20 struct PresentationSessionInfo;
21 struct PresentationSessionMessage;
22 } // namespace content
23
24 namespace media_router {
25
26 class MediaRoute;
27 class MediaSinksObserver;
28 class PresentationSessionStateObserver;
29
30 // Implements the receiver side of presentation API for offscreen presentations.
31 // Created under the offscreen tab WebContents when the tab is created for an
32 // offscreen presentation. Each instance is tied to a single offscreen
33 // presentation whose ID is given during construction. As such, the receiver
34 // APIs are contextual with the offscreen presentation.
35 // Only the main frame of the offscreen tab is allowed to make receiver
36 // Presentation API requests; requests made from any other frame will be
37 // rejected.
38 class ReceiverPresentationServiceDelegateImpl
39 : public content::WebContentsUserData<
40 ReceiverPresentationServiceDelegateImpl>,
41 public content::PresentationServiceDelegate {
42 public:
43 // Creates an instance of ReceiverPresentationServiceDelegateImpl under
44 // |web_contents| and registers it as the receiver of the offscreen
45 // presentation |presentation_id| with OffscreenPresentationManager.
46 // No-op if a ReceiverPresentationServiceDelegateImpl instance already
47 // exists under |web_contents|.
48 static void CreateForWebContents(content::WebContents* web_contents,
49 const std::string& presentation_id);
50
51 ~ReceiverPresentationServiceDelegateImpl() override;
52
53 // content::PresentationServiceDelegate implementation.
54 void AddObserver(
55 int render_process_id,
56 int render_frame_id,
57 content::PresentationServiceDelegate::Observer* observer) override;
58 void RemoveObserver(int render_process_id, int render_frame_id) override;
59 bool AddScreenAvailabilityListener(
60 int render_process_id,
61 int render_frame_id,
62 content::PresentationScreenAvailabilityListener* listener) override;
63 void RemoveScreenAvailabilityListener(
64 int render_process_id,
65 int render_frame_id,
66 content::PresentationScreenAvailabilityListener* listener) override;
67 void Reset(int render_process_id, int render_frame_id) override;
68 void SetDefaultPresentationUrl(
69 int render_process_id,
70 int render_frame_id,
71 const std::string& default_presentation_url) override;
72 void StartSession(int render_process_id,
73 int render_frame_id,
74 const std::string& presentation_url,
75 const PresentationSessionSuccessCallback& success_cb,
76 const PresentationSessionErrorCallback& error_cb) override;
77 void JoinSession(int render_process_id,
78 int render_frame_id,
79 const std::string& presentation_url,
80 const std::string& presentation_id,
81 const PresentationSessionSuccessCallback& success_cb,
82 const PresentationSessionErrorCallback& error_cb) override;
83 void CloseSession(int render_process_id,
84 int render_frame_id,
85 const std::string& presentation_id) override;
86 void ListenForSessionMessages(
87 int render_process_id,
88 int render_frame_id,
89 const content::PresentationSessionInfo& session_info,
90 const content::PresentationSessionMessageCallback& message_cb) override;
91 void SendMessage(
92 int render_process_id,
93 int render_frame_id,
94 const content::PresentationSessionInfo& session_info,
95 scoped_ptr<content::PresentationSessionMessage> message,
96 const content::SendMessageCallback& send_message_cb) override;
97 bool ListenForSessionStateChange(
98 int render_process_id,
99 int render_frame_id,
100 content::PresentationSessionStateListener* listener) override;
101 void NotifyWhenReceiverSessionIsAvailable(
102 int render_process_id,
103 int render_frame_id,
104 const content::PresentationReceiverSessionAvailableCallback& callback)
105 override;
106 std::vector<content::PresentationSessionInfo> GetPresentationReceiverSessions(
107 int render_process_id,
108 int render_frame_id) override;
109
110 private:
111 friend class content::WebContentsUserData<
112 ReceiverPresentationServiceDelegateImpl>;
113
114 explicit ReceiverPresentationServiceDelegateImpl(
115 content::WebContents* web_contents,
116 const std::string& presentation_id);
117 void OnReceiverSessionAvailable(
118 scoped_ptr<OffscreenPresentationManager::OffscreenPresentationSession>
119 session);
120 bool IsMainFrame(int render_process_id, int render_frame_id);
121 OffscreenPresentationManager::OffscreenPresentationSession* FindSession(
122 const content::PresentationSessionInfo& session_info);
123
124 // Reference to the WebContents that owns this instance.
125 content::WebContents* const web_contents_;
126
127 const std::string presentation_id_;
128 OffscreenPresentationManager* const offscreen_presentation_manager_;
129 ScopedVector<OffscreenPresentationManager::OffscreenPresentationSession>
130 receiver_sessions_;
131 content::PresentationReceiverSessionAvailableCallback
132 receiver_available_callback_;
133 std::map<RenderFrameHostId, content::PresentationServiceDelegate::Observer*>
134 observers_;
135
136 DISALLOW_COPY_AND_ASSIGN(ReceiverPresentationServiceDelegateImpl);
137 };
138
139 } // namespace media_router
140
141 #endif // CHROME_BROWSER_MEDIA_ROUTER_RECEIVER_PRESENTATION_SERVICE_DELEGATE_IM PL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698