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

Side by Side Diff: chrome/browser/media/router/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: Created 5 years, 3 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ 6 #define CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/observer_list.h" 16 #include "base/observer_list.h"
17 #include "chrome/browser/media/router/media_router.h" 17 #include "chrome/browser/media/router/media_router.h"
18 #include "chrome/browser/media/router/media_source.h" 18 #include "chrome/browser/media/router/media_source.h"
19 #include "chrome/browser/media/router/render_frame_host_helper.h"
19 #include "content/public/browser/presentation_service_delegate.h" 20 #include "content/public/browser/presentation_service_delegate.h"
20 #include "content/public/browser/web_contents_observer.h" 21 #include "content/public/browser/web_contents_observer.h"
21 #include "content/public/browser/web_contents_user_data.h" 22 #include "content/public/browser/web_contents_user_data.h"
22 23
23 namespace content { 24 namespace content {
24 class RenderFrameHost; 25 class RenderFrameHost;
25 class PresentationScreenAvailabilityListener; 26 class PresentationScreenAvailabilityListener;
26 class WebContents; 27 class WebContents;
27 struct PresentationSessionInfo; 28 struct PresentationSessionInfo;
28 struct PresentationSessionMessage; 29 struct PresentationSessionMessage;
29 } // namespace content 30 } // namespace content
30 31
31 namespace media_router { 32 namespace media_router {
32 33
33 class MediaRoute; 34 class MediaRoute;
34 class MediaSinksObserver; 35 class MediaSinksObserver;
36 class OneUAPresentationRouter;
35 class PresentationFrameManager; 37 class PresentationFrameManager;
36 class PresentationSessionStateObserver; 38 class PresentationSessionStateObserver;
37 39
38 // Implementation of PresentationServiceDelegate that interfaces an 40 // Implementation of PresentationServiceDelegate that interfaces an
39 // instance of WebContents with the Chrome Media Router. It uses the Media 41 // instance of WebContents with the Chrome Media Router. It uses the Media
40 // Router to handle presentation API calls forwarded from 42 // Router to handle presentation API calls forwarded from
41 // PresentationServiceImpl. In addition, it also 43 // PresentationServiceImpl. In addition, it also
42 // provides default presentation URL that is required for creating 44 // provides default presentation URL that is required for creating
43 // browser-initiated sessions. 45 // browser-initiated sessions.
44 // It is scoped to the lifetime of a WebContents, and is managed by the 46 // It is scoped to the lifetime of a WebContents, and is managed by the
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 const PresentationSessionSuccessCallback& success_cb, 88 const PresentationSessionSuccessCallback& success_cb,
87 const PresentationSessionErrorCallback& error_cb) override; 89 const PresentationSessionErrorCallback& error_cb) override;
88 void CloseSession(int render_process_id, 90 void CloseSession(int render_process_id,
89 int render_frame_id, 91 int render_frame_id,
90 const std::string& presentation_id) override; 92 const std::string& presentation_id) override;
91 void ListenForSessionMessages( 93 void ListenForSessionMessages(
92 int render_process_id, 94 int render_process_id,
93 int render_frame_id, 95 int render_frame_id,
94 const content::PresentationSessionInfo& session, 96 const content::PresentationSessionInfo& session,
95 const content::PresentationSessionMessageCallback& message_cb) override; 97 const content::PresentationSessionMessageCallback& message_cb) override;
96 void SendMessage(int render_process_id, 98 void SendMessage(
97 int render_frame_id, 99 int render_process_id,
98 const content::PresentationSessionInfo& session, 100 int render_frame_id,
99 scoped_ptr<content::PresentationSessionMessage> message, 101 const content::PresentationSessionInfo& session,
100 const SendMessageCallback& send_message_cb) override; 102 scoped_ptr<content::PresentationSessionMessage> message,
103 const content::SendMessageCallback& send_message_cb) override;
101 void ListenForSessionStateChange( 104 void ListenForSessionStateChange(
102 int render_process_id, 105 int render_process_id,
103 int render_frame_id, 106 int render_frame_id,
104 const content::SessionStateChangedCallback& state_changed_cb) override; 107 const content::SessionStateChangedCallback& state_changed_cb) override;
108 void GetPresenterSession(
mark a. foltz 2015/09/11 23:24:20 FWIW, the terminology in the spec group is moving
imcheng 2015/09/26 01:21:57 Done.
109 int render_process_id,
110 int render_frame_id,
111 const content::PresenterSessionAvailableCallback& success_callback,
112 const base::Callback<void(const std::string&)>& error_callback) override;
113 std::vector<content::PresentationSessionInfo> GetPresenterSessions(
114 int render_process_id,
115 int render_frame_id) override;
105 116
106 // Callback invoked when there is a route response from CreateRoute/JoinRoute 117 // Callback invoked when there is a route response from CreateRoute/JoinRoute
107 // outside of a Presentation API request. This could be due to 118 // outside of a Presentation API request. This could be due to
108 // browser action (e.g., browser initiated media router dialog) or 119 // browser action (e.g., browser initiated media router dialog) or
109 // a media route provider (e.g., autojoin). 120 // a media route provider (e.g., autojoin).
110 void OnRouteResponse(const MediaRoute* route, 121 void OnRouteResponse(const MediaRoute* route,
111 const std::string& presentation_id, 122 const std::string& presentation_id,
112 const std::string& error); 123 const std::string& error,
124 bool is_one_ua_presentation);
113 125
114 // Returns the default MediaSource for this tab if there is one. 126 // Returns the default MediaSource for this tab if there is one.
115 // Returns an empty MediaSource otherwise. 127 // Returns an empty MediaSource otherwise.
116 MediaSource default_source() const { return default_source_; } 128 MediaSource default_source() const { return default_source_; }
117 129
118 content::WebContents* web_contents() const { return web_contents_; } 130 content::WebContents* web_contents() const { return web_contents_; }
119 const GURL& default_frame_url() const { return default_frame_url_; } 131 const GURL& default_frame_url() const { return default_frame_url_; }
120 132
121 // Observer interface for listening to default MediaSource changes for the 133 // Observer interface for listening to default MediaSource changes for the
122 // WebContents. 134 // WebContents.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 MediaSource GetMediaSourceFromListener( 169 MediaSource GetMediaSourceFromListener(
158 content::PresentationScreenAvailabilityListener* listener); 170 content::PresentationScreenAvailabilityListener* listener);
159 171
160 void OnJoinRouteResponse(int render_process_id, 172 void OnJoinRouteResponse(int render_process_id,
161 int render_frame_id, 173 int render_frame_id,
162 const content::PresentationSessionInfo& session, 174 const content::PresentationSessionInfo& session,
163 const PresentationSessionSuccessCallback& success_cb, 175 const PresentationSessionSuccessCallback& success_cb,
164 const PresentationSessionErrorCallback& error_cb, 176 const PresentationSessionErrorCallback& error_cb,
165 const MediaRoute* route, 177 const MediaRoute* route,
166 const std::string& presentation_id, 178 const std::string& presentation_id,
167 const std::string& error_text); 179 const std::string& error_text,
180 bool is_one_ua_presentation);
168 181
169 void OnStartSessionSucceeded( 182 void OnStartSessionSucceeded(
170 int render_process_id, 183 int render_process_id,
171 int render_frame_id, 184 int render_frame_id,
172 const PresentationSessionSuccessCallback& success_cb, 185 const PresentationSessionSuccessCallback& success_cb,
173 const content::PresentationSessionInfo& new_session, 186 const content::PresentationSessionInfo& new_session,
174 const MediaRoute::Id& route_id); 187 const MediaRoute::Id& route_id,
mark a. foltz 2015/09/11 23:24:20 Can we pass the MediaRoute* here and ask if it's a
imcheng 2015/09/26 01:21:57 Done.
188 bool is_one_ua_presentation);
175 189
176 // Returns |true| if the frame is the main frame of |web_contents_|. 190 // Returns |true| if the frame is the main frame of |web_contents_|.
177 bool IsMainFrame(int render_process_id, int render_frame_id) const; 191 bool IsMainFrame(int render_process_id, int render_frame_id) const;
178 192
179 // Updates tab-level default MediaSource and/or default frame URL. If either 193 // Updates tab-level default MediaSource and/or default frame URL. If either
180 // changed, notify the observers. 194 // changed, notify the observers.
181 void UpdateDefaultMediaSourceAndNotifyObservers( 195 void UpdateDefaultMediaSourceAndNotifyObservers(
182 const MediaSource& new_default_source, 196 const MediaSource& new_default_source,
183 const GURL& new_default_frame_url); 197 const GURL& new_default_frame_url);
184 198
199 void RegisterOneUAPresentationController(
200 const content::PresentationSessionInfo& session,
201 const RenderFrameHostId& controller_frame_id);
202
185 // Default MediaSource for the tab associated with this instance. 203 // Default MediaSource for the tab associated with this instance.
186 MediaSource default_source_; 204 MediaSource default_source_;
187 // URL of the frame that contains the default MediaSource. 205 // URL of the frame that contains the default MediaSource.
188 GURL default_frame_url_; 206 GURL default_frame_url_;
189 207
190 // References to the observers listening for changes to default media source. 208 // References to the observers listening for changes to default media source.
191 base::ObserverList< 209 base::ObserverList<
192 DefaultMediaSourceObserver> default_media_source_observers_; 210 DefaultMediaSourceObserver> default_media_source_observers_;
193 211
194 // References to the WebContents that owns this instance, and associated 212 // References to the WebContents that owns this instance, and associated
195 // browser profile's MediaRouter instance. 213 // browser profile's MediaRouter/OneUAPresentationRouter instances.
196 content::WebContents* web_contents_; 214 content::WebContents* const web_contents_;
197 MediaRouter* router_; 215 MediaRouter* router_;
216 OneUAPresentationRouter* const one_ua_presentation_router_;
198 217
199 scoped_ptr<PresentationFrameManager> frame_manager_; 218 scoped_ptr<PresentationFrameManager> frame_manager_;
200 219
201 base::WeakPtrFactory<PresentationServiceDelegateImpl> weak_factory_; 220 base::WeakPtrFactory<PresentationServiceDelegateImpl> weak_factory_;
202 221
203 DISALLOW_COPY_AND_ASSIGN(PresentationServiceDelegateImpl); 222 DISALLOW_COPY_AND_ASSIGN(PresentationServiceDelegateImpl);
204 }; 223 };
205 224
206 } // namespace media_router 225 } // namespace media_router
207 226
208 #endif // CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ 227 #endif // CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698