OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #import "ios/chrome/browser/ui/settings/voicesearch_collection_view_controller.h
" | 5 #import "ios/chrome/browser/ui/settings/voicesearch_collection_view_controller.h
" |
6 | 6 |
7 #import "base/ios/weak_nsobject.h" | 7 #import "base/ios/weak_nsobject.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
10 #import "base/mac/scoped_nsobject.h" | 10 #import "base/mac/scoped_nsobject.h" |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 BOOL enabled = [self currentLanguageSupportsTTS]; | 230 BOOL enabled = [self currentLanguageSupportsTTS]; |
231 BOOL on = enabled && _ttsEnabled.GetValue(); | 231 BOOL on = enabled && _ttsEnabled.GetValue(); |
232 | 232 |
233 UISwitch* switchView = switchCell.switchView; | 233 UISwitch* switchView = switchCell.switchView; |
234 switchView.enabled = enabled; | 234 switchView.enabled = enabled; |
235 switchCell.textLabel.textColor = | 235 switchCell.textLabel.textColor = |
236 [CollectionViewSwitchCell defaultTextColorForState:switchView.state]; | 236 [CollectionViewSwitchCell defaultTextColorForState:switchView.state]; |
237 if (on != switchView.isOn) { | 237 if (on != switchView.isOn) { |
238 [switchView setOn:on animated:YES]; | 238 [switchView setOn:on animated:YES]; |
239 } | 239 } |
| 240 // Also update the switch item. |
| 241 CollectionViewSwitchItem* switchItem = |
| 242 base::mac::ObjCCastStrict<CollectionViewSwitchItem>( |
| 243 [self.collectionViewModel itemAtIndexPath:switchPath]); |
| 244 switchItem.enabled = enabled; |
| 245 switchItem.on = on; |
240 | 246 |
241 [self reconfigureCellsForItems:modifiedItems]; | 247 [self reconfigureCellsForItems:modifiedItems]; |
242 } | 248 } |
243 | 249 |
244 - (BOOL)currentLanguageSupportsTTS { | 250 - (BOOL)currentLanguageSupportsTTS { |
245 voice::SpeechInputLocaleConfig* localeConfig = | 251 voice::SpeechInputLocaleConfig* localeConfig = |
246 voice::SpeechInputLocaleConfig::GetInstance(); | 252 voice::SpeechInputLocaleConfig::GetInstance(); |
247 std::string localeCode = _selectedLanguage.GetValue().empty() | 253 std::string localeCode = _selectedLanguage.GetValue().empty() |
248 ? localeConfig->GetDefaultLocale().code | 254 ? localeConfig->GetDefaultLocale().code |
249 : _selectedLanguage.GetValue(); | 255 : _selectedLanguage.GetValue(); |
250 return localeConfig->IsTextToSpeechEnabledForCode(localeCode); | 256 return localeConfig->IsTextToSpeechEnabledForCode(localeCode); |
251 } | 257 } |
252 | 258 |
253 @end | 259 @end |
OLD | NEW |