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

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

Issue 2379703002: [Presentation API] (alternative) 1-UA: send message between controller and receiver page (Closed)
Patch Set: resolve code review comments from Mark Created 4 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.
mark a. foltz 2016/10/08 00:33:41 Update copyright
zhaobin 2016/10/12 02:27:33 Done.
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 #include "url/gurl.h"
11
12 DEFINE_WEB_CONTENTS_USER_DATA_KEY(
13 media_router::ReceiverPresentationServiceDelegateImpl);
14
15 using content::PresentationServiceDelegate;
16 using content::RenderFrameHost;
17
18 namespace media_router {
19
20 // static
21 void ReceiverPresentationServiceDelegateImpl::CreateForWebContents(
22 content::WebContents* web_contents,
23 const std::string& presentation_id) {
24 DCHECK(web_contents);
25
26 if (FromWebContents(web_contents))
27 return;
28
29 web_contents->SetUserData(UserDataKey(),
30 new ReceiverPresentationServiceDelegateImpl(
31 web_contents, presentation_id));
32 }
33
34 ReceiverPresentationServiceDelegateImpl::
35 ~ReceiverPresentationServiceDelegateImpl() {
36 for (auto& observer_pair : observers_)
37 observer_pair.second->OnDelegateDestroyed();
38 }
39
40 void ReceiverPresentationServiceDelegateImpl::AddObserver(
mark a. foltz 2016/10/08 00:33:42 IMO it would be worth having a base class for the
zhaobin 2016/10/12 02:27:33 Done.
41 int render_process_id,
42 int render_frame_id,
43 content::PresentationServiceDelegate::Observer* observer) {
44 DCHECK(observer);
45
46 RenderFrameHostId rfh_id(render_process_id, render_frame_id);
47 DCHECK(!base::ContainsKey(observers_, rfh_id));
48 observers_[rfh_id] = observer;
49 }
50
51 void ReceiverPresentationServiceDelegateImpl::RemoveObserver(
52 int render_process_id,
53 int render_frame_id) {
54 observers_.erase(RenderFrameHostId(render_process_id, render_frame_id));
55 }
56
57 bool ReceiverPresentationServiceDelegateImpl::AddScreenAvailabilityListener(
58 int render_process_id,
59 int render_frame_id,
60 content::PresentationScreenAvailabilityListener* listener) {
61 NOTIMPLEMENTED();
62 return false;
63 }
64
65 void ReceiverPresentationServiceDelegateImpl::RemoveScreenAvailabilityListener(
66 int render_process_id,
67 int render_frame_id,
68 content::PresentationScreenAvailabilityListener* listener) {
69 NOTIMPLEMENTED();
70 }
71
72 void ReceiverPresentationServiceDelegateImpl::Reset(int render_process_id,
73 int render_frame_id) {
74 DVLOG(2) << __FUNCTION__ << render_process_id << ", " << render_frame_id;
75 offscreen_presentation_manager_->OnOffscreenPresentationReceiverTerminated(
76 presentation_id_);
77 }
78
79 void ReceiverPresentationServiceDelegateImpl::SetDefaultPresentationUrls(
80 int render_process_id,
81 int render_frame_id,
82 const std::vector<std::string>& default_presentation_urls,
83 const content::PresentationSessionStartedCallback& callback) {
84 NOTIMPLEMENTED();
85 }
86
87 void ReceiverPresentationServiceDelegateImpl::StartSession(
88 int render_process_id,
89 int render_frame_id,
90 const std::vector<std::string>& presentation_urls,
91 const content::PresentationSessionStartedCallback& success_cb,
92 const content::PresentationSessionErrorCallback& error_cb) {
93 NOTIMPLEMENTED();
94 error_cb.Run(content::PresentationError(content::PRESENTATION_ERROR_UNKNOWN,
95 "Not implemented"));
96 }
97
98 void ReceiverPresentationServiceDelegateImpl::JoinSession(
99 int render_process_id,
100 int render_frame_id,
101 const std::vector<std::string>& presentation_urls,
102 const std::string& presentation_id,
103 const content::PresentationSessionStartedCallback& success_cb,
104 const content::PresentationSessionErrorCallback& error_cb) {
105 NOTIMPLEMENTED();
106 error_cb.Run(content::PresentationError(content::PRESENTATION_ERROR_UNKNOWN,
107 "Not implemented"));
108 }
109
110 void ReceiverPresentationServiceDelegateImpl::CloseConnection(
111 int render_process_id,
112 int render_frame_id,
113 const std::string& presentation_id) {
114 NOTIMPLEMENTED();
mark a. foltz 2016/10/08 00:33:41 This should be implemented eventually right?
zhaobin 2016/10/12 02:27:33 Maybe not if close/terminate can be handled at ren
115 }
116
117 void ReceiverPresentationServiceDelegateImpl::Terminate(
118 int render_process_id,
119 int render_frame_id,
120 const std::string& presentation_id) {
121 NOTIMPLEMENTED();
mark a. foltz 2016/10/08 00:33:41 Should be implemented in the future?
zhaobin 2016/10/12 02:27:33 Same as above.
122 }
123
124 void ReceiverPresentationServiceDelegateImpl::ListenForSessionMessages(
125 int render_process_id,
126 int render_frame_id,
127 const content::PresentationSessionInfo& session_info,
128 const content::PresentationSessionMessageCallback& message_cb) {
129 NOTIMPLEMENTED();
130 }
131
132 void ReceiverPresentationServiceDelegateImpl::SendMessage(
133 int render_process_id,
134 int render_frame_id,
135 const content::PresentationSessionInfo& session_info,
136 std::unique_ptr<content::PresentationSessionMessage> message,
137 const SendMessageCallback& send_message_cb) {
138 NOTIMPLEMENTED();
139 }
140
141 void ReceiverPresentationServiceDelegateImpl::ListenForConnectionStateChange(
142 int render_process_id,
143 int render_frame_id,
144 const content::PresentationSessionInfo& connection,
145 const content::PresentationConnectionStateChangedCallback&
146 state_changed_cb) {
147 NOTIMPLEMENTED();
148 }
149
150 ReceiverPresentationServiceDelegateImpl::
151 ReceiverPresentationServiceDelegateImpl(content::WebContents* web_contents,
152 const std::string& presentation_id)
153 : web_contents_(web_contents),
154 presentation_id_(presentation_id),
155 offscreen_presentation_manager_(
156 OffscreenPresentationManagerFactory::GetOrCreateForBrowserContext(
157 Profile::FromBrowserContext(web_contents_->GetBrowserContext())
158 ->GetOriginalProfile())) {
159 DCHECK(web_contents_);
160 DCHECK(!presentation_id.empty());
161 DCHECK(offscreen_presentation_manager_);
162 DCHECK(web_contents_->GetBrowserContext()->IsOffTheRecord());
163 }
164
165 void ReceiverPresentationServiceDelegateImpl::RegisterReceiverAvailableCallback(
166 const content::ReceiverConnectionAvailableCallback&
167 receiver_available_callback) {
168 std::string presentation_url = web_contents_->GetURL().spec();
mark a. foltz 2016/10/08 00:33:41 Can you just pass the URL directly?
zhaobin 2016/10/12 02:27:33 Done.
169 offscreen_presentation_manager_->OnOffscreenPresentationReceiverCreated(
170 presentation_id_, GURL(presentation_url), receiver_available_callback);
171 }
172
173 void ReceiverPresentationServiceDelegateImpl::
174 RegisterOffscreenPresentationConnection(
175 int render_process_id,
176 int render_frame_id,
177 const content::PresentationSessionInfo& session,
178 content::PresentationConnectionPtr connection) {
179 NOTREACHED();
180 }
181
182 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698