summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/chromeos/cros/cros_in_process_browser_test.cc10
-rw-r--r--chrome/browser/chromeos/cros/language_library.h1
-rw-r--r--chrome/browser/chromeos/preferences.cc55
-rw-r--r--chrome/browser/chromeos/preferences.h15
4 files changed, 27 insertions, 54 deletions
diff --git a/chrome/browser/chromeos/cros/cros_in_process_browser_test.cc b/chrome/browser/chromeos/cros/cros_in_process_browser_test.cc
index 3baaf5e5..6d5c99b 100644
--- a/chrome/browser/chromeos/cros/cros_in_process_browser_test.cc
+++ b/chrome/browser/chromeos/cros/cros_in_process_browser_test.cc
@@ -98,21 +98,15 @@ void CrosInProcessBrowserTest::SetLanguageLibraryStatusAreaExpectations() {
.Times(1)
.RetiresOnSaturation();
EXPECT_CALL(*mock_language_library_, GetActiveInputMethods())
- .Times(2)
- // Don't use WillRepeatedly since the fucntion should be evaluated twice.
- .WillOnce(Return(CreateFallbackInputMethodDescriptors()))
- .WillOnce(Return(CreateFallbackInputMethodDescriptors()))
- .RetiresOnSaturation();
- EXPECT_CALL(*mock_language_library_, SetInputMethodActivated(_, _))
.Times(1)
- .WillOnce((Return(true)))
+ .WillOnce(Return(CreateFallbackInputMethodDescriptors()))
.RetiresOnSaturation();
EXPECT_CALL(*mock_language_library_, current_ime_properties())
.Times(1)
.WillOnce((ReturnRef(ime_properties_)))
.RetiresOnSaturation();
EXPECT_CALL(*mock_language_library_, SetImeConfig(_, _, _))
- .Times(4)
+ .Times(5)
.WillRepeatedly((Return(true)))
.RetiresOnSaturation();
EXPECT_CALL(*mock_language_library_, RemoveObserver(_))
diff --git a/chrome/browser/chromeos/cros/language_library.h b/chrome/browser/chromeos/cros/language_library.h
index 853283a..efc49fd 100644
--- a/chrome/browser/chromeos/cros/language_library.h
+++ b/chrome/browser/chromeos/cros/language_library.h
@@ -55,6 +55,7 @@ class LanguageLibrary {
// Sets whether the input method specified by |input_method_id| is
// activated. If |activated| is true, activates the input method. If
// |activate| is false, deactivates the input method.
+ // TODO(yusukes): Probably we can remove this function.
virtual bool SetInputMethodActivated(const std::string& input_method_id,
bool activated) = 0;
diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc
index 257d68c..cd12b0e 100644
--- a/chrome/browser/chromeos/preferences.cc
+++ b/chrome/browser/chromeos/preferences.cc
@@ -24,6 +24,7 @@ const char kHotKeySectionName[] = "general/hotkey";
const char kHangulSectionName[] = "engine/Hangul";
const char kUseGlobalEngineConfigName[] = "use_global_engine";
+const char kPreloadEnginesConfigName[] = "preload_engines";
const char kNextEngineConfigName[] = "next_engine";
const char kTriggerConfigName[] = "trigger";
const char kHangulKeyboardConfigName[] = "HangulKeyboard";
@@ -97,11 +98,17 @@ void Preferences::NotifyPrefChanged(const std::wstring* pref_name) {
SetLanguageConfigBoolean(kGeneralSectionName, kUseGlobalEngineConfigName,
language_use_global_engine_.GetValue());
if (!pref_name || *pref_name == prefs::kLanguageHotkeyNextEngine)
- SetHotkeys(kNextEngineConfigName, language_hotkey_next_engine_.GetValue());
+ SetLanguageConfigStringListAsCSV(kHotKeySectionName,
+ kNextEngineConfigName,
+ language_hotkey_next_engine_.GetValue());
if (!pref_name || *pref_name == prefs::kLanguageHotkeyTrigger)
- SetHotkeys(kTriggerConfigName, language_hotkey_trigger_.GetValue());
+ SetLanguageConfigStringListAsCSV(kHotKeySectionName,
+ kTriggerConfigName,
+ language_hotkey_trigger_.GetValue());
if (!pref_name || *pref_name == prefs::kLanguagePreloadEngines)
- SetPreloadEngines(language_preload_engines_.GetValue());
+ SetLanguageConfigStringListAsCSV(kGeneralSectionName,
+ kPreloadEnginesConfigName,
+ language_preload_engines_.GetValue());
if (!pref_name || *pref_name == prefs::kLanguageHangulKeyboard)
SetLanguageConfigString(kHangulSectionName, kHangulKeyboardConfigName,
language_hangul_keyboard_.GetValue());
@@ -143,42 +150,18 @@ void Preferences::SetLanguageConfigStringList(
CrosLibrary::Get()->GetLanguageLibrary()->SetImeConfig(section, name, config);
}
-void Preferences::SetHotkeys(const char* name, const std::wstring& value) {
- std::vector<std::wstring> hotkeys;
+void Preferences::SetLanguageConfigStringListAsCSV(const char* section,
+ const char* name,
+ const std::wstring& value) {
+ LOG(INFO) << "Setting " << name << " to '" << value << "'";
+
+ std::vector<std::wstring> split_values;
if (!value.empty()) {
- SplitString(value, L',', &hotkeys);
+ SplitString(value, L',', &split_values);
}
// We should call the cros API even when |value| is empty, to disable default
- // hot-keys.
- SetLanguageConfigStringList(kHotKeySectionName, name, hotkeys);
-}
-
-void Preferences::SetPreloadEngines(const std::wstring& value) {
- // TODO(yusukes): might be better to change the cros API signature so it
- // could accept the comma separated |value| as-is.
-
- LanguageLibrary* library = CrosLibrary::Get()->GetLanguageLibrary();
- std::vector<std::wstring> input_method_ids;
- SplitString(value, L',', &input_method_ids);
- LOG(INFO) << "Setting preload_engines to '" << value << "'";
-
- // Activate languages in |value|.
- for (size_t i = 0; i < input_method_ids.size(); ++i) {
- library->SetInputMethodActivated(WideToUTF8(input_method_ids[i]), true);
- }
-
- // Deactivate languages that are currently active, but are not in |value|.
- const std::set<std::wstring> input_method_id_set(input_method_ids.begin(),
- input_method_ids.end());
- scoped_ptr<InputMethodDescriptors> active_input_methods(
- library->GetActiveInputMethods());
- for (size_t i = 0; i < active_input_methods->size(); ++i) {
- const InputMethodDescriptor& active_input_method
- = active_input_methods->at(i);
- if (input_method_id_set.count(UTF8ToWide(active_input_method.id)) == 0) {
- library->SetInputMethodActivated(active_input_method.id, false);
- }
- }
+ // config.
+ SetLanguageConfigStringList(section, name, split_values);
}
} // namespace chromeos
diff --git a/chrome/browser/chromeos/preferences.h b/chrome/browser/chromeos/preferences.h
index 42a0090..04cf176 100644
--- a/chrome/browser/chromeos/preferences.h
+++ b/chrome/browser/chromeos/preferences.h
@@ -62,16 +62,11 @@ class Preferences : public NotificationObserver {
const char* name,
const std::vector<std::wstring>& values);
- // Set input method hot-keys specified by |name| to |value|.
- // Examples of |name|: "trigger", "next_engine"
- // Examples of |value|: "" (no hot-keys), "Control+space,Hiragana"
- void SetHotkeys(const char* name, const std::wstring& value);
-
- // Activates IMEs that are on |value|, which is a comma separated list of IME
- // IDs (e.g. "xkb:en,pinyin,hangul,m17n:ar:kbd"), and deactivates all other
- // IMEs that are currently active. |value| could be empty. In that case, this
- // function deactivates all active IMEs.
- void SetPreloadEngines(const std::wstring& value);
+ // A variant of SetLanguageConfigStringList. You can pass comma-separated
+ // values. Examples of |value|: "", "Control+space,Hiragana"
+ void SetLanguageConfigStringListAsCSV(const char* section,
+ const char* name,
+ const std::wstring& value);
StringPrefMember timezone_;
BooleanPrefMember tap_to_click_enabled_;