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

Side by Side Diff: ios/chrome/browser/voice/speech_input_locale_config_impl.mm

Issue 2945803002: Use ContainsValue() instead of std::find() in ios/ (Closed)
Patch Set: Fixed compilation error. Created 3 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ios/chrome/browser/voice/speech_input_locale_config_impl.h" 5 #include "ios/chrome/browser/voice/speech_input_locale_config_impl.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 8
9 #include "base/mac/bundle_locations.h" 9 #include "base/mac/bundle_locations.h"
10 #include "base/mac/foundation_util.h" 10 #include "base/mac/foundation_util.h"
11 #include "base/mac/scoped_cftyperef.h" 11 #include "base/mac/scoped_cftyperef.h"
12 #include "base/stl_util.h"
12 #include "base/strings/string_split.h" 13 #include "base/strings/string_split.h"
13 #include "base/strings/sys_string_conversions.h" 14 #include "base/strings/sys_string_conversions.h"
14 #import "ios/chrome/browser/voice/speech_input_locale_match_config.h" 15 #import "ios/chrome/browser/voice/speech_input_locale_match_config.h"
15 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" 16 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
16 #include "ios/public/provider/chrome/browser/voice/voice_search_language.h" 17 #include "ios/public/provider/chrome/browser/voice/voice_search_language.h"
17 #include "ios/public/provider/chrome/browser/voice/voice_search_provider.h" 18 #include "ios/public/provider/chrome/browser/voice/voice_search_provider.h"
18 19
19 #if !defined(__has_feature) || !__has_feature(objc_arc) 20 #if !defined(__has_feature) || !__has_feature(objc_arc)
20 #error "This file requires ARC support." 21 #error "This file requires ARC support."
21 #endif 22 #endif
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 77 }
77 78
78 const std::vector<std::string>& 79 const std::vector<std::string>&
79 SpeechInputLocaleConfigImpl::GetTextToSpeechLanguages() const { 80 SpeechInputLocaleConfigImpl::GetTextToSpeechLanguages() const {
80 return text_to_speech_languages_; 81 return text_to_speech_languages_;
81 } 82 }
82 83
83 bool SpeechInputLocaleConfigImpl::IsTextToSpeechEnabledForCode( 84 bool SpeechInputLocaleConfigImpl::IsTextToSpeechEnabledForCode(
84 const std::string& locale_code) const { 85 const std::string& locale_code) const {
85 std::string language = GetLanguageComponentForLocaleCode(locale_code); 86 std::string language = GetLanguageComponentForLocaleCode(locale_code);
86 auto found_language = std::find(text_to_speech_languages_.begin(), 87 return base::ContainsValue(text_to_speech_languages_, language);
87 text_to_speech_languages_.end(), language);
88 return found_language != text_to_speech_languages_.end();
89 } 88 }
90 89
91 SpeechInputLocale SpeechInputLocaleConfigImpl::GetMatchingLocale( 90 SpeechInputLocale SpeechInputLocaleConfigImpl::GetMatchingLocale(
92 const std::string& locale_code) const { 91 const std::string& locale_code) const {
93 // Return exact match if one is found. 92 // Return exact match if one is found.
94 auto index_iterator = locale_indices_for_codes_.find(locale_code); 93 auto index_iterator = locale_indices_for_codes_.find(locale_code);
95 if (index_iterator != locale_indices_for_codes_.end()) 94 if (index_iterator != locale_indices_for_codes_.end())
96 return available_locales_[index_iterator->second]; 95 return available_locales_[index_iterator->second];
97 // If there is no exact match, search for another locale with the same 96 // If there is no exact match, search for another locale with the same
98 // language component. 97 // language component.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } 189 }
191 } 190 }
192 } 191 }
193 } 192 }
194 193
195 void SpeechInputLocaleConfigImpl::InitializeTextToSpeechLangauges() { 194 void SpeechInputLocaleConfigImpl::InitializeTextToSpeechLangauges() {
196 text_to_speech_languages_ = {"de", "en", "es", "fr", "it", "ja", "ko"}; 195 text_to_speech_languages_ = {"de", "en", "es", "fr", "it", "ja", "ko"};
197 } 196 }
198 197
199 } // namespace voice 198 } // namespace voice
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/bookmarks/bookmark_collection_view.mm ('k') | ios/web/webui/url_data_manager_ios.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698