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

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

Issue 1784533004: [Media Router] Add origins to sink query results. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 #include <vector> 9 #include <vector>
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 } // namespace 60 } // namespace
61 61
62 // Used by PresentationServiceDelegateImpl to manage 62 // Used by PresentationServiceDelegateImpl to manage
63 // listeners and default presentation info in a render frame. 63 // listeners and default presentation info in a render frame.
64 // Its lifetime: 64 // Its lifetime:
65 // * PresentationFrameManager AddDelegateObserver 65 // * PresentationFrameManager AddDelegateObserver
66 // * Reset 0+ times. 66 // * Reset 0+ times.
67 // * PresentationFrameManager.RemoveDelegateObserver. 67 // * PresentationFrameManager.RemoveDelegateObserver.
68 class PresentationFrame { 68 class PresentationFrame {
69 public: 69 public:
70 PresentationFrame(content::WebContents* web_contents, MediaRouter* router); 70 PresentationFrame(const RenderFrameHostId& render_frame_host_id,
71 content::WebContents* web_contents,
72 MediaRouter* router);
71 ~PresentationFrame(); 73 ~PresentationFrame();
72 74
73 // Mirror corresponding APIs in PresentationServiceDelegateImpl. 75 // Mirror corresponding APIs in PresentationServiceDelegateImpl.
74 bool SetScreenAvailabilityListener( 76 bool SetScreenAvailabilityListener(
75 content::PresentationScreenAvailabilityListener* listener); 77 content::PresentationScreenAvailabilityListener* listener);
76 bool RemoveScreenAvailabilityListener( 78 bool RemoveScreenAvailabilityListener(
77 content::PresentationScreenAvailabilityListener* listener); 79 content::PresentationScreenAvailabilityListener* listener);
78 bool HasScreenAvailabilityListenerForTest( 80 bool HasScreenAvailabilityListenerForTest(
79 const MediaSource::Id& source_id) const; 81 const MediaSource::Id& source_id) const;
80 std::string GetDefaultPresentationId() const; 82 std::string GetDefaultPresentationId() const;
(...skipping 27 matching lines...) Expand all
108 base::SmallMap<std::map<std::string, MediaRoute::Id>> 110 base::SmallMap<std::map<std::string, MediaRoute::Id>>
109 presentation_id_to_route_id_; 111 presentation_id_to_route_id_;
110 base::SmallMap< 112 base::SmallMap<
111 std::map<std::string, scoped_ptr<PresentationMediaSinksObserver>>> 113 std::map<std::string, scoped_ptr<PresentationMediaSinksObserver>>>
112 url_to_sinks_observer_; 114 url_to_sinks_observer_;
113 base::ScopedPtrHashMap<MediaRoute::Id, 115 base::ScopedPtrHashMap<MediaRoute::Id,
114 scoped_ptr<PresentationConnectionStateSubscription>> 116 scoped_ptr<PresentationConnectionStateSubscription>>
115 connection_state_subscriptions_; 117 connection_state_subscriptions_;
116 ScopedVector<PresentationSessionMessagesObserver> session_messages_observers_; 118 ScopedVector<PresentationSessionMessagesObserver> session_messages_observers_;
117 119
120 RenderFrameHostId render_frame_host_id_;
121
118 // References to the owning WebContents, and the corresponding MediaRouter. 122 // References to the owning WebContents, and the corresponding MediaRouter.
119 const content::WebContents* web_contents_; 123 const content::WebContents* web_contents_;
120 MediaRouter* router_; 124 MediaRouter* router_;
121 125
122 DelegateObserver* delegate_observer_; 126 DelegateObserver* delegate_observer_;
123 }; 127 };
124 128
125 PresentationFrame::PresentationFrame(content::WebContents* web_contents, 129 PresentationFrame::PresentationFrame(
126 MediaRouter* router) 130 const RenderFrameHostId& render_frame_host_id,
127 : web_contents_(web_contents), 131 content::WebContents* web_contents,
132 MediaRouter* router)
133 : render_frame_host_id_(render_frame_host_id),
134 web_contents_(web_contents),
128 router_(router), 135 router_(router),
129 delegate_observer_(nullptr) { 136 delegate_observer_(nullptr) {
130 DCHECK(web_contents_); 137 DCHECK(web_contents_);
131 DCHECK(router_); 138 DCHECK(router_);
132 } 139 }
133 140
134 PresentationFrame::~PresentationFrame() { 141 PresentationFrame::~PresentationFrame() {
135 } 142 }
136 143
137 void PresentationFrame::OnPresentationServiceDelegateDestroyed() const { 144 void PresentationFrame::OnPresentationServiceDelegateDestroyed() const {
(...skipping 20 matching lines...) Expand all
158 return route_ids; 165 return route_ids;
159 } 166 }
160 167
161 bool PresentationFrame::SetScreenAvailabilityListener( 168 bool PresentationFrame::SetScreenAvailabilityListener(
162 content::PresentationScreenAvailabilityListener* listener) { 169 content::PresentationScreenAvailabilityListener* listener) {
163 MediaSource source(GetMediaSourceFromListener(listener)); 170 MediaSource source(GetMediaSourceFromListener(listener));
164 auto& sinks_observer = url_to_sinks_observer_[source.id()]; 171 auto& sinks_observer = url_to_sinks_observer_[source.id()];
165 if (sinks_observer && sinks_observer->listener() == listener) 172 if (sinks_observer && sinks_observer->listener() == listener)
166 return false; 173 return false;
167 174
168 sinks_observer.reset( 175 sinks_observer.reset(new PresentationMediaSinksObserver(
169 new PresentationMediaSinksObserver(router_, listener, source)); 176 router_, listener, source,
177 GetLastCommittedURLForFrame(render_frame_host_id_).GetOrigin()));
mark a. foltz 2016/03/11 01:20:23 Can GetLastCommittedURLForFrame() ever fail? What
imcheng 2016/03/14 21:30:20 GetOrigin() will return empty for javascript:. I s
170 178
171 if (!sinks_observer->Init()) { 179 if (!sinks_observer->Init()) {
172 url_to_sinks_observer_.erase(source.id()); 180 url_to_sinks_observer_.erase(source.id());
173 listener->OnScreenAvailabilityNotSupported(); 181 listener->OnScreenAvailabilityNotSupported();
174 return false; 182 return false;
175 } 183 }
176 184
177 return true; 185 return true;
178 } 186 }
179 187
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 auto presentation_frame = presentation_frames_.get(render_frame_host_id); 553 auto presentation_frame = presentation_frames_.get(render_frame_host_id);
546 if (presentation_frame) 554 if (presentation_frame)
547 presentation_frame->RemoveConnection(route_id, presentation_id); 555 presentation_frame->RemoveConnection(route_id, presentation_id);
548 } 556 }
549 557
550 PresentationFrame* PresentationFrameManager::GetOrAddPresentationFrame( 558 PresentationFrame* PresentationFrameManager::GetOrAddPresentationFrame(
551 const RenderFrameHostId& render_frame_host_id) { 559 const RenderFrameHostId& render_frame_host_id) {
552 if (!presentation_frames_.contains(render_frame_host_id)) { 560 if (!presentation_frames_.contains(render_frame_host_id)) {
553 presentation_frames_.add( 561 presentation_frames_.add(
554 render_frame_host_id, 562 render_frame_host_id,
555 scoped_ptr<PresentationFrame>( 563 scoped_ptr<PresentationFrame>(new PresentationFrame(
556 new PresentationFrame(web_contents_, router_))); 564 render_frame_host_id, web_contents_, router_)));
557 } 565 }
558 return presentation_frames_.get(render_frame_host_id); 566 return presentation_frames_.get(render_frame_host_id);
559 } 567 }
560 568
561 void PresentationFrameManager::ClearDefaultPresentationRequest() { 569 void PresentationFrameManager::ClearDefaultPresentationRequest() {
562 default_presentation_started_callback_.Reset(); 570 default_presentation_started_callback_.Reset();
563 if (!default_presentation_request_) 571 if (!default_presentation_request_)
564 return; 572 return;
565 573
566 default_presentation_request_.reset(); 574 default_presentation_request_.reset();
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest( 889 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest(
882 int render_process_id, 890 int render_process_id,
883 int render_frame_id, 891 int render_frame_id,
884 const MediaSource::Id& source_id) const { 892 const MediaSource::Id& source_id) const {
885 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); 893 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id);
886 return frame_manager_->HasScreenAvailabilityListenerForTest( 894 return frame_manager_->HasScreenAvailabilityListenerForTest(
887 render_frame_host_id, source_id); 895 render_frame_host_id, source_id);
888 } 896 }
889 897
890 } // namespace media_router 898 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698