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

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: Fix compile failure 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::GetHardwareInputMethodIds(
618 const std::string input_method_id = delegate_->GetHardwareKeyboardLayout(); 618 std::vector<std::string>* out) const {
619 DCHECK(out);
620 out->clear();
621 delegate_->GetHardwareKeyboardLayout(out);
619 622
620 if (input_method_id.empty()) { 623 if (out->empty()) {
621 // This is totally fine if it's empty. The hardware keyboard layout is 624 // 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 625 // not stored if startup_manifest.json (OEM customization data) is not
623 // present (ex. Cr48 doen't have that file). 626 // present (ex. Cr48 doen't have that file).
624 return GetFallbackInputMethodDescriptor().id(); 627 out->push_back(GetFallbackInputMethodDescriptor().id());
625 } 628 }
626 return input_method_id;
627 } 629 }
628 630
629 std::string InputMethodUtil::GetHardwareLoginInputMethodId() const { 631 void InputMethodUtil::GetHardwareLoginInputMethodId(
630 const std::string input_method_id = GetHardwareInputMethodId(); 632 std::vector<std::string>* out) const {
631 633
632 if (!IsLoginKeyboard(input_method_id)) 634 std::vector<std::string> candidates;
633 return GetFallbackInputMethodDescriptor().id(); 635 GetHardwareInputMethodIds(&candidates);
636 out->clear();
634 637
635 return input_method_id; 638 for (size_t i = 0; i < candidates.size(); ++i) {
639 if (IsLoginKeyboard(candidates[i]))
640 out->push_back(candidates[i]);
641 }
642
643 if (out->empty())
644 out->push_back(GetFallbackInputMethodDescriptor().id());
636 } 645 }
637 646
638 bool InputMethodUtil::IsLoginKeyboard(const std::string& input_method_id) 647 bool InputMethodUtil::IsLoginKeyboard(const std::string& input_method_id)
639 const { 648 const {
640 const InputMethodDescriptor* ime = 649 const InputMethodDescriptor* ime =
641 GetInputMethodDescriptorFromId(input_method_id); 650 GetInputMethodDescriptorFromId(input_method_id);
642 return ime ? ime->is_login_keyboard() : false; 651 return ime ? ime->is_login_keyboard() : false;
643 } 652 }
644 653
645 void InputMethodUtil::SetComponentExtensions( 654 void InputMethodUtil::SetComponentExtensions(
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 if (IsKeyboardLayout(input_method.id())) { 708 if (IsKeyboardLayout(input_method.id())) {
700 xkb_id_to_descriptor_.insert( 709 xkb_id_to_descriptor_.insert(
701 std::make_pair(input_method.GetPreferredKeyboardLayout(), 710 std::make_pair(input_method.GetPreferredKeyboardLayout(),
702 input_method)); 711 input_method));
703 } 712 }
704 } 713 }
705 } 714 }
706 715
707 } // namespace input_method 716 } // namespace input_method
708 } // namespace chromeos 717 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698