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

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: Document cause within method declaration Created 5 years, 9 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
« no previous file with comments | « chrome/browser/ui/tabs/tab_utils.h ('k') | chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c010c92c6e33729743763ff9b82fbe4ec9b154f6 100644
--- a/chrome/browser/ui/tabs/tab_utils.cc
+++ b/chrome/browser/ui/tabs/tab_utils.cc
@@ -17,8 +17,22 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/animation/multi_animation.h"
+struct LastMuteMetadata
+ : public content::WebContentsUserData<LastMuteMetadata> {
+ 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 {
+const char kMutedToggleCauseUser[] = "user";
+const char kMutedToggleCauseCapture[] = "auto-forced for capture";
+
namespace {
// Interval between frame updates of the tab indicator animations. This is not
@@ -252,9 +266,25 @@ bool CanToggleAudioMute(content::WebContents* contents) {
return false;
}
-void SetTabAudioMuted(content::WebContents* contents, bool mute) {
+const 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 mute,
+ const std::string& cause) {
if (!contents || !chrome::CanToggleAudioMute(contents))
return;
+
+ LastMuteMetadata::CreateForWebContents(contents); // Create if not exists.
+ LastMuteMetadata::FromWebContents(contents)->cause = cause;
+
contents->SetAudioMuted(mute);
}
« no previous file with comments | « chrome/browser/ui/tabs/tab_utils.h ('k') | chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698