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

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: 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/api/tabs/tabs_constants.h » ('j') | no next file with comments »
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 tab_muted_result = chrome::SetTabAudioMuted(
1245 if (!chrome::CanToggleAudioMute(contents)) { 1245 contents, *params->update_properties.muted, extension()->id());
1246 WriteToConsole( 1246
1247 content::CONSOLE_MESSAGE_LEVEL_WARNING, 1247 switch (tab_muted_result) {
1248 base::StringPrintf( 1248 case TAB_MUTED_RESULT_SUCCESS:
1249 "Cannot update mute state for tab %d, tab has audio or video " 1249 break;
1250 "currently being captured", 1250 case TAB_MUTED_RESULT_FAIL_NOT_ENABLED:
1251 tab_id)); 1251 error_ = ErrorUtils::FormatErrorMessage(
1252 } else { 1252 keys::kCannotUpdateMuteDisabled, base::IntToString(tab_id),
1253 chrome::SetTabAudioMuted(contents, *params->update_properties.muted, 1253 switches::kEnableTabAudioMuting);
1254 extension()->id()); 1254 return false;
1255 } 1255 case TAB_MUTED_RESULT_FAIL_TABCAPTURE:
1256 } else { 1256 error_ = ErrorUtils::FormatErrorMessage(keys::kCannotUpdateMuteCaptured,
1257 WriteToConsole(content::CONSOLE_MESSAGE_LEVEL_WARNING, 1257 base::IntToString(tab_id));
1258 base::StringPrintf( 1258 return false;
1259 "Failed to update mute state, --%s must be enabled",
1260 switches::kEnableTabAudioMuting));
1261 } 1259 }
1262 } 1260 }
1263 1261
1264 if (params->update_properties.opener_tab_id.get()) { 1262 if (params->update_properties.opener_tab_id.get()) {
1265 int opener_id = *params->update_properties.opener_tab_id; 1263 int opener_id = *params->update_properties.opener_tab_id;
1266 1264
1267 WebContents* opener_contents = NULL; 1265 WebContents* opener_contents = NULL;
1268 if (!ExtensionTabUtil::GetTabById(opener_id, 1266 if (!ExtensionTabUtil::GetTabById(opener_id,
1269 GetProfile(), 1267 GetProfile(),
1270 include_incognito(), 1268 include_incognito(),
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
2026 ZoomModeToZoomSettings(zoom_mode, &zoom_settings); 2024 ZoomModeToZoomSettings(zoom_mode, &zoom_settings);
2027 zoom_settings.default_zoom_factor.reset(new double( 2025 zoom_settings.default_zoom_factor.reset(new double(
2028 content::ZoomLevelToZoomFactor(zoom_controller->GetDefaultZoomLevel()))); 2026 content::ZoomLevelToZoomFactor(zoom_controller->GetDefaultZoomLevel())));
2029 2027
2030 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings); 2028 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings);
2031 SendResponse(true); 2029 SendResponse(true);
2032 return true; 2030 return true;
2033 } 2031 }
2034 2032
2035 } // namespace extensions 2033 } // namespace extensions
OLDNEW
« 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