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

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

Issue 1233263002: Clean up error handling logic for extension tab muting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: include case for TAB_MUTED_RESULT_SUCCESS first within switch to match enum order Created 5 years, 5 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/test/data/extensions/api_test/tabs/basics/muted.js » ('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 cfe6282b03aeb2d6ad9a80104fae4874f394a759..29e514420319925f94902fbb46c0ce93e99a7407 100644
--- a/chrome/browser/ui/tabs/tab_utils.cc
+++ b/chrome/browser/ui/tabs/tab_utils.cc
@@ -276,16 +276,23 @@ const std::string& GetTabAudioMutedCause(content::WebContents* contents) {
return LastMuteMetadata::FromWebContents(contents)->cause;
}
-void SetTabAudioMuted(content::WebContents* contents,
- bool mute,
- const std::string& cause) {
- if (!contents || !chrome::CanToggleAudioMute(contents))
- return;
+TabMutedResult SetTabAudioMuted(content::WebContents* contents,
+ bool mute,
+ const std::string& cause) {
+ DCHECK(contents);
+
+ if (!IsTabAudioMutingFeatureEnabled())
+ return TAB_MUTED_RESULT_FAIL_NOT_ENABLED;
+
+ if (!chrome::CanToggleAudioMute(contents))
+ return TAB_MUTED_RESULT_FAIL_TABCAPTURE;
LastMuteMetadata::CreateForWebContents(contents); // Create if not exists.
- LastMuteMetadata::FromWebContents(contents)->cause = cause;
contents->SetAudioMuted(mute);
+ LastMuteMetadata::FromWebContents(contents)->cause = cause;
+
+ return TAB_MUTED_RESULT_SUCCESS;
}
bool IsTabAudioMuted(content::WebContents* contents) {
« no previous file with comments | « chrome/browser/ui/tabs/tab_utils.h ('k') | chrome/test/data/extensions/api_test/tabs/basics/muted.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698