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/chromeos/input_method/input_method_util.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <map> | 9 #include <map> |
10 #include <utility> | 10 #include <utility> |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 if (extension_ime_util::GetInputMethodIDByEngineID( | 294 if (extension_ime_util::GetInputMethodIDByEngineID( |
295 kMappingImeIdToMediumLenNameResourceId[i].engine_id) == | 295 kMappingImeIdToMediumLenNameResourceId[i].engine_id) == |
296 input_method.id()) { | 296 input_method.id()) { |
297 return delegate_->GetLocalizedString( | 297 return delegate_->GetLocalizedString( |
298 kMappingImeIdToMediumLenNameResourceId[i].resource_id); | 298 kMappingImeIdToMediumLenNameResourceId[i].resource_id); |
299 } | 299 } |
300 } | 300 } |
301 return GetInputMethodShortName(input_method); | 301 return GetInputMethodShortName(input_method); |
302 } | 302 } |
303 | 303 |
304 base::string16 InputMethodUtil::GetInputMethodLongName( | 304 base::string16 InputMethodUtil::GetInputMethodLongNameInternal( |
305 const InputMethodDescriptor& input_method) const { | 305 const InputMethodDescriptor& input_method, bool short_name) const { |
306 if (!input_method.name().empty() && !IsKeyboardLayout(input_method.id())) { | 306 if (!input_method.name().empty() && !IsKeyboardLayout(input_method.id())) { |
307 // If the descriptor has a name, use it. | 307 // If the descriptor has a name, use it. |
308 return base::UTF8ToUTF16(input_method.name()); | 308 return base::UTF8ToUTF16(input_method.name()); |
309 } | 309 } |
310 | 310 |
311 // We don't show language here. Name of keyboard layout or input method | 311 // We don't show language here. Name of keyboard layout or input method |
312 // usually imply (or explicitly include) its language. | 312 // usually imply (or explicitly include) its language. |
313 | |
314 // Special case for German, French and Dutch: these languages have multiple | 313 // Special case for German, French and Dutch: these languages have multiple |
315 // keyboard layouts and share the same layout of keyboard (Belgian). We need | 314 // keyboard layouts and share the same layout of keyboard (Belgian). We need |
316 // to show explicitly the language for the layout. For Arabic, Amharic, and | 315 // to show explicitly the language for the layout. |
317 // Indic languages: they share "Standard Input Method". | |
318 const base::string16 standard_input_method_text = | |
319 delegate_->GetLocalizedString( | |
320 IDS_OPTIONS_SETTINGS_LANGUAGES_M17N_STANDARD_INPUT_METHOD); | |
321 DCHECK(!input_method.language_codes().empty()); | 316 DCHECK(!input_method.language_codes().empty()); |
322 const std::string language_code = input_method.language_codes().at(0); | 317 const std::string language_code = input_method.language_codes().at(0); |
323 | 318 |
324 base::string16 text = TranslateString(input_method.id()); | 319 base::string16 text = (short_name || input_method.name().empty()) |
325 if (text == standard_input_method_text || | 320 ? TranslateString(input_method.id()) |
326 language_code == "de" || | 321 : base::UTF8ToUTF16(input_method.name()); |
327 language_code == "fr" || | 322 if (language_code == "de" || language_code == "fr" || language_code == "nl") { |
328 language_code == "nl") { | |
329 const base::string16 language_name = delegate_->GetDisplayLanguageName( | 323 const base::string16 language_name = delegate_->GetDisplayLanguageName( |
330 language_code); | 324 language_code); |
331 | |
332 text = language_name + base::UTF8ToUTF16(" - ") + text; | 325 text = language_name + base::UTF8ToUTF16(" - ") + text; |
333 } | 326 } |
334 | 327 |
335 DCHECK(!text.empty()); | 328 DCHECK(!text.empty()); |
336 return text; | 329 return text; |
337 } | 330 } |
338 | 331 |
| 332 |
| 333 base::string16 InputMethodUtil::GetInputMethodLongNameStripped( |
| 334 const InputMethodDescriptor& input_method) const { |
| 335 return GetInputMethodLongNameInternal(input_method, true /* short_name */); |
| 336 } |
| 337 |
| 338 base::string16 InputMethodUtil::GetInputMethodLongName( |
| 339 const InputMethodDescriptor& input_method) const { |
| 340 return GetInputMethodLongNameInternal(input_method, false /* short_name */); |
| 341 } |
| 342 |
339 const InputMethodDescriptor* InputMethodUtil::GetInputMethodDescriptorFromId( | 343 const InputMethodDescriptor* InputMethodUtil::GetInputMethodDescriptorFromId( |
340 const std::string& input_method_id) const { | 344 const std::string& input_method_id) const { |
341 InputMethodIdToDescriptorMap::const_iterator iter = | 345 InputMethodIdToDescriptorMap::const_iterator iter = |
342 id_to_descriptor_.find(input_method_id); | 346 id_to_descriptor_.find(input_method_id); |
343 if (iter == id_to_descriptor_.end()) | 347 if (iter == id_to_descriptor_.end()) |
344 return NULL; | 348 return NULL; |
345 return &(iter->second); | 349 return &(iter->second); |
346 } | 350 } |
347 | 351 |
348 bool InputMethodUtil::GetInputMethodIdsFromLanguageCode( | 352 bool InputMethodUtil::GetInputMethodIdsFromLanguageCode( |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 "US", | 625 "US", |
622 layouts, | 626 layouts, |
623 languages, | 627 languages, |
624 true, // login keyboard. | 628 true, // login keyboard. |
625 GURL(), // options page, not available. | 629 GURL(), // options page, not available. |
626 GURL()); // input view page, not available. | 630 GURL()); // input view page, not available. |
627 } | 631 } |
628 | 632 |
629 } // namespace input_method | 633 } // namespace input_method |
630 } // namespace chromeos | 634 } // namespace chromeos |
OLD | NEW |