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

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

Issue 139803010: Support comma separated hardware keyboard layout. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing comments Created 6 years, 10 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 | Annotate | Revision Log
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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 const std::string& language_code) { 607 const std::string& language_code) {
608 std::vector<std::string> candidates; 608 std::vector<std::string> candidates;
609 GetInputMethodIdsFromLanguageCode( 609 GetInputMethodIdsFromLanguageCode(
610 language_code, input_method::kKeyboardLayoutsOnly, &candidates); 610 language_code, input_method::kKeyboardLayoutsOnly, &candidates);
611 if (candidates.size()) 611 if (candidates.size())
612 return candidates.front(); 612 return candidates.front();
613 613
614 return std::string(); 614 return std::string();
615 } 615 }
616 616
617 std::string InputMethodUtil::GetHardwareInputMethodId() const { 617 void InputMethodUtil::UpdateHardwareLayoutCache() {
618 const std::string input_method_id = delegate_->GetHardwareKeyboardLayout(); 618 DCHECK(thread_checker_.CalledOnValidThread());
619 hardware_layouts_.clear();
620 hardware_login_layouts_.clear();
621 Tokenize(delegate_->GetHardwareKeyboardLayouts(), ",", &hardware_layouts_);
619 622
620 if (input_method_id.empty()) { 623 for (size_t i = 0; i < hardware_layouts_.size(); ++i) {
624 if (IsLoginKeyboard(hardware_layouts_[i]))
625 hardware_login_layouts_.push_back(hardware_layouts_[i]);
626 }
627 if (hardware_layouts_.empty()) {
621 // This is totally fine if it's empty. The hardware keyboard layout is 628 // This is totally fine if it's empty. The hardware keyboard layout is
622 // not stored if startup_manifest.json (OEM customization data) is not 629 // not stored if startup_manifest.json (OEM customization data) is not
623 // present (ex. Cr48 doen't have that file). 630 // present (ex. Cr48 doen't have that file).
624 return GetFallbackInputMethodDescriptor().id(); 631 hardware_layouts_.push_back(GetFallbackInputMethodDescriptor().id());
625 } 632 }
626 return input_method_id; 633
634 if (hardware_login_layouts_.empty())
635 hardware_login_layouts_.push_back(GetFallbackInputMethodDescriptor().id());
627 } 636 }
628 637
629 std::string InputMethodUtil::GetHardwareLoginInputMethodId() const { 638 const std::vector<std::string>&
630 const std::string input_method_id = GetHardwareInputMethodId(); 639 InputMethodUtil::GetHardwareInputMethodIds() {
640 DCHECK(thread_checker_.CalledOnValidThread());
641 return hardware_layouts_;
642 }
631 643
632 if (!IsLoginKeyboard(input_method_id)) 644 const std::vector<std::string>&
633 return GetFallbackInputMethodDescriptor().id(); 645 InputMethodUtil::GetHardwareLoginInputMethodIds() {
634 646 DCHECK(thread_checker_.CalledOnValidThread());
635 return input_method_id; 647 return hardware_login_layouts_;
636 } 648 }
637 649
638 bool InputMethodUtil::IsLoginKeyboard(const std::string& input_method_id) 650 bool InputMethodUtil::IsLoginKeyboard(const std::string& input_method_id)
639 const { 651 const {
640 const InputMethodDescriptor* ime = 652 const InputMethodDescriptor* ime =
641 GetInputMethodDescriptorFromId(input_method_id); 653 GetInputMethodDescriptorFromId(input_method_id);
642 return ime ? ime->is_login_keyboard() : false; 654 return ime ? ime->is_login_keyboard() : false;
643 } 655 }
644 656
645 void InputMethodUtil::SetComponentExtensions( 657 void InputMethodUtil::SetComponentExtensions(
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 if (IsKeyboardLayout(input_method.id())) { 711 if (IsKeyboardLayout(input_method.id())) {
700 xkb_id_to_descriptor_.insert( 712 xkb_id_to_descriptor_.insert(
701 std::make_pair(input_method.GetPreferredKeyboardLayout(), 713 std::make_pair(input_method.GetPreferredKeyboardLayout(),
702 input_method)); 714 input_method));
703 } 715 }
704 } 716 }
705 } 717 }
706 718
707 } // namespace input_method 719 } // namespace input_method
708 } // namespace chromeos 720 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698