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

Unified Diff: chrome/browser/ui/tabs/tab_utils.cc

Issue 757033005: Make tab audible and muted states and cause available for an extension API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Better webcontents_impl decoupling Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
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) {

Powered by Google App Engine
This is Rietveld 408576698