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

Side by Side Diff: chrome/browser/media/media_stream_capture_indicator.cc

Issue 13355003: Minor cleanups in MediaStreamCaptureIndicator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
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/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 void MediaStreamCaptureIndicator::CaptureDevicesOpened( 267 void MediaStreamCaptureIndicator::CaptureDevicesOpened(
268 int render_process_id, 268 int render_process_id,
269 int render_view_id, 269 int render_view_id,
270 const content::MediaStreamDevices& devices, 270 const content::MediaStreamDevices& devices,
271 const base::Closure& close_callback) { 271 const base::Closure& close_callback) {
272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
273 DCHECK(!devices.empty()); 273 DCHECK(!devices.empty());
274 274
275 BrowserThread::PostTask( 275 BrowserThread::PostTask(
276 BrowserThread::UI, FROM_HERE, 276 BrowserThread::UI, FROM_HERE,
277 base::Bind(&MediaStreamCaptureIndicator::DoDevicesOpenedOnUIThread, 277 base::Bind(&MediaStreamCaptureIndicator::AddCaptureDevices,
278 this, render_process_id, render_view_id, devices, 278 this, render_process_id, render_view_id, devices,
279 close_callback)); 279 close_callback));
280 } 280 }
281 281
282 void MediaStreamCaptureIndicator::CaptureDevicesClosed( 282 void MediaStreamCaptureIndicator::CaptureDevicesClosed(
283 int render_process_id, 283 int render_process_id,
284 int render_view_id, 284 int render_view_id,
285 const content::MediaStreamDevices& devices) { 285 const content::MediaStreamDevices& devices) {
286 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 286 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
287 DCHECK(!devices.empty()); 287 DCHECK(!devices.empty());
288 288
289 BrowserThread::PostTask( 289 BrowserThread::PostTask(
290 BrowserThread::UI, FROM_HERE, 290 BrowserThread::UI, FROM_HERE,
291 base::Bind(&MediaStreamCaptureIndicator::DoDevicesClosedOnUIThread, 291 base::Bind(&MediaStreamCaptureIndicator::RemoveCaptureDevices,
292 this, render_process_id, render_view_id, devices)); 292 this, render_process_id, render_view_id, devices));
293 } 293 }
294 294
295 295
296 bool MediaStreamCaptureIndicator::IsCapturingUserMedia( 296 bool MediaStreamCaptureIndicator::IsCapturingUserMedia(
297 int render_process_id, int render_view_id) const { 297 content::WebContents* web_contents) const {
298 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 298 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
299 299
300 WebContents* const web_contents =
301 LookUpByKnownAlias(render_process_id, render_view_id);
302 if (!web_contents)
303 return false;
304
305 UsageMap::const_iterator it = usage_map_.find(web_contents); 300 UsageMap::const_iterator it = usage_map_.find(web_contents);
306 return (it != usage_map_.end() && 301 return (it != usage_map_.end() &&
307 (it->second->IsCapturingAudio() || it->second->IsCapturingVideo())); 302 (it->second->IsCapturingAudio() || it->second->IsCapturingVideo()));
308 } 303 }
309 304
310 bool MediaStreamCaptureIndicator::IsBeingMirrored( 305 bool MediaStreamCaptureIndicator::IsBeingMirrored(
311 int render_process_id, int render_view_id) const { 306 content::WebContents* web_contents) const {
312 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 307 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
313 308
314 WebContents* const web_contents =
315 LookUpByKnownAlias(render_process_id, render_view_id);
316 if (!web_contents)
317 return false;
318
319 UsageMap::const_iterator it = usage_map_.find(web_contents); 309 UsageMap::const_iterator it = usage_map_.find(web_contents);
320 return it != usage_map_.end() && it->second->IsMirroring(); 310 return it != usage_map_.end() && it->second->IsMirroring();
321 } 311 }
322 312
323 void MediaStreamCaptureIndicator::DoDevicesOpenedOnUIThread(
324 int render_process_id,
325 int render_view_id,
326 const content::MediaStreamDevices& devices,
327 const base::Closure& close_callback) {
328 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
329
330 AddCaptureDevices(render_process_id, render_view_id, devices, close_callback);
331 }
332
333 void MediaStreamCaptureIndicator::DoDevicesClosedOnUIThread(
334 int render_process_id,
335 int render_view_id,
336 const content::MediaStreamDevices& devices) {
337 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
338
339 RemoveCaptureDevices(render_process_id, render_view_id, devices);
340 }
341
342 void MediaStreamCaptureIndicator::MaybeCreateStatusTrayIcon() { 313 void MediaStreamCaptureIndicator::MaybeCreateStatusTrayIcon() {
343 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 314 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
344 if (status_icon_) 315 if (status_icon_)
345 return; 316 return;
346 317
347 // If there is no browser process, we should not create the status tray. 318 // If there is no browser process, we should not create the status tray.
348 if (!g_browser_process) 319 if (!g_browser_process)
349 return; 320 return;
350 321
351 StatusTray* status_tray = g_browser_process->status_tray(); 322 StatusTray* status_tray = g_browser_process->status_tray();
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 } 588 }
618 589
619 UpdateNotificationUserInterface(); 590 UpdateNotificationUserInterface();
620 } 591 }
621 592
622 void MediaStreamCaptureIndicator::OnStopScreenCapture( 593 void MediaStreamCaptureIndicator::OnStopScreenCapture(
623 const base::Closure& stop) { 594 const base::Closure& stop) {
624 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 595 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
625 stop.Run(); 596 stop.Run();
626 } 597 }
OLDNEW
« no previous file with comments | « chrome/browser/media/media_stream_capture_indicator.h ('k') | chrome/browser/ui/tabs/tab_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698