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

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: Restore capitalization of LastMuteMetadata 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/ui/tabs/tab_utils.h » ('j') | chrome/browser/ui/tabs/tab_utils.h » ('J')
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..11dc1df4b2b91b086995d5ae46edf4546b03f5a7 100644
--- a/chrome/browser/extensions/api/tabs/tabs_api.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_api.cc
@@ -1241,23 +1241,31 @@ 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());
+ std::string msg = "";
+
+ switch (tabMutedResult) {
+ case TAB_MUTED_RESULT_FAIL_NOT_ENABLED:
+ msg = base::StringPrintf(
+ "Failed to update mute state for tab %d, --%s must be enabled",
+ tab_id, switches::kEnableTabAudioMuting);
+ break;
+ case TAB_MUTED_RESULT_FAIL_TABCAPTURE:
+ msg = base::StringPrintf(
+ "Cannot update mute state for tab %d, tab has audio or video"
+ " currently being captured",
+ tab_id);
+ break;
+ case TAB_MUTED_RESULT_FAIL_RATE_LIMITED:
+ msg = base::StringPrintf(
+ "Rate limit exceeded when updating mute state for tab %d.", tab_id);
+ break;
+ case TAB_MUTED_RESULT_SUCCESS:
+ break;
+ }
+ if (msg != "") {
+ WriteToConsole(content::CONSOLE_MESSAGE_LEVEL_ERROR, msg);
}
}
« no previous file with comments | « no previous file | chrome/browser/ui/tabs/tab_utils.h » ('j') | chrome/browser/ui/tabs/tab_utils.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698