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/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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 425 if (extension_ime_util::GetInputMethodIDByEngineID( | 425 if (extension_ime_util::GetInputMethodIDByEngineID( |
| 426 kMappingImeIdToMediumLenNameResourceId[i].engine_id) == | 426 kMappingImeIdToMediumLenNameResourceId[i].engine_id) == |
| 427 input_method.id()) { | 427 input_method.id()) { |
| 428 return delegate_->GetLocalizedString( | 428 return delegate_->GetLocalizedString( |
| 429 kMappingImeIdToMediumLenNameResourceId[i].resource_id); | 429 kMappingImeIdToMediumLenNameResourceId[i].resource_id); |
| 430 } | 430 } |
| 431 } | 431 } |
| 432 return GetInputMethodShortName(input_method); | 432 return GetInputMethodShortName(input_method); |
| 433 } | 433 } |
| 434 | 434 |
| 435 base::string16 InputMethodUtil::GetInputMethodLongName( | 435 base::string16 InputMethodUtil::GetInputMethodLongNameInternal( |
| 436 const InputMethodDescriptor& input_method) const { | 436 const InputMethodDescriptor& input_method, bool strip) const { |
| 437 LOG(ERROR) << "-----" << input_method.id(); | |
|
Nikita (slow)
2014/09/29 19:03:19
nit: debug code
Shu Chen
2014/09/30 01:11:15
Done.
| |
| 437 if (!input_method.name().empty() && !IsKeyboardLayout(input_method.id())) { | 438 if (!input_method.name().empty() && !IsKeyboardLayout(input_method.id())) { |
| 438 // If the descriptor has a name, use it. | 439 // If the descriptor has a name, use it. |
| 439 return base::UTF8ToUTF16(input_method.name()); | 440 return base::UTF8ToUTF16(input_method.name()); |
| 440 } | 441 } |
| 441 | 442 |
| 442 // We don't show language here. Name of keyboard layout or input method | 443 // We don't show language here. Name of keyboard layout or input method |
| 443 // usually imply (or explicitly include) its language. | 444 // usually imply (or explicitly include) its language. |
| 444 | |
| 445 // Special case for German, French and Dutch: these languages have multiple | 445 // Special case for German, French and Dutch: these languages have multiple |
| 446 // keyboard layouts and share the same layout of keyboard (Belgian). We need | 446 // keyboard layouts and share the same layout of keyboard (Belgian). We need |
| 447 // to show explicitly the language for the layout. For Arabic, Amharic, and | 447 // to show explicitly the language for the layout. |
| 448 // Indic languages: they share "Standard Input Method". | |
| 449 const base::string16 standard_input_method_text = | |
| 450 delegate_->GetLocalizedString( | |
| 451 IDS_OPTIONS_SETTINGS_LANGUAGES_M17N_STANDARD_INPUT_METHOD); | |
| 452 DCHECK(!input_method.language_codes().empty()); | 448 DCHECK(!input_method.language_codes().empty()); |
| 453 const std::string language_code = input_method.language_codes().at(0); | 449 const std::string language_code = input_method.language_codes().at(0); |
| 454 | 450 |
| 455 base::string16 text = TranslateString(input_method.id()); | 451 base::string16 text = (strip || input_method.name().empty()) |
| 456 if (text == standard_input_method_text || | 452 ? TranslateString(input_method.id()) |
| 457 language_code == "de" || | 453 : base::UTF8ToUTF16(input_method.name()); |
| 458 language_code == "fr" || | 454 if (language_code == "de" || language_code == "fr" || language_code == "nl") { |
| 459 language_code == "nl") { | |
| 460 const base::string16 language_name = delegate_->GetDisplayLanguageName( | 455 const base::string16 language_name = delegate_->GetDisplayLanguageName( |
| 461 language_code); | 456 language_code); |
| 462 | |
| 463 text = language_name + base::UTF8ToUTF16(" - ") + text; | 457 text = language_name + base::UTF8ToUTF16(" - ") + text; |
| 464 } | 458 } |
| 465 | 459 |
| 466 DCHECK(!text.empty()); | 460 DCHECK(!text.empty()); |
| 467 return text; | 461 return text; |
| 468 } | 462 } |
| 469 | 463 |
| 464 | |
| 465 base::string16 InputMethodUtil::GetInputMethodLongNameStripped( | |
| 466 const InputMethodDescriptor& input_method) const { | |
| 467 return GetInputMethodLongNameInternal(input_method, true); | |
|
Nikita (slow)
2014/09/29 19:03:18
nit: true /* strip */
Shu Chen
2014/09/30 01:11:15
Done.
| |
| 468 } | |
| 469 | |
| 470 base::string16 InputMethodUtil::GetInputMethodLongName( | |
| 471 const InputMethodDescriptor& input_method) const { | |
| 472 return GetInputMethodLongNameInternal(input_method, true); | |
|
Nikita (slow)
2014/09/29 19:03:18
Should the strip parameter be false here?
Shu Chen
2014/09/30 01:11:15
Done.
| |
| 473 } | |
| 474 | |
| 470 const InputMethodDescriptor* InputMethodUtil::GetInputMethodDescriptorFromId( | 475 const InputMethodDescriptor* InputMethodUtil::GetInputMethodDescriptorFromId( |
| 471 const std::string& input_method_id) const { | 476 const std::string& input_method_id) const { |
| 472 InputMethodIdToDescriptorMap::const_iterator iter = | 477 InputMethodIdToDescriptorMap::const_iterator iter = |
| 473 id_to_descriptor_.find(input_method_id); | 478 id_to_descriptor_.find(input_method_id); |
| 474 if (iter == id_to_descriptor_.end()) | 479 if (iter == id_to_descriptor_.end()) |
| 475 return NULL; | 480 return NULL; |
| 476 return &(iter->second); | 481 return &(iter->second); |
| 477 } | 482 } |
| 478 | 483 |
| 479 bool InputMethodUtil::GetInputMethodIdsFromLanguageCode( | 484 bool InputMethodUtil::GetInputMethodIdsFromLanguageCode( |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 752 "US", | 757 "US", |
| 753 layouts, | 758 layouts, |
| 754 languages, | 759 languages, |
| 755 true, // login keyboard. | 760 true, // login keyboard. |
| 756 GURL(), // options page, not available. | 761 GURL(), // options page, not available. |
| 757 GURL()); // input view page, not available. | 762 GURL()); // input view page, not available. |
| 758 } | 763 } |
| 759 | 764 |
| 760 } // namespace input_method | 765 } // namespace input_method |
| 761 } // namespace chromeos | 766 } // namespace chromeos |
| OLD | NEW |