 Chromium Code Reviews
 Chromium Code Reviews Issue 133273032:
  Guest Mode: input method should default to the underlying latin keyboard layout.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 133273032:
  Guest Mode: input method should default to the underlying latin keyboard layout.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| 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> | 
| 11 | 11 | 
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" | 
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" | 
| 14 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" | 
| 15 #include "base/strings/string_split.h" | 15 #include "base/strings/string_split.h" | 
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" | 
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" | 
| 18 #include "chromeos/ime/component_extension_ime_manager.h" | 18 #include "chromeos/ime/component_extension_ime_manager.h" | 
| 19 #include "chromeos/ime/extension_ime_util.h" | 19 #include "chromeos/ime/extension_ime_util.h" | 
| 20 #include "chromeos/ime/input_method_delegate.h" | 20 #include "chromeos/ime/input_method_delegate.h" | 
| 21 #include "chromeos/ime/input_method_manager.h" | |
| 21 // TODO(nona): move this header from this file. | 22 // TODO(nona): move this header from this file. | 
| 22 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" | 
| 23 | 24 | 
| 24 namespace { | 25 namespace { | 
| 25 | 26 | 
| 26 // A mapping from an input method id to a string for the language indicator. The | 27 // A mapping from an input method id to a string for the language indicator. The | 
| 27 // mapping is necessary since some input methods belong to the same language. | 28 // mapping is necessary since some input methods belong to the same language. | 
| 28 // For example, both "xkb:us::eng" and "xkb:us:dvorak:eng" are for US English. | 29 // For example, both "xkb:us::eng" and "xkb:us:dvorak:eng" are for US English. | 
| 29 const struct { | 30 const struct { | 
| 30 const char* input_method_id; | 31 const char* input_method_id; | 
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 596 DCHECK(!input_method->language_codes().empty()); | 597 DCHECK(!input_method->language_codes().empty()); | 
| 597 const std::string language_code = input_method->language_codes().at(0); | 598 const std::string language_code = input_method->language_codes().at(0); | 
| 598 // Add it if it's not already present. | 599 // Add it if it's not already present. | 
| 599 if (std::count(out_language_codes->begin(), out_language_codes->end(), | 600 if (std::count(out_language_codes->begin(), out_language_codes->end(), | 
| 600 language_code) == 0) { | 601 language_code) == 0) { | 
| 601 out_language_codes->push_back(language_code); | 602 out_language_codes->push_back(language_code); | 
| 602 } | 603 } | 
| 603 } | 604 } | 
| 604 } | 605 } | 
| 605 | 606 | 
| 607 std::string InputMethodUtil::GetLanguageDefaultInputMethodId( | |
| 608 const std::string& language_code) { | |
| 609 std::vector<std::string> candidates; | |
| 610 GetInputMethodIdsFromLanguageCode( | |
| 611 language_code, input_method::kKeyboardLayoutsOnly, &candidates); | |
| 612 if (candidates.size()) | |
| 613 return candidates.front(); | |
| 614 | |
| 615 return std::string(); | |
| 616 } | |
| 617 | |
| 606 std::string InputMethodUtil::GetHardwareInputMethodId() const { | 618 std::string InputMethodUtil::GetHardwareInputMethodId() const { | 
| 607 const std::string input_method_id = delegate_->GetHardwareKeyboardLayout(); | 619 const std::string input_method_id = delegate_->GetHardwareKeyboardLayout(); | 
| 608 | 620 | 
| 609 if (input_method_id.empty()) { | 621 if (input_method_id.empty()) { | 
| 610 // This is totally fine if it's empty. The hardware keyboard layout is | 622 // This is totally fine if it's empty. The hardware keyboard layout is | 
| 611 // not stored if startup_manifest.json (OEM customization data) is not | 623 // not stored if startup_manifest.json (OEM customization data) is not | 
| 612 // present (ex. Cr48 doen't have that file). | 624 // present (ex. Cr48 doen't have that file). | 
| 613 return GetFallbackInputMethodDescriptor().id(); | 625 return GetFallbackInputMethodDescriptor().id(); | 
| 614 } | 626 } | 
| 615 return input_method_id; | 627 return input_method_id; | 
| 616 } | 628 } | 
| 617 | 629 | 
| 630 std::string InputMethodUtil::GetHardwareLoginInputMethodId() const { | |
| 631 const std::string input_method_id = GetHardwareInputMethodId(); | |
| 632 | |
| 633 if (!InputMethodManager::Get()->IsLoginKeyboard(input_method_id)) { | |
| 
Hiro Komatsu
2014/01/21 05:46:01
Please check the actual implementation of IsLoging
 
Alexander Alekseev
2014/01/21 14:05:27
Done.
 | |
| 634 return GetFallbackInputMethodDescriptor().id(); | |
| 635 } | |
| 636 | |
| 637 return input_method_id; | |
| 638 } | |
| 639 | |
| 618 void InputMethodUtil::SetComponentExtensions( | 640 void InputMethodUtil::SetComponentExtensions( | 
| 619 const InputMethodDescriptors& imes) { | 641 const InputMethodDescriptors& imes) { | 
| 620 component_extension_ime_id_to_descriptor_.clear(); | 642 component_extension_ime_id_to_descriptor_.clear(); | 
| 621 for (size_t i = 0; i < imes.size(); ++i) { | 643 for (size_t i = 0; i < imes.size(); ++i) { | 
| 622 const InputMethodDescriptor& input_method = imes.at(i); | 644 const InputMethodDescriptor& input_method = imes.at(i); | 
| 623 DCHECK(!input_method.language_codes().empty()); | 645 DCHECK(!input_method.language_codes().empty()); | 
| 624 const std::string language_code = input_method.language_codes().at(0); | 646 const std::string language_code = input_method.language_codes().at(0); | 
| 625 id_to_language_code_.insert( | 647 id_to_language_code_.insert( | 
| 626 std::make_pair(input_method.id(), language_code)); | 648 std::make_pair(input_method.id(), language_code)); | 
| 627 id_to_descriptor_.insert( | 649 id_to_descriptor_.insert( | 
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 672 if (IsKeyboardLayout(input_method.id())) { | 694 if (IsKeyboardLayout(input_method.id())) { | 
| 673 xkb_id_to_descriptor_.insert( | 695 xkb_id_to_descriptor_.insert( | 
| 674 std::make_pair(input_method.GetPreferredKeyboardLayout(), | 696 std::make_pair(input_method.GetPreferredKeyboardLayout(), | 
| 675 input_method)); | 697 input_method)); | 
| 676 } | 698 } | 
| 677 } | 699 } | 
| 678 } | 700 } | 
| 679 | 701 | 
| 680 } // namespace input_method | 702 } // namespace input_method | 
| 681 } // namespace chromeos | 703 } // namespace chromeos | 
| OLD | NEW |