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

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 comments #18-21 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_id.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,
72 const PresentationSessionStartedCallback& callback) override;
73 void StartSession(int render_process_id,
74 int render_frame_id,
75 const std::string& presentation_url,
76 const PresentationSessionStartedCallback& success_cb,
77 const PresentationSessionErrorCallback& error_cb) override;
78 void JoinSession(int render_process_id,
79 int render_frame_id,
80 const std::string& presentation_url,
81 const std::string& presentation_id,
82 const PresentationSessionStartedCallback& success_cb,
83 const PresentationSessionErrorCallback& error_cb) override;
84 void CloseSession(int render_process_id,
85 int render_frame_id,
86 const std::string& presentation_id) override;
87 void ListenForSessionMessages(
88 int render_process_id,
89 int render_frame_id,
90 const content::PresentationSessionInfo& session_info,
91 const content::PresentationSessionMessageCallback& message_cb) override;
92 void SendMessage(
93 int render_process_id,
94 int render_frame_id,
95 const content::PresentationSessionInfo& session_info,
96 scoped_ptr<content::PresentationSessionMessage> message,
97 const content::SendMessageCallback& send_message_cb) override;
98 bool ListenForSessionStateChange(
99 int render_process_id,
100 int render_frame_id,
101 content::PresentationSessionStateListener* listener) override;
102 void NotifyWhenReceiverSessionIsAvailable(
103 int render_process_id,
104 int render_frame_id,
105 const content::PresentationReceiverSessionAvailableCallback& callback)
106 override;
107
108 private:
109 friend class content::WebContentsUserData<
110 ReceiverPresentationServiceDelegateImpl>;
111
112 explicit ReceiverPresentationServiceDelegateImpl(
113 content::WebContents* web_contents,
114 const std::string& presentation_id);
115 void OnReceiverSessionAvailable(
116 scoped_ptr<OffscreenPresentationManager::OffscreenPresentationSession>
117 session);
118 bool IsMainFrame(int render_process_id, int render_frame_id);
119 OffscreenPresentationManager::OffscreenPresentationSession* FindSession(
120 const content::PresentationSessionInfo& session_info);
121
122 // Reference to the WebContents that owns this instance.
123 content::WebContents* const web_contents_;
124
125 const std::string presentation_id_;
126 OffscreenPresentationManager* const offscreen_presentation_manager_;
127 ScopedVector<OffscreenPresentationManager::OffscreenPresentationSession>
128 receiver_sessions_;
129 content::PresentationReceiverSessionAvailableCallback
130 receiver_available_callback_;
131 std::map<RenderFrameHostId, content::PresentationServiceDelegate::Observer*>
132 observers_;
133
134 DISALLOW_COPY_AND_ASSIGN(ReceiverPresentationServiceDelegateImpl);
135 };
136
137 } // namespace media_router
138
139 #endif // CHROME_BROWSER_MEDIA_ROUTER_RECEIVER_PRESENTATION_SERVICE_DELEGATE_IM PL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698