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

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

Issue 2477423002: [ios] Removes calls to the deprecated GetAvailableVoiceSearchLanguages(). (Closed)
Patch Set: Fix compile. Created 4 years, 1 month 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/strings/string_split.h" 12 #include "base/strings/string_split.h"
13 #include "base/strings/sys_string_conversions.h" 13 #include "base/strings/sys_string_conversions.h"
14 #import "ios/chrome/browser/voice/speech_input_locale_match_config.h" 14 #import "ios/chrome/browser/voice/speech_input_locale_match_config.h"
15 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" 15 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
16 #include "ios/public/provider/chrome/browser/voice/voice_search_language.h" 16 #include "ios/public/provider/chrome/browser/voice/voice_search_language.h"
17 #include "ios/public/provider/chrome/browser/voice/voice_search_provider.h"
17 18
18 namespace { 19 namespace {
19 20
20 // Returns the language portion of |locale_code|. 21 // Returns the language portion of |locale_code|.
21 std::string GetLanguageComponentForLocaleCode(const std::string& locale_code) { 22 std::string GetLanguageComponentForLocaleCode(const std::string& locale_code) {
22 std::vector<std::string> tokens = base::SplitString( 23 std::vector<std::string> tokens = base::SplitString(
23 locale_code, "-", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); 24 locale_code, "-", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
24 if (tokens.empty()) 25 if (tokens.empty())
25 return std::string(); 26 return std::string();
26 return tokens[0]; 27 return tokens[0];
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // Prioritize the country portion of |current_locale|. 138 // Prioritize the country portion of |current_locale|.
138 NSString* country = [current_locale objectForKey:NSLocaleCountryCode]; 139 NSString* country = [current_locale objectForKey:NSLocaleCountryCode];
139 if (!country.length) 140 if (!country.length)
140 country = [lang_pref_locale objectForKey:NSLocaleCountryCode]; 141 country = [lang_pref_locale objectForKey:NSLocaleCountryCode];
141 DCHECK(country.length); 142 DCHECK(country.length);
142 return GetCanonicalLocaleForLocale( 143 return GetCanonicalLocaleForLocale(
143 [NSString stringWithFormat:@"%@-%@", language, country]); 144 [NSString stringWithFormat:@"%@-%@", language, country]);
144 } 145 }
145 146
146 void SpeechInputLocaleConfigImpl::InitializeAvailableLocales() { 147 void SpeechInputLocaleConfigImpl::InitializeAvailableLocales() {
147 NSArray* languages = 148 NSArray* languages = ios::GetChromeBrowserProvider()
148 ios::GetChromeBrowserProvider()->GetAvailableVoiceSearchLanguages(); 149 ->GetVoiceSearchProvider()
150 ->GetAvailableLanguages();
149 for (VoiceSearchLanguage* language in languages) { 151 for (VoiceSearchLanguage* language in languages) {
150 // Store the InputLocale in |available_locales_|. 152 // Store the InputLocale in |available_locales_|.
151 std::string locale_code = GetCanonicalLocaleForLocale(language.identifier); 153 std::string locale_code = GetCanonicalLocaleForLocale(language.identifier);
152 DCHECK(locale_code.length()); 154 DCHECK(locale_code.length());
153 voice::SpeechInputLocale locale; 155 voice::SpeechInputLocale locale;
154 locale.code = locale_code; 156 locale.code = locale_code;
155 locale.display_name = base::SysNSStringToUTF16(language.displayName); 157 locale.display_name = base::SysNSStringToUTF16(language.displayName);
156 available_locales_.push_back(locale); 158 available_locales_.push_back(locale);
157 // Store the index of the InputLocale. 159 // Store the index of the InputLocale.
158 size_t locale_index = available_locales_.size() - 1; 160 size_t locale_index = available_locales_.size() - 1;
(...skipping 25 matching lines...) Expand all
184 } 186 }
185 } 187 }
186 } 188 }
187 } 189 }
188 190
189 void SpeechInputLocaleConfigImpl::InitializeTextToSpeechLangauges() { 191 void SpeechInputLocaleConfigImpl::InitializeTextToSpeechLangauges() {
190 text_to_speech_languages_ = {"de", "en", "es", "fr", "it", "ja", "ko"}; 192 text_to_speech_languages_ = {"de", "en", "es", "fr", "it", "ja", "ko"};
191 } 193 }
192 194
193 } // namespace voice 195 } // namespace voice
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698