Index: chrome/browser/chromeos/input_method/input_method_util.cc |
diff --git a/chrome/browser/chromeos/input_method/input_method_util.cc b/chrome/browser/chromeos/input_method/input_method_util.cc |
index 6946a8b59bd787791343836784b99b25b4ca2264..e4dbc09801c53320ca3a7c70a3b0532bb1cb8b1e 100644 |
--- a/chrome/browser/chromeos/input_method/input_method_util.cc |
+++ b/chrome/browser/chromeos/input_method/input_method_util.cc |
@@ -614,25 +614,49 @@ std::string InputMethodUtil::GetLanguageDefaultInputMethodId( |
return std::string(); |
} |
-std::string InputMethodUtil::GetHardwareInputMethodId() const { |
- const std::string input_method_id = delegate_->GetHardwareKeyboardLayout(); |
+const std::vector<std::string>& |
+ InputMethodUtil::GetHardwareInputMethodIds() { |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
+ if (hardware_layouts_.get()) |
Alexander Alekseev
2014/02/12 14:45:35
Why are hardware_layouts_ and hardware_login_layou
Seigo Nonaka
2014/02/12 16:49:51
Yes, you are right! Changing to plain object.
On
|
+ return *(hardware_layouts_.get()); |
- if (input_method_id.empty()) { |
+ hardware_layouts_.reset(new std::vector<std::string>()); |
+ |
+ delegate_->GetHardwareKeyboardLayouts(hardware_layouts_.get()); |
+ |
+ if (hardware_layouts_->empty()) { |
// This is totally fine if it's empty. The hardware keyboard layout is |
// not stored if startup_manifest.json (OEM customization data) is not |
// present (ex. Cr48 doen't have that file). |
- return GetFallbackInputMethodDescriptor().id(); |
+ hardware_layouts_->push_back(GetFallbackInputMethodDescriptor().id()); |
} |
- return input_method_id; |
+ return *(hardware_layouts_.get()); |
+} |
+ |
+void InputMethodUtil::InvalidateHardwareInputMethodIdsCache() { |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
+ hardware_layouts_.reset(); |
+ hardware_login_layouts_.reset(); |
} |
-std::string InputMethodUtil::GetHardwareLoginInputMethodId() const { |
- const std::string input_method_id = GetHardwareInputMethodId(); |
+const std::vector<std::string>& |
+ InputMethodUtil::GetHardwareLoginInputMethodIds() { |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
- if (!IsLoginKeyboard(input_method_id)) |
- return GetFallbackInputMethodDescriptor().id(); |
+ if (hardware_login_layouts_.get()) |
+ return *(hardware_login_layouts_.get()); |
+ |
+ hardware_login_layouts_.reset(new std::vector<std::string>()); |
+ const std::vector<std::string>& candidates = GetHardwareInputMethodIds(); |
+ |
+ for (size_t i = 0; i < candidates.size(); ++i) { |
+ if (IsLoginKeyboard(candidates[i])) |
+ hardware_login_layouts_->push_back(candidates[i]); |
+ } |
- return input_method_id; |
+ if (hardware_login_layouts_->empty()) |
+ hardware_login_layouts_->push_back(GetFallbackInputMethodDescriptor().id()); |
+ return *(hardware_login_layouts_.get()); |
} |
bool InputMethodUtil::IsLoginKeyboard(const std::string& input_method_id) |