| 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/ui/tabs/tab_utils.h" | 5 #include "chrome/browser/ui/tabs/tab_utils.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 9 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
| 10 #include "chrome/browser/media/media_stream_capture_indicator.h" | 10 #include "chrome/browser/media/media_stream_capture_indicator.h" |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 const std::string& GetTabAudioMutedCause(content::WebContents* contents) { | 269 const std::string& GetTabAudioMutedCause(content::WebContents* contents) { |
| 270 LastMuteMetadata::CreateForWebContents(contents); // Create if not exists. | 270 LastMuteMetadata::CreateForWebContents(contents); // Create if not exists. |
| 271 if (GetTabMediaStateForContents(contents) == TAB_MEDIA_STATE_CAPTURING) { | 271 if (GetTabMediaStateForContents(contents) == TAB_MEDIA_STATE_CAPTURING) { |
| 272 // For tab capture, libcontent forces muting off. | 272 // For tab capture, libcontent forces muting off. |
| 273 LastMuteMetadata::FromWebContents(contents)->cause = | 273 LastMuteMetadata::FromWebContents(contents)->cause = |
| 274 kMutedToggleCauseCapture; | 274 kMutedToggleCauseCapture; |
| 275 } | 275 } |
| 276 return LastMuteMetadata::FromWebContents(contents)->cause; | 276 return LastMuteMetadata::FromWebContents(contents)->cause; |
| 277 } | 277 } |
| 278 | 278 |
| 279 void SetTabAudioMuted(content::WebContents* contents, | 279 TabMutedResult SetTabAudioMuted(content::WebContents* contents, |
| 280 bool mute, | 280 bool mute, |
| 281 const std::string& cause) { | 281 const std::string& cause) { |
| 282 if (!contents || !chrome::CanToggleAudioMute(contents)) | 282 DCHECK(contents); |
| 283 return; | 283 |
| 284 if (!IsTabAudioMutingFeatureEnabled()) |
| 285 return TAB_MUTED_RESULT_FAIL_NOT_ENABLED; |
| 286 |
| 287 if (!chrome::CanToggleAudioMute(contents)) |
| 288 return TAB_MUTED_RESULT_FAIL_TABCAPTURE; |
| 284 | 289 |
| 285 LastMuteMetadata::CreateForWebContents(contents); // Create if not exists. | 290 LastMuteMetadata::CreateForWebContents(contents); // Create if not exists. |
| 291 |
| 292 contents->SetAudioMuted(mute); |
| 286 LastMuteMetadata::FromWebContents(contents)->cause = cause; | 293 LastMuteMetadata::FromWebContents(contents)->cause = cause; |
| 287 | 294 |
| 288 contents->SetAudioMuted(mute); | 295 return TAB_MUTED_RESULT_SUCCESS; |
| 289 } | 296 } |
| 290 | 297 |
| 291 bool IsTabAudioMuted(content::WebContents* contents) { | 298 bool IsTabAudioMuted(content::WebContents* contents) { |
| 292 return contents && contents->IsAudioMuted(); | 299 return contents && contents->IsAudioMuted(); |
| 293 } | 300 } |
| 294 | 301 |
| 295 bool AreAllTabsMuted(const TabStripModel& tab_strip, | 302 bool AreAllTabsMuted(const TabStripModel& tab_strip, |
| 296 const std::vector<int>& indices) { | 303 const std::vector<int>& indices) { |
| 297 for (std::vector<int>::const_iterator i = indices.begin(); i != indices.end(); | 304 for (std::vector<int>::const_iterator i = indices.begin(); i != indices.end(); |
| 298 ++i) { | 305 ++i) { |
| 299 if (!IsTabAudioMuted(tab_strip.GetWebContentsAt(*i))) | 306 if (!IsTabAudioMuted(tab_strip.GetWebContentsAt(*i))) |
| 300 return false; | 307 return false; |
| 301 } | 308 } |
| 302 return true; | 309 return true; |
| 303 } | 310 } |
| 304 | 311 |
| 305 } // namespace chrome | 312 } // namespace chrome |
| OLD | NEW |