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

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: Fix issues from #4. Also use tab_constants for error strings." 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
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..8f852768e564ad72bba57bbb5a007e2865accc6f 100644
--- a/chrome/browser/extensions/api/tabs/tabs_api.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_api.cc
@@ -1241,23 +1241,25 @@ 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 tabMutedResult = chrome::SetTabAudioMuted(
+ contents, *params->update_properties.muted, extension()->id());
+
+ switch (tabMutedResult) {
+ 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;
+ case TAB_MUTED_RESULT_FAIL_RATE_LIMITED:
+ error_ = ErrorUtils::FormatErrorMessage(
+ keys::kCannotUpdateMuteRateLimited, base::IntToString(tab_id));
+ return false;
+ case TAB_MUTED_RESULT_SUCCESS:
+ break;
}
}

Powered by Google App Engine
This is Rietveld 408576698