OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/media_stream_capture_indicator.h" | 5 #include "chrome/browser/media/media_stream_capture_indicator.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 const MediaStreamCaptureIndicator::CaptureDeviceTab& tab) { | 117 const MediaStreamCaptureIndicator::CaptureDeviceTab& tab) { |
118 return (render_process_id_ == tab.render_process_id && | 118 return (render_process_id_ == tab.render_process_id && |
119 render_view_id_ == tab.render_view_id); | 119 render_view_id_ == tab.render_view_id); |
120 } | 120 } |
121 | 121 |
122 MediaStreamCaptureIndicator::MediaStreamCaptureIndicator() | 122 MediaStreamCaptureIndicator::MediaStreamCaptureIndicator() |
123 : status_icon_(NULL), | 123 : status_icon_(NULL), |
124 mic_image_(NULL), | 124 mic_image_(NULL), |
125 camera_image_(NULL), | 125 camera_image_(NULL), |
126 balloon_image_(NULL), | 126 balloon_image_(NULL), |
127 request_index_(0) { | 127 request_index_(0), |
128 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | |
128 } | 129 } |
129 | 130 |
130 MediaStreamCaptureIndicator::~MediaStreamCaptureIndicator() { | 131 MediaStreamCaptureIndicator::~MediaStreamCaptureIndicator() { |
131 // The user is responsible for cleaning up by closing all the opened devices. | 132 // The user is responsible for cleaning up by closing all the opened devices. |
132 DCHECK(tabs_.empty()); | 133 DCHECK(tabs_.empty()); |
133 } | 134 } |
134 | 135 |
135 bool MediaStreamCaptureIndicator::IsCommandIdChecked( | 136 bool MediaStreamCaptureIndicator::IsCommandIdChecked( |
136 int command_id) const { | 137 int command_id) const { |
137 NOTIMPLEMENTED() << "There are no checked items in the MediaStream menu."; | 138 NOTIMPLEMENTED() << "There are no checked items in the MediaStream menu."; |
(...skipping 30 matching lines...) Expand all Loading... | |
168 void MediaStreamCaptureIndicator::CaptureDevicesOpened( | 169 void MediaStreamCaptureIndicator::CaptureDevicesOpened( |
169 int render_process_id, | 170 int render_process_id, |
170 int render_view_id, | 171 int render_view_id, |
171 const content::MediaStreamDevices& devices) { | 172 const content::MediaStreamDevices& devices) { |
172 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 173 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
173 DCHECK(!devices.empty()); | 174 DCHECK(!devices.empty()); |
174 | 175 |
175 BrowserThread::PostTask( | 176 BrowserThread::PostTask( |
176 BrowserThread::UI, FROM_HERE, | 177 BrowserThread::UI, FROM_HERE, |
177 base::Bind(&MediaStreamCaptureIndicator::DoDevicesOpenedOnUIThread, | 178 base::Bind(&MediaStreamCaptureIndicator::DoDevicesOpenedOnUIThread, |
178 this, render_process_id, render_view_id, devices)); | 179 weak_ptr_factory_.GetWeakPtr(), |
180 render_process_id, render_view_id, devices)); | |
179 } | 181 } |
180 | 182 |
181 void MediaStreamCaptureIndicator::CaptureDevicesClosed( | 183 void MediaStreamCaptureIndicator::CaptureDevicesClosed( |
182 int render_process_id, | 184 int render_process_id, |
183 int render_view_id, | 185 int render_view_id, |
184 const content::MediaStreamDevices& devices) { | 186 const content::MediaStreamDevices& devices) { |
185 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 187 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
186 DCHECK(!devices.empty()); | 188 DCHECK(!devices.empty()); |
187 | 189 |
188 BrowserThread::PostTask( | 190 BrowserThread::PostTask( |
189 BrowserThread::UI, FROM_HERE, | 191 BrowserThread::UI, FROM_HERE, |
190 base::Bind(&MediaStreamCaptureIndicator::DoDevicesClosedOnUIThread, | 192 base::Bind(&MediaStreamCaptureIndicator::DoDevicesClosedOnUIThread, |
191 this, render_process_id, render_view_id, devices)); | 193 weak_ptr_factory_.GetWeakPtr(), |
no longer working on chromium
2012/10/23 08:56:53
Do we know that if MediaInternals will always outl
stevenjb
2012/10/23 18:11:31
As a Singleton, yes, it will outlive the UI messag
| |
194 render_process_id, render_view_id, devices)); | |
192 } | 195 } |
193 | 196 |
194 void MediaStreamCaptureIndicator::DoDevicesOpenedOnUIThread( | 197 void MediaStreamCaptureIndicator::DoDevicesOpenedOnUIThread( |
195 int render_process_id, | 198 int render_process_id, |
196 int render_view_id, | 199 int render_view_id, |
197 const content::MediaStreamDevices& devices) { | 200 const content::MediaStreamDevices& devices) { |
198 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 201 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
199 | 202 |
200 CreateStatusTray(); | 203 CreateStatusTray(); |
201 | 204 |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
444 } | 447 } |
445 | 448 |
446 // Remove the tab if all the devices have been closed. | 449 // Remove the tab if all the devices have been closed. |
447 if (iter->audio_ref_count == 0 && iter->video_ref_count == 0) | 450 if (iter->audio_ref_count == 0 && iter->video_ref_count == 0) |
448 tabs_.erase(iter); | 451 tabs_.erase(iter); |
449 } | 452 } |
450 | 453 |
451 UpdateStatusTrayIconContextMenu(); | 454 UpdateStatusTrayIconContextMenu(); |
452 } | 455 } |
453 | 456 |
457 bool MediaStreamCaptureIndicator::IsProcessCapturing(int render_process_id, | |
458 int render_view_id) const { | |
459 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
460 CaptureDeviceTabs::const_iterator iter = std::find_if( | |
461 tabs_.begin(), tabs_.end(), TabEquals(render_process_id, render_view_id)); | |
462 if (iter == tabs_.end()) | |
463 return false; | |
464 return (iter->audio_ref_count > 0 || iter->video_ref_count > 0); | |
465 } | |
466 | |
454 void MediaStreamCaptureIndicator::EnsureImageLoadingTracker() { | 467 void MediaStreamCaptureIndicator::EnsureImageLoadingTracker() { |
455 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 468 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
456 if (tracker_.get()) | 469 if (tracker_.get()) |
457 return; | 470 return; |
458 | 471 |
459 tracker_.reset(new ImageLoadingTracker(this)); | 472 tracker_.reset(new ImageLoadingTracker(this)); |
460 pending_messages_.clear(); | 473 pending_messages_.clear(); |
461 request_index_ = 0; | 474 request_index_ = 0; |
462 } | 475 } |
OLD | NEW |