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

Side by Side 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 unified diff | 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')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/api/tabs/tabs_api.h" 5 #include "chrome/browser/extensions/api/tabs/tabs_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 1234
1235 if (params->update_properties.pinned.get()) { 1235 if (params->update_properties.pinned.get()) {
1236 bool pinned = *params->update_properties.pinned; 1236 bool pinned = *params->update_properties.pinned;
1237 tab_strip->SetTabPinned(tab_index, pinned); 1237 tab_strip->SetTabPinned(tab_index, pinned);
1238 1238
1239 // Update the tab index because it may move when being pinned. 1239 // Update the tab index because it may move when being pinned.
1240 tab_index = tab_strip->GetIndexOfWebContents(contents); 1240 tab_index = tab_strip->GetIndexOfWebContents(contents);
1241 } 1241 }
1242 1242
1243 if (params->update_properties.muted.get()) { 1243 if (params->update_properties.muted.get()) {
1244 if (chrome::IsTabAudioMutingFeatureEnabled()) { 1244 TabMutedResult tabMutedResult = chrome::SetTabAudioMuted(
1245 if (!chrome::CanToggleAudioMute(contents)) { 1245 contents, *params->update_properties.muted, extension()->id());
1246 WriteToConsole( 1246 std::string msg = "";
1247 content::CONSOLE_MESSAGE_LEVEL_WARNING, 1247
1248 base::StringPrintf( 1248 switch (tabMutedResult) {
1249 "Cannot update mute state for tab %d, tab has audio or video " 1249 case TAB_MUTED_RESULT_FAIL_NOT_ENABLED:
1250 "currently being captured", 1250 msg = base::StringPrintf(
1251 tab_id)); 1251 "Failed to update mute state for tab %d, --%s must be enabled",
1252 } else { 1252 tab_id, switches::kEnableTabAudioMuting);
1253 chrome::SetTabAudioMuted(contents, *params->update_properties.muted, 1253 break;
1254 extension()->id()); 1254 case TAB_MUTED_RESULT_FAIL_TABCAPTURE:
1255 } 1255 msg = base::StringPrintf(
1256 } else { 1256 "Cannot update mute state for tab %d, tab has audio or video"
1257 WriteToConsole(content::CONSOLE_MESSAGE_LEVEL_WARNING, 1257 " currently being captured",
1258 base::StringPrintf( 1258 tab_id);
1259 "Failed to update mute state, --%s must be enabled", 1259 break;
1260 switches::kEnableTabAudioMuting)); 1260 case TAB_MUTED_RESULT_FAIL_RATE_LIMITED:
1261 msg = base::StringPrintf(
1262 "Rate limit exceeded when updating mute state for tab %d.", tab_id);
1263 break;
1264 case TAB_MUTED_RESULT_SUCCESS:
1265 break;
1266 }
1267 if (msg != "") {
1268 WriteToConsole(content::CONSOLE_MESSAGE_LEVEL_ERROR, msg);
1261 } 1269 }
1262 } 1270 }
1263 1271
1264 if (params->update_properties.opener_tab_id.get()) { 1272 if (params->update_properties.opener_tab_id.get()) {
1265 int opener_id = *params->update_properties.opener_tab_id; 1273 int opener_id = *params->update_properties.opener_tab_id;
1266 1274
1267 WebContents* opener_contents = NULL; 1275 WebContents* opener_contents = NULL;
1268 if (!ExtensionTabUtil::GetTabById(opener_id, 1276 if (!ExtensionTabUtil::GetTabById(opener_id,
1269 GetProfile(), 1277 GetProfile(),
1270 include_incognito(), 1278 include_incognito(),
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
2026 ZoomModeToZoomSettings(zoom_mode, &zoom_settings); 2034 ZoomModeToZoomSettings(zoom_mode, &zoom_settings);
2027 zoom_settings.default_zoom_factor.reset(new double( 2035 zoom_settings.default_zoom_factor.reset(new double(
2028 content::ZoomLevelToZoomFactor(zoom_controller->GetDefaultZoomLevel()))); 2036 content::ZoomLevelToZoomFactor(zoom_controller->GetDefaultZoomLevel())));
2029 2037
2030 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings); 2038 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings);
2031 SendResponse(true); 2039 SendResponse(true);
2032 return true; 2040 return true;
2033 } 2041 }
2034 2042
2035 } // namespace extensions 2043 } // namespace extensions
OLDNEW
« 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