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

Side by Side Diff: chrome/browser/media/router/receiver_presentation_service_delegate_impl.cc

Issue 2343013002: [Presentation API] (MR side) 1-UA: notify receiver page when receiver connection becomes available (Closed)
Patch Set: resolve code review comments from Derek Created 4 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
(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 #include "chrome/browser/media/router/receiver_presentation_service_delegate_imp l.h"
6
7 #include "chrome/browser/profiles/profile.h"
8 #include "content/public/browser/render_frame_host.h"
9 #include "content/public/browser/render_process_host.h"
10
11 DEFINE_WEB_CONTENTS_USER_DATA_KEY(
12 media_router::ReceiverPresentationServiceDelegateImpl);
13
14 using content::PresentationServiceDelegate;
15 using content::RenderFrameHost;
16
17 namespace media_router {
18
19 // static
20 void ReceiverPresentationServiceDelegateImpl::CreateForWebContents(
21 content::WebContents* web_contents,
22 const std::string& presentation_id) {
23 DCHECK(web_contents);
24
25 if (FromWebContents(web_contents))
26 return;
27
28 web_contents->SetUserData(UserDataKey(),
29 new ReceiverPresentationServiceDelegateImpl(
30 web_contents, presentation_id));
31 }
32
33 ReceiverPresentationServiceDelegateImpl::
34 ~ReceiverPresentationServiceDelegateImpl() {
35 for (auto& observer_pair : observers_)
36 observer_pair.second->OnDelegateDestroyed();
37 }
38
39 void ReceiverPresentationServiceDelegateImpl::AddObserver(
40 int render_process_id,
41 int render_frame_id,
42 content::PresentationServiceDelegate::Observer* observer) {
43 DCHECK(observer);
44
45 RenderFrameHostId rfh_id(render_process_id, render_frame_id);
46 DCHECK(!base::ContainsKey(observers_, rfh_id));
47 observers_[rfh_id] = observer;
48 }
49
50 void ReceiverPresentationServiceDelegateImpl::RemoveObserver(
51 int render_process_id,
52 int render_frame_id) {
53 observers_.erase(RenderFrameHostId(render_process_id, render_frame_id));
54 }
55
56 bool ReceiverPresentationServiceDelegateImpl::AddScreenAvailabilityListener(
57 int render_process_id,
58 int render_frame_id,
59 content::PresentationScreenAvailabilityListener* listener) {
60 NOTIMPLEMENTED();
61 return false;
62 }
63
64 void ReceiverPresentationServiceDelegateImpl::RemoveScreenAvailabilityListener(
65 int render_process_id,
66 int render_frame_id,
67 content::PresentationScreenAvailabilityListener* listener) {
68 NOTIMPLEMENTED();
69 }
70
71 void ReceiverPresentationServiceDelegateImpl::Reset(int render_process_id,
72 int render_frame_id) {
73 DVLOG(2) << __FUNCTION__ << render_process_id << ", " << render_frame_id;
74 offscreen_presentation_manager_->UnregisterOffscreenPresentationReceiver(
75 presentation_id_);
76 }
77
78 void ReceiverPresentationServiceDelegateImpl::SetDefaultPresentationUrls(
79 int render_process_id,
80 int render_frame_id,
81 const std::vector<std::string>& default_presentation_urls,
82 const content::PresentationSessionStartedCallback& callback) {
83 NOTIMPLEMENTED();
84 }
85
86 void ReceiverPresentationServiceDelegateImpl::StartSession(
87 int render_process_id,
88 int render_frame_id,
89 const std::vector<std::string>& presentation_urls,
90 const content::PresentationSessionStartedCallback& success_cb,
91 const content::PresentationSessionErrorCallback& error_cb) {
92 NOTIMPLEMENTED();
93 error_cb.Run(content::PresentationError(content::PRESENTATION_ERROR_UNKNOWN,
94 "Not implemented"));
95 }
96
97 void ReceiverPresentationServiceDelegateImpl::JoinSession(
98 int render_process_id,
99 int render_frame_id,
100 const std::vector<std::string>& presentation_urls,
101 const std::string& presentation_id,
102 const content::PresentationSessionStartedCallback& success_cb,
103 const content::PresentationSessionErrorCallback& error_cb) {
104 NOTIMPLEMENTED();
105 error_cb.Run(content::PresentationError(content::PRESENTATION_ERROR_UNKNOWN,
106 "Not implemented"));
107 }
108
109 void ReceiverPresentationServiceDelegateImpl::CloseConnection(
110 int render_process_id,
111 int render_frame_id,
112 const std::string& presentation_id) {
113 NOTIMPLEMENTED();
114 }
115
116 void ReceiverPresentationServiceDelegateImpl::Terminate(
117 int render_process_id,
118 int render_frame_id,
119 const std::string& presentation_id) {
120 NOTIMPLEMENTED();
121 }
122
123 void ReceiverPresentationServiceDelegateImpl::ListenForSessionMessages(
124 int render_process_id,
125 int render_frame_id,
126 const content::PresentationSessionInfo& session_info,
127 const content::PresentationSessionMessageCallback& message_cb) {
128 NOTIMPLEMENTED();
129 }
130
131 void ReceiverPresentationServiceDelegateImpl::SendMessage(
132 int render_process_id,
133 int render_frame_id,
134 const content::PresentationSessionInfo& session_info,
135 std::unique_ptr<content::PresentationSessionMessage> message,
136 const SendMessageCallback& send_message_cb) {
137 NOTIMPLEMENTED();
138 }
139
140 void ReceiverPresentationServiceDelegateImpl::ListenForConnectionStateChange(
141 int render_process_id,
142 int render_frame_id,
143 const content::PresentationSessionInfo& connection,
144 const content::PresentationConnectionStateChangedCallback&
145 state_changed_cb) {
146 NOTIMPLEMENTED();
147 }
148
149 ReceiverPresentationServiceDelegateImpl::
150 ReceiverPresentationServiceDelegateImpl(content::WebContents* web_contents,
151 const std::string& presentation_id)
152 : web_contents_(web_contents),
153 presentation_id_(presentation_id),
154 offscreen_presentation_manager_(
155 OffscreenPresentationManagerFactory::GetOrCreateForBrowserContext(
156 Profile::FromBrowserContext(web_contents_->GetBrowserContext())
157 ->GetOriginalProfile())) {
158 DCHECK(web_contents_);
159 DCHECK(!presentation_id.empty());
160 DCHECK(offscreen_presentation_manager_);
161 DCHECK(web_contents_->GetBrowserContext()->IsOffTheRecord());
162 }
163
164 void ReceiverPresentationServiceDelegateImpl::RegisterReceiverAvailableCallback(
165 const content::ReceiverConnectionAvailableCallback&
166 receiver_available_callback) {
167 offscreen_presentation_manager_->RegisterOffscreenPresentationReceiver(
168 presentation_id_, receiver_available_callback);
169 }
170
171 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698