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

Side by Side Diff: chrome/browser/chromeos/input_method/input_method_util.cc

Issue 606063002: Only strip 'keyboard' from the input method name for OOBE screen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits per comments Created 6 years, 2 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 (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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 if (extension_ime_util::GetInputMethodIDByEngineID( 427 if (extension_ime_util::GetInputMethodIDByEngineID(
428 kMappingImeIdToMediumLenNameResourceId[i].engine_id) == 428 kMappingImeIdToMediumLenNameResourceId[i].engine_id) ==
429 input_method.id()) { 429 input_method.id()) {
430 return delegate_->GetLocalizedString( 430 return delegate_->GetLocalizedString(
431 kMappingImeIdToMediumLenNameResourceId[i].resource_id); 431 kMappingImeIdToMediumLenNameResourceId[i].resource_id);
432 } 432 }
433 } 433 }
434 return GetInputMethodShortName(input_method); 434 return GetInputMethodShortName(input_method);
435 } 435 }
436 436
437 base::string16 InputMethodUtil::GetInputMethodLongName( 437 base::string16 InputMethodUtil::GetInputMethodLongNameInternal(
438 const InputMethodDescriptor& input_method) const { 438 const InputMethodDescriptor& input_method, bool strip) const {
439 if (!input_method.name().empty() && !IsKeyboardLayout(input_method.id())) { 439 if (!input_method.name().empty() && !IsKeyboardLayout(input_method.id())) {
440 // If the descriptor has a name, use it. 440 // If the descriptor has a name, use it.
441 return base::UTF8ToUTF16(input_method.name()); 441 return base::UTF8ToUTF16(input_method.name());
442 } 442 }
443 443
444 // We don't show language here. Name of keyboard layout or input method 444 // We don't show language here. Name of keyboard layout or input method
445 // usually imply (or explicitly include) its language. 445 // usually imply (or explicitly include) its language.
446
447 // Special case for German, French and Dutch: these languages have multiple 446 // Special case for German, French and Dutch: these languages have multiple
448 // keyboard layouts and share the same layout of keyboard (Belgian). We need 447 // keyboard layouts and share the same layout of keyboard (Belgian). We need
449 // to show explicitly the language for the layout. For Arabic, Amharic, and 448 // to show explicitly the language for the layout.
450 // Indic languages: they share "Standard Input Method".
451 const base::string16 standard_input_method_text =
452 delegate_->GetLocalizedString(
453 IDS_OPTIONS_SETTINGS_LANGUAGES_M17N_STANDARD_INPUT_METHOD);
454 DCHECK(!input_method.language_codes().empty()); 449 DCHECK(!input_method.language_codes().empty());
455 const std::string language_code = input_method.language_codes().at(0); 450 const std::string language_code = input_method.language_codes().at(0);
456 451
457 base::string16 text = TranslateString(input_method.id()); 452 base::string16 text = (strip || input_method.name().empty())
458 if (text == standard_input_method_text || 453 ? TranslateString(input_method.id())
459 language_code == "de" || 454 : base::UTF8ToUTF16(input_method.name());
460 language_code == "fr" || 455 if (language_code == "de" || language_code == "fr" || language_code == "nl") {
461 language_code == "nl") {
462 const base::string16 language_name = delegate_->GetDisplayLanguageName( 456 const base::string16 language_name = delegate_->GetDisplayLanguageName(
463 language_code); 457 language_code);
464
465 text = language_name + base::UTF8ToUTF16(" - ") + text; 458 text = language_name + base::UTF8ToUTF16(" - ") + text;
466 } 459 }
467 460
468 DCHECK(!text.empty()); 461 DCHECK(!text.empty());
469 return text; 462 return text;
470 } 463 }
471 464
465
466 base::string16 InputMethodUtil::GetInputMethodLongNameStripped(
467 const InputMethodDescriptor& input_method) const {
468 return GetInputMethodLongNameInternal(input_method, true /* strip */);
469 }
470
471 base::string16 InputMethodUtil::GetInputMethodLongName(
472 const InputMethodDescriptor& input_method) const {
473 return GetInputMethodLongNameInternal(input_method, false /* strip */);
474 }
475
472 const InputMethodDescriptor* InputMethodUtil::GetInputMethodDescriptorFromId( 476 const InputMethodDescriptor* InputMethodUtil::GetInputMethodDescriptorFromId(
473 const std::string& input_method_id) const { 477 const std::string& input_method_id) const {
474 InputMethodIdToDescriptorMap::const_iterator iter = 478 InputMethodIdToDescriptorMap::const_iterator iter =
475 id_to_descriptor_.find(input_method_id); 479 id_to_descriptor_.find(input_method_id);
476 if (iter == id_to_descriptor_.end()) 480 if (iter == id_to_descriptor_.end())
477 return NULL; 481 return NULL;
478 return &(iter->second); 482 return &(iter->second);
479 } 483 }
480 484
481 bool InputMethodUtil::GetInputMethodIdsFromLanguageCode( 485 bool InputMethodUtil::GetInputMethodIdsFromLanguageCode(
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 "US", 758 "US",
755 layouts, 759 layouts,
756 languages, 760 languages,
757 true, // login keyboard. 761 true, // login keyboard.
758 GURL(), // options page, not available. 762 GURL(), // options page, not available.
759 GURL()); // input view page, not available. 763 GURL()); // input view page, not available.
760 } 764 }
761 765
762 } // namespace input_method 766 } // namespace input_method
763 } // namespace chromeos 767 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698