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

Unified Diff: content/browser/web_contents/web_contents_impl.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: Improve naming/capitalization for muted toggle strings; remove audible/muted event-listener code fr… Created 6 years 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: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 5ec31a02c05612ac3f3807e8b0e0ed9d560352f4..6a9c6da6df27d9cb705af108bf57672adac3ac14 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -125,6 +125,10 @@ const double kMinimumLoadingProgress = 0.1;
const char kDotGoogleDotCom[] = ".google.com";
+// String to indicate that muted state change is initial
+// (instead of by user, tab capture, or an extension id).
+const char kMutedToggleCauseInit[] = "initial";
+
#if defined(OS_ANDROID)
const char kWebContentsAndroidKey[] = "web_contents_android";
#endif // OS_ANDROID
@@ -310,6 +314,7 @@ WebContentsImpl::WebContentsImpl(BrowserContext* browser_context,
upload_position_(0),
displayed_insecure_content_(false),
has_accessed_initial_document_(false),
+ mutedToggleCause_(kMutedToggleCauseInit),
capturer_count_(0),
should_normally_be_visible_(true),
is_being_destroyed_(false),
@@ -949,14 +954,16 @@ bool WebContentsImpl::IsAudioMuted() const {
return audio_muter_.get() && audio_muter_->is_muting();
}
-void WebContentsImpl::SetAudioMuted(bool mute) {
- DVLOG(1) << "SetAudioMuted(mute=" << mute << "), was " << IsAudioMuted()
- << " for WebContentsImpl@" << this;
+void WebContentsImpl::SetAudioMuted(bool muted, const std::string& cause) {
+ DVLOG(1) << "SetAudioMuted(muted=" << muted << ", cause =" << cause
+ << "), was " << IsAudioMuted() << " for WebContentsImpl@" << this;
- if (mute == IsAudioMuted())
+ if (muted == IsAudioMuted())
return;
- if (mute) {
+ mutedToggleCause_ = cause;
+
+ if (muted) {
if (!audio_muter_)
audio_muter_.reset(new WebContentsAudioMuter(this));
audio_muter_->StartMuting();
@@ -969,6 +976,10 @@ void WebContentsImpl::SetAudioMuted(bool mute) {
NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
}
+const std::string& WebContentsImpl::GetAudioMutedCause() const {
+ return mutedToggleCause_;
+}
+
bool WebContentsImpl::IsCrashed() const {
return (crashed_status_ == base::TERMINATION_STATUS_PROCESS_CRASHED ||
crashed_status_ == base::TERMINATION_STATUS_ABNORMAL_TERMINATION ||

Powered by Google App Engine
This is Rietveld 408576698