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

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: 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 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
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
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|. No-op if a ReceiverPresentationServiceDelegateImpl instance
45 // already exists under |web_contents|.
46 // TODO: update comments
miu 2015/10/07 21:51:46 Please do. ;-)
imcheng 2015/10/10 04:39:43 Done.
47 static void CreateForWebContents(content::WebContents* web_contents,
48 const std::string& presentation_id);
49
50 ~ReceiverPresentationServiceDelegateImpl() override;
51
52 // content::PresentationServiceDelegate implementation.
53 void AddObserver(
54 int render_process_id,
55 int render_frame_id,
56 content::PresentationServiceDelegate::Observer* observer) override;
57 void RemoveObserver(int render_process_id, int render_frame_id) override;
58 bool AddScreenAvailabilityListener(
59 int render_process_id,
60 int render_frame_id,
61 content::PresentationScreenAvailabilityListener* listener) override;
62 void RemoveScreenAvailabilityListener(
63 int render_process_id,
64 int render_frame_id,
65 content::PresentationScreenAvailabilityListener* listener) override;
66 void Reset(int render_process_id, int render_frame_id) override;
67 void SetDefaultPresentationUrl(
68 int render_process_id,
69 int render_frame_id,
70 const std::string& default_presentation_url) override;
71 void StartSession(int render_process_id,
72 int render_frame_id,
73 const std::string& presentation_url,
74 const PresentationSessionSuccessCallback& success_cb,
75 const PresentationSessionErrorCallback& error_cb) override;
76 void JoinSession(int render_process_id,
77 int render_frame_id,
78 const std::string& presentation_url,
79 const std::string& presentation_id,
80 const PresentationSessionSuccessCallback& success_cb,
81 const PresentationSessionErrorCallback& error_cb) override;
82 void CloseSession(int render_process_id,
83 int render_frame_id,
84 const std::string& presentation_id) override;
85 void ListenForSessionMessages(
86 int render_process_id,
87 int render_frame_id,
88 const content::PresentationSessionInfo& session_info,
89 const content::PresentationSessionMessageCallback& message_cb) override;
90 void SendMessage(
91 int render_process_id,
92 int render_frame_id,
93 const content::PresentationSessionInfo& session_info,
94 scoped_ptr<content::PresentationSessionMessage> message,
95 const content::SendMessageCallback& send_message_cb) override;
96 bool ListenForSessionStateChange(
97 int render_process_id,
98 int render_frame_id,
99 content::PresentationSessionStateListener* listener) override;
100 void GetPresentationReceiverSession(
101 int render_process_id,
102 int render_frame_id,
103 const content::PresentationReceiverSessionAvailableCallback& callback)
104 override;
105 std::vector<content::PresentationSessionInfo> GetPresentationReceiverSessions(
106 int render_process_id,
107 int render_frame_id) override;
108
109 private:
110 friend class content::WebContentsUserData<
111 ReceiverPresentationServiceDelegateImpl>;
112
113 explicit ReceiverPresentationServiceDelegateImpl(
114 content::WebContents* web_contents,
115 const std::string& presentation_id);
116 void OnReceiverSessionAvailable(
117 scoped_ptr<OffscreenPresentationManager::OffscreenPresentationSession>
118 session);
119 bool IsMainFrame(int render_process_id, int render_frame_id);
120 OffscreenPresentationManager::OffscreenPresentationSession* FindSession(
121 const content::PresentationSessionInfo& session_info);
122
123 // Reference to the WebContents that owns this instance.
124 content::WebContents* const web_contents_;
125
126 const std::string presentation_id_;
127 OffscreenPresentationManager* const offscreen_presentation_manager_;
128 ScopedVector<OffscreenPresentationManager::OffscreenPresentationSession>
129 receiver_sessions_;
130 content::PresentationReceiverSessionAvailableCallback
131 receiver_available_callback_;
132 std::map<RenderFrameHostId, content::PresentationServiceDelegate::Observer*>
133 observers_;
134
135 DISALLOW_COPY_AND_ASSIGN(ReceiverPresentationServiceDelegateImpl);
136 };
137
138 } // namespace media_router
139
140 #endif // CHROME_BROWSER_MEDIA_ROUTER_RECEIVER_PRESENTATION_SERVICE_DELEGATE_IM PL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698