Chromium Code Reviews| Index: chrome/browser/ui/tabs/tab_utils.cc |
| diff --git a/chrome/browser/ui/tabs/tab_utils.cc b/chrome/browser/ui/tabs/tab_utils.cc |
| index a61996701309b28c8d94d985247a30ef396d64ae..ea1eaea927a1bd3e8d3341b085765988c1fd55c8 100644 |
| --- a/chrome/browser/ui/tabs/tab_utils.cc |
| +++ b/chrome/browser/ui/tabs/tab_utils.cc |
| @@ -17,6 +17,17 @@ |
| #include "ui/base/resource/resource_bundle.h" |
| #include "ui/gfx/animation/multi_animation.h" |
| +struct LastMuteMetadata : public |
| + content::WebContentsUserData<LastMuteMetadata> { |
|
miu
2015/01/22 00:55:23
style: Please run `git cl format` to make indentat
|
| + std::string cause; // Extension ID or constant from header file |
| + // or empty string |
| + private: |
| + explicit LastMuteMetadata(content::WebContents* contents) {} |
| + friend class content::WebContentsUserData<LastMuteMetadata>; |
| +}; |
| + |
| +DEFINE_WEB_CONTENTS_USER_DATA_KEY(LastMuteMetadata); |
| + |
| namespace chrome { |
| namespace { |
| @@ -252,10 +263,26 @@ bool CanToggleAudioMute(content::WebContents* contents) { |
| return false; |
| } |
| -void SetTabAudioMuted(content::WebContents* contents, bool mute) { |
| +std::string& GetTabAudioMutedCause(content::WebContents* contents) { |
| + LastMuteMetadata::CreateForWebContents(contents); // Create if not exists. |
| + if (GetTabMediaStateForContents(contents) == TAB_MEDIA_STATE_CAPTURING) { |
| + // For tab capture, libcontent forces muting off. |
| + LastMuteMetadata::FromWebContents(contents)->cause = |
| + kMutedToggleCauseCapture; |
| + } |
| + return LastMuteMetadata::FromWebContents(contents)->cause; |
| +} |
| + |
| +void SetTabAudioMuted(content::WebContents* contents, |
| + bool muted, |
| + const std::string& cause) { |
| if (!contents || !chrome::CanToggleAudioMute(contents)) |
| return; |
| - contents->SetAudioMuted(mute); |
| + |
| + LastMuteMetadata::CreateForWebContents(contents); // Create if not exists. |
| + LastMuteMetadata::FromWebContents(contents)->cause = cause; |
| + |
| + contents->SetAudioMuted(muted); |
| } |
| bool IsTabAudioMuted(content::WebContents* contents) { |