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

Unified Diff: chrome/browser/extensions/api/tabs/tabs_api.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 | « no previous file | chrome/browser/extensions/api/tabs/tabs_constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/tabs/tabs_api.cc
diff --git a/chrome/browser/extensions/api/tabs/tabs_api.cc b/chrome/browser/extensions/api/tabs/tabs_api.cc
index 83827fb16c30ebaace2bf039766634fd3036c383..4ef6db3b873a1c2116feea67eea9eb4ea5cf6cc5 100644
--- a/chrome/browser/extensions/api/tabs/tabs_api.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_api.cc
@@ -1241,23 +1241,21 @@ bool TabsUpdateFunction::RunAsync() {
}
if (params->update_properties.muted.get()) {
- if (chrome::IsTabAudioMutingFeatureEnabled()) {
- if (!chrome::CanToggleAudioMute(contents)) {
- WriteToConsole(
- content::CONSOLE_MESSAGE_LEVEL_WARNING,
- base::StringPrintf(
- "Cannot update mute state for tab %d, tab has audio or video "
- "currently being captured",
- tab_id));
- } else {
- chrome::SetTabAudioMuted(contents, *params->update_properties.muted,
- extension()->id());
- }
- } else {
- WriteToConsole(content::CONSOLE_MESSAGE_LEVEL_WARNING,
- base::StringPrintf(
- "Failed to update mute state, --%s must be enabled",
- switches::kEnableTabAudioMuting));
+ TabMutedResult tab_muted_result = chrome::SetTabAudioMuted(
+ contents, *params->update_properties.muted, extension()->id());
+
+ switch (tab_muted_result) {
+ case TAB_MUTED_RESULT_SUCCESS:
+ break;
+ case TAB_MUTED_RESULT_FAIL_NOT_ENABLED:
+ error_ = ErrorUtils::FormatErrorMessage(
+ keys::kCannotUpdateMuteDisabled, base::IntToString(tab_id),
+ switches::kEnableTabAudioMuting);
+ return false;
+ case TAB_MUTED_RESULT_FAIL_TABCAPTURE:
+ error_ = ErrorUtils::FormatErrorMessage(keys::kCannotUpdateMuteCaptured,
+ base::IntToString(tab_id));
+ return false;
}
}
« no previous file with comments | « no previous file | chrome/browser/extensions/api/tabs/tabs_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698