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

Unified 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 side-by-side diff with in-line comments
Download patch
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)

Powered by Google App Engine
This is Rietveld 408576698