summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authoryusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-09 10:35:55 +0000
committeryusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-09 10:35:55 +0000
commit2c25ddfdc8fd5180c75c66d700d94f8dac71238f (patch)
tree4833e64eb63d1a7502428b445c290d39f0527de3 /chrome
parent8b0cd39c1238c960ee8003755d89b7431eb8ae2a (diff)
downloadchromium_src-2c25ddfdc8fd5180c75c66d700d94f8dac71238f.zip
chromium_src-2c25ddfdc8fd5180c75c66d700d94f8dac71238f.tar.gz
chromium_src-2c25ddfdc8fd5180c75c66d700d94f8dac71238f.tar.bz2
Adding 2 preferences for configuring "NextEngine" and "Trigger" hot-keys.
This change also disables the latter hot-key so that users can't disable IBus. This is preferable since "current input method is xkb:us::eng (for example) and it is enabled" and "current one is xkb:us::eng but it's disabled" are almost indistinguishable. This change depends on http://codereview.chromium.org/1528023 and http://codereview.chromium.org/1610013. BUG=none TEST=boot chrome os, activate English and Chinese, click omnibox, press lang menu, press English to enable "xkb:us::eng", press omnibox, press ctrl+space, verify that the menu shows "Chi" (not "Eng"). Review URL: http://codereview.chromium.org/1553018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44072 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/chromeos/cros/language_library.cc4
-rw-r--r--chrome/browser/chromeos/language_preferences.h4
-rw-r--r--chrome/browser/chromeos/preferences.cc38
-rw-r--r--chrome/browser/chromeos/preferences.h16
-rw-r--r--chrome/common/pref_names.cc7
-rw-r--r--chrome/common/pref_names.h2
6 files changed, 67 insertions, 4 deletions
diff --git a/chrome/browser/chromeos/cros/language_library.cc b/chrome/browser/chromeos/cros/language_library.cc
index 6ccbf9f..3277b08 100644
--- a/chrome/browser/chromeos/cros/language_library.cc
+++ b/chrome/browser/chromeos/cros/language_library.cc
@@ -135,7 +135,7 @@ chromeos::InputMethodDescriptors* LanguageLibraryImpl::GetActiveInputMethods() {
if (EnsureLoadedAndStarted()) {
result = chromeos::GetActiveInputMethods(language_status_connection_);
}
- if (!result) {
+ if (!result || result->empty()) {
result = CreateFallbackInputMethodDescriptors();
}
// TODO(yusukes): Remove this hack.
@@ -149,7 +149,7 @@ LanguageLibraryImpl::GetSupportedInputMethods() {
if (EnsureLoadedAndStarted()) {
result = chromeos::GetSupportedInputMethods(language_status_connection_);
}
- if (!result) {
+ if (!result || result->empty()) {
result = CreateFallbackInputMethodDescriptors();
}
// TODO(yusukes): Remove this hack.
diff --git a/chrome/browser/chromeos/language_preferences.h b/chrome/browser/chromeos/language_preferences.h
index 78c90cd..2568ab2 100644
--- a/chrome/browser/chromeos/language_preferences.h
+++ b/chrome/browser/chromeos/language_preferences.h
@@ -23,6 +23,10 @@ const struct HangulKeyboardNameIDPair {
};
// For ibus-daemon
+// TODO(yusukes): We'll add more "next engine" hot-keys.
+const wchar_t kHotkeyNextEngine[] = L"Control+space";
+const wchar_t kHotkeyTrigger[] = L""; // We don't allow users to disable IBus.
+
// For Simplified Chinese IME (ibus-pinyin)
// For Traditional Chinese IME (ibus-chewing)
// For Japanese IME (ibus-google-japanese-input)
diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc
index d245f29..257d68c 100644
--- a/chrome/browser/chromeos/preferences.cc
+++ b/chrome/browser/chromeos/preferences.cc
@@ -20,8 +20,12 @@ namespace {
// Section and config names for the IBus configuration daemon.
const char kGeneralSectionName[] = "general";
-const char kUseGlobalEngineConfigName[] = "use_global_engine";
+const char kHotKeySectionName[] = "general/hotkey";
const char kHangulSectionName[] = "engine/Hangul";
+
+const char kUseGlobalEngineConfigName[] = "use_global_engine";
+const char kNextEngineConfigName[] = "next_engine";
+const char kTriggerConfigName[] = "trigger";
const char kHangulKeyboardConfigName[] = "HangulKeyboard";
} // namespace
@@ -36,6 +40,9 @@ void Preferences::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterIntegerPref(prefs::kTouchpadSpeedFactor, 5);
prefs->RegisterIntegerPref(prefs::kTouchpadSensitivity, 5);
prefs->RegisterBooleanPref(prefs::kLanguageUseGlobalEngine, true);
+ prefs->RegisterStringPref(prefs::kLanguageHotkeyNextEngine,
+ kHotkeyNextEngine);
+ prefs->RegisterStringPref(prefs::kLanguageHotkeyTrigger, kHotkeyTrigger);
prefs->RegisterStringPref(prefs::kLanguagePreloadEngines,
UTF8ToWide(kFallbackInputMethodId)); // EN layout
prefs->RegisterStringPref(prefs::kLanguageHangulKeyboard,
@@ -50,6 +57,9 @@ void Preferences::Init(PrefService* prefs) {
sensitivity_.Init(prefs::kTouchpadSensitivity, prefs, this);
language_use_global_engine_.Init(
prefs::kLanguageUseGlobalEngine, prefs, this);
+ language_hotkey_next_engine_.Init(
+ prefs::kLanguageHotkeyNextEngine, prefs, this);
+ language_hotkey_trigger_.Init(prefs::kLanguageHotkeyTrigger, prefs, this);
language_preload_engines_.Init(prefs::kLanguagePreloadEngines, prefs, this);
language_hangul_keyboard_.Init(prefs::kLanguageHangulKeyboard, prefs, this);
@@ -86,6 +96,10 @@ void Preferences::NotifyPrefChanged(const std::wstring* pref_name) {
if (!pref_name || *pref_name == prefs::kLanguageUseGlobalEngine)
SetLanguageConfigBoolean(kGeneralSectionName, kUseGlobalEngineConfigName,
language_use_global_engine_.GetValue());
+ if (!pref_name || *pref_name == prefs::kLanguageHotkeyNextEngine)
+ SetHotkeys(kNextEngineConfigName, language_hotkey_next_engine_.GetValue());
+ if (!pref_name || *pref_name == prefs::kLanguageHotkeyTrigger)
+ SetHotkeys(kTriggerConfigName, language_hotkey_trigger_.GetValue());
if (!pref_name || *pref_name == prefs::kLanguagePreloadEngines)
SetPreloadEngines(language_preload_engines_.GetValue());
if (!pref_name || *pref_name == prefs::kLanguageHangulKeyboard)
@@ -117,6 +131,28 @@ void Preferences::SetLanguageConfigString(const char* section,
CrosLibrary::Get()->GetLanguageLibrary()->SetImeConfig(section, name, config);
}
+void Preferences::SetLanguageConfigStringList(
+ const char* section,
+ const char* name,
+ const std::vector<std::wstring>& values) {
+ ImeConfigValue config;
+ config.type = ImeConfigValue::kValueTypeStringList;
+ for (size_t i = 0; i < values.size(); ++i) {
+ config.string_list_value.push_back(WideToUTF8(values[i]));
+ }
+ CrosLibrary::Get()->GetLanguageLibrary()->SetImeConfig(section, name, config);
+}
+
+void Preferences::SetHotkeys(const char* name, const std::wstring& value) {
+ std::vector<std::wstring> hotkeys;
+ if (!value.empty()) {
+ SplitString(value, L',', &hotkeys);
+ }
+ // 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.
diff --git a/chrome/browser/chromeos/preferences.h b/chrome/browser/chromeos/preferences.h
index d324e09..42a0090 100644
--- a/chrome/browser/chromeos/preferences.h
+++ b/chrome/browser/chromeos/preferences.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_CHROMEOS_PREFERENCES_H_
#include <string>
+#include <vector>
#include "chrome/browser/pref_member.h"
#include "chrome/common/notification_observer.h"
@@ -49,12 +50,23 @@ class Preferences : public NotificationObserver {
const char* name,
bool value);
- // Writes stromg |value| to the IME (IBus) configuration daemon. |section|
+ // Writes string |value| to the IME (IBus) configuration daemon. |section|
// and |name| should not be NULL.
void SetLanguageConfigString(const char* section,
const char* name,
const std::wstring& value);
+ // Writes a string list to the IME (IBus) configuration daemon. |section|
+ // and |name| should not be NULL.
+ void SetLanguageConfigStringList(const char* section,
+ 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
@@ -68,6 +80,8 @@ class Preferences : public NotificationObserver {
IntegerPrefMember sensitivity_;
// Language (IME) preferences.
BooleanPrefMember language_use_global_engine_;
+ StringPrefMember language_hotkey_next_engine_;
+ StringPrefMember language_hotkey_trigger_;
StringPrefMember language_preload_engines_;
StringPrefMember language_hangul_keyboard_;
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 2833173..5f8cd2d 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -199,6 +199,13 @@ const wchar_t kTouchpadSensitivity[] = L"settings.touchpad.sensitivity";
const wchar_t kLanguageUseGlobalEngine[] =
L"settings.language.use_global_engine";
+// A string pref (comma-separated list) set to the "next engine" hot-key lists.
+const wchar_t kLanguageHotkeyNextEngine[] =
+ L"settings.language.hotkey_next_engine";
+
+// A string pref (comma-separated list) set to the "trigger" hot-key lists.
+const wchar_t kLanguageHotkeyTrigger[] = L"settings.language.hotkey_trigger";
+
// A string pref (comma-separated list) set to the preloaded (active) IME IDs.
const wchar_t kLanguagePreloadEngines[] = L"settings.language.preload_engines";
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 5436aaa..23cd977 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -73,6 +73,8 @@ extern const wchar_t kVertEdgeScrollEnabled[];
extern const wchar_t kTouchpadSpeedFactor[];
extern const wchar_t kTouchpadSensitivity[];
extern const wchar_t kLanguageUseGlobalEngine[];
+extern const wchar_t kLanguageHotkeyNextEngine[];
+extern const wchar_t kLanguageHotkeyTrigger[];
extern const wchar_t kLanguagePreloadEngines[];
extern const wchar_t kLanguageHangulKeyboard[];
#endif