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

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

Issue 1693963003: Pass origin to StartObservingMediaSinks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ready for Review Created 4 years, 10 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 #include "chrome/browser/media/router/presentation_service_delegate_impl.h" 5 #include "chrome/browser/media/router/presentation_service_delegate_impl.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/containers/scoped_ptr_hash_map.h" 10 #include "base/containers/scoped_ptr_hash_map.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // * PresentationFrameManager AddDelegateObserver 62 // * PresentationFrameManager AddDelegateObserver
63 // * Reset 0+ times. 63 // * Reset 0+ times.
64 // * PresentationFrameManager.RemoveDelegateObserver. 64 // * PresentationFrameManager.RemoveDelegateObserver.
65 class PresentationFrame { 65 class PresentationFrame {
66 public: 66 public:
67 PresentationFrame(content::WebContents* web_contents, MediaRouter* router); 67 PresentationFrame(content::WebContents* web_contents, MediaRouter* router);
68 ~PresentationFrame(); 68 ~PresentationFrame();
69 69
70 // Mirror corresponding APIs in PresentationServiceDelegateImpl. 70 // Mirror corresponding APIs in PresentationServiceDelegateImpl.
71 bool SetScreenAvailabilityListener( 71 bool SetScreenAvailabilityListener(
72 content::PresentationScreenAvailabilityListener* listener); 72 content::PresentationScreenAvailabilityListener* listener,
73 const GURL &origin);
73 bool RemoveScreenAvailabilityListener( 74 bool RemoveScreenAvailabilityListener(
74 content::PresentationScreenAvailabilityListener* listener); 75 content::PresentationScreenAvailabilityListener* listener);
75 bool HasScreenAvailabilityListenerForTest( 76 bool HasScreenAvailabilityListenerForTest(
76 const MediaSource::Id& source_id) const; 77 const MediaSource::Id& source_id) const;
77 std::string GetDefaultPresentationId() const; 78 std::string GetDefaultPresentationId() const;
78 void ListenForConnectionStateChange( 79 void ListenForConnectionStateChange(
79 const content::PresentationSessionInfo& connection, 80 const content::PresentationSessionInfo& connection,
80 const content::PresentationConnectionStateChangedCallback& 81 const content::PresentationConnectionStateChangedCallback&
81 state_changed_cb); 82 state_changed_cb);
82 void ListenForSessionMessages( 83 void ListenForSessionMessages(
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 148 }
148 149
149 const std::vector<MediaRoute::Id> PresentationFrame::GetRouteIds() const { 150 const std::vector<MediaRoute::Id> PresentationFrame::GetRouteIds() const {
150 std::vector<MediaRoute::Id> route_ids; 151 std::vector<MediaRoute::Id> route_ids;
151 for (const auto& e : presentation_id_to_route_id_) 152 for (const auto& e : presentation_id_to_route_id_)
152 route_ids.push_back(e.second); 153 route_ids.push_back(e.second);
153 return route_ids; 154 return route_ids;
154 } 155 }
155 156
156 bool PresentationFrame::SetScreenAvailabilityListener( 157 bool PresentationFrame::SetScreenAvailabilityListener(
157 content::PresentationScreenAvailabilityListener* listener) { 158 content::PresentationScreenAvailabilityListener* listener,
159 const GURL &origin) {
158 if (sinks_observer_ && sinks_observer_->listener() == listener) 160 if (sinks_observer_ && sinks_observer_->listener() == listener)
159 return false; 161 return false;
160 162
161 MediaSource source(GetMediaSourceFromListener(listener)); 163 MediaSource source(GetMediaSourceFromListener(listener));
162 sinks_observer_.reset( 164 sinks_observer_.reset(
163 new PresentationMediaSinksObserver(router_, listener, source)); 165 new PresentationMediaSinksObserver(router_, listener, source, origin));
164 166
165 if (!sinks_observer_->Init()) { 167 if (!sinks_observer_->Init()) {
166 sinks_observer_.reset(); 168 sinks_observer_.reset();
167 listener->OnScreenAvailabilityNotSupported(); 169 listener->OnScreenAvailabilityNotSupported();
168 return false; 170 return false;
169 } 171 }
170 172
171 return true; 173 return true;
172 } 174 }
173 175
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 auto presentation_frame = presentation_frames_.get(render_frame_host_id); 417 auto presentation_frame = presentation_frames_.get(render_frame_host_id);
416 return presentation_frame ? presentation_frame->GetRouteIds() 418 return presentation_frame ? presentation_frame->GetRouteIds()
417 : std::vector<MediaRoute::Id>(); 419 : std::vector<MediaRoute::Id>();
418 } 420 }
419 421
420 bool PresentationFrameManager::SetScreenAvailabilityListener( 422 bool PresentationFrameManager::SetScreenAvailabilityListener(
421 const RenderFrameHostId& render_frame_host_id, 423 const RenderFrameHostId& render_frame_host_id,
422 content::PresentationScreenAvailabilityListener* listener) { 424 content::PresentationScreenAvailabilityListener* listener) {
423 DCHECK(listener); 425 DCHECK(listener);
424 auto presentation_frame = GetOrAddPresentationFrame(render_frame_host_id); 426 auto presentation_frame = GetOrAddPresentationFrame(render_frame_host_id);
425 return presentation_frame->SetScreenAvailabilityListener(listener); 427 GURL frame_url(GetLastCommittedURLForFrame(render_frame_host_id));
428 return presentation_frame->SetScreenAvailabilityListener(listener, frame_url);
426 } 429 }
427 430
428 bool PresentationFrameManager::RemoveScreenAvailabilityListener( 431 bool PresentationFrameManager::RemoveScreenAvailabilityListener(
429 const RenderFrameHostId& render_frame_host_id, 432 const RenderFrameHostId& render_frame_host_id,
430 content::PresentationScreenAvailabilityListener* listener) { 433 content::PresentationScreenAvailabilityListener* listener) {
431 DCHECK(listener); 434 DCHECK(listener);
432 auto presentation_frame = presentation_frames_.get(render_frame_host_id); 435 auto presentation_frame = presentation_frames_.get(render_frame_host_id);
433 return presentation_frame && 436 return presentation_frame &&
434 presentation_frame->RemoveScreenAvailabilityListener(listener); 437 presentation_frame->RemoveScreenAvailabilityListener(listener);
435 } 438 }
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest( 877 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest(
875 int render_process_id, 878 int render_process_id,
876 int render_frame_id, 879 int render_frame_id,
877 const MediaSource::Id& source_id) const { 880 const MediaSource::Id& source_id) const {
878 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); 881 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id);
879 return frame_manager_->HasScreenAvailabilityListenerForTest( 882 return frame_manager_->HasScreenAvailabilityListenerForTest(
880 render_frame_host_id, source_id); 883 render_frame_host_id, source_id);
881 } 884 }
882 885
883 } // namespace media_router 886 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698