Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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( |
|
not at google - send to devlin
2015/07/24 21:48:48
tab_muted_result
| |
| 1245 if (!chrome::CanToggleAudioMute(contents)) { | 1245 contents, *params->update_properties.muted, extension()->id()); |
| 1246 WriteToConsole( | 1246 |
| 1247 content::CONSOLE_MESSAGE_LEVEL_WARNING, | 1247 switch (tabMutedResult) { |
| 1248 base::StringPrintf( | 1248 case TAB_MUTED_RESULT_FAIL_NOT_ENABLED: |
| 1249 "Cannot update mute state for tab %d, tab has audio or video " | 1249 error_ = ErrorUtils::FormatErrorMessage( |
| 1250 "currently being captured", | 1250 keys::kCannotUpdateMuteDisabled, base::IntToString(tab_id), |
| 1251 tab_id)); | 1251 switches::kEnableTabAudioMuting); |
| 1252 } else { | 1252 return false; |
| 1253 chrome::SetTabAudioMuted(contents, *params->update_properties.muted, | 1253 case TAB_MUTED_RESULT_FAIL_TABCAPTURE: |
| 1254 extension()->id()); | 1254 error_ = ErrorUtils::FormatErrorMessage(keys::kCannotUpdateMuteCaptured, |
| 1255 } | 1255 base::IntToString(tab_id)); |
| 1256 } else { | 1256 return false; |
| 1257 WriteToConsole(content::CONSOLE_MESSAGE_LEVEL_WARNING, | 1257 case TAB_MUTED_RESULT_FAIL_RATE_LIMITED: |
| 1258 base::StringPrintf( | 1258 error_ = ErrorUtils::FormatErrorMessage( |
| 1259 "Failed to update mute state, --%s must be enabled", | 1259 keys::kCannotUpdateMuteRateLimited, base::IntToString(tab_id)); |
| 1260 switches::kEnableTabAudioMuting)); | 1260 return false; |
| 1261 case TAB_MUTED_RESULT_SUCCESS: | |
| 1262 break; | |
| 1261 } | 1263 } |
| 1262 } | 1264 } |
| 1263 | 1265 |
| 1264 if (params->update_properties.opener_tab_id.get()) { | 1266 if (params->update_properties.opener_tab_id.get()) { |
| 1265 int opener_id = *params->update_properties.opener_tab_id; | 1267 int opener_id = *params->update_properties.opener_tab_id; |
| 1266 | 1268 |
| 1267 WebContents* opener_contents = NULL; | 1269 WebContents* opener_contents = NULL; |
| 1268 if (!ExtensionTabUtil::GetTabById(opener_id, | 1270 if (!ExtensionTabUtil::GetTabById(opener_id, |
| 1269 GetProfile(), | 1271 GetProfile(), |
| 1270 include_incognito(), | 1272 include_incognito(), |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2026 ZoomModeToZoomSettings(zoom_mode, &zoom_settings); | 2028 ZoomModeToZoomSettings(zoom_mode, &zoom_settings); |
| 2027 zoom_settings.default_zoom_factor.reset(new double( | 2029 zoom_settings.default_zoom_factor.reset(new double( |
| 2028 content::ZoomLevelToZoomFactor(zoom_controller->GetDefaultZoomLevel()))); | 2030 content::ZoomLevelToZoomFactor(zoom_controller->GetDefaultZoomLevel()))); |
| 2029 | 2031 |
| 2030 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings); | 2032 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings); |
| 2031 SendResponse(true); | 2033 SendResponse(true); |
| 2032 return true; | 2034 return true; |
| 2033 } | 2035 } |
| 2034 | 2036 |
| 2035 } // namespace extensions | 2037 } // namespace extensions |
| OLD | NEW |