Index: chrome/browser/media/media_stream_capture_indicator.cc |
diff --git a/chrome/browser/media/media_stream_capture_indicator.cc b/chrome/browser/media/media_stream_capture_indicator.cc |
index 9467b7e60516654c23fd79697f47d10bb2a24984..8b7abcc6f03ee541350b22c2c27a66b3cf74a2a3 100644 |
--- a/chrome/browser/media/media_stream_capture_indicator.cc |
+++ b/chrome/browser/media/media_stream_capture_indicator.cc |
@@ -133,7 +133,6 @@ void MediaStreamCaptureIndicator::DoDevicesClosedOnUIThread( |
if (!status_icon_) |
return; |
- DCHECK(!tabs_.empty()); |
RemoveCaptureDeviceTab(render_process_id, render_view_id, devices); |
} |
@@ -197,6 +196,7 @@ void MediaStreamCaptureIndicator::ShowBalloon( |
void MediaStreamCaptureIndicator::Hide() { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ DCHECK(tabs_.empty()); |
if (!status_icon_) |
return; |
@@ -223,8 +223,11 @@ void MediaStreamCaptureIndicator::UpdateStatusTrayIconContextMenu() { |
string16 tab_title = GetTitle(iter->render_process_id, |
iter->render_view_id); |
// The tab has gone away. |
- if (tab_title.empty()) |
+ if (tab_title.empty()) { |
+ // Delete the entry since the tab has gone away. |
+ tabs_.erase(iter); |
continue; |
+ } |
// Check if any audio and video devices have been used. |
audio = audio || iter->audio_ref_count > 0; |
@@ -241,9 +244,10 @@ void MediaStreamCaptureIndicator::UpdateStatusTrayIconContextMenu() { |
++command_id; |
} |
- // All the tabs have gone away. |
- if (!audio && !video) |
+ if (!audio && !video) { |
+ Hide(); |
return; |
+ } |
// The icon will take the ownership of the passed context menu. |
status_icon_->SetContextMenu(menu.release()); |
@@ -329,10 +333,7 @@ void MediaStreamCaptureIndicator::RemoveCaptureDeviceTab( |
if (iter->audio_ref_count == 0 && iter->video_ref_count == 0) |
tabs_.erase(iter); |
- if (tabs_.empty()) |
- Hide(); |
- else |
- UpdateStatusTrayIconContextMenu(); |
+ UpdateStatusTrayIconContextMenu(); |
} |
string16 MediaStreamCaptureIndicator::GetTitle(int render_process_id, |