summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-22 04:29:28 +0000
committeryusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-22 04:29:28 +0000
commit9040ad23a3950685b08523d12305d9afcbbc7551 (patch)
tree24656c6adfc1a44aebfec374d7e8fb7ddbce61f0
parent849b5e6fc3efafb25a659d7a9c7484d58e4d2952 (diff)
downloadchromium_src-9040ad23a3950685b08523d12305d9afcbbc7551.zip
chromium_src-9040ad23a3950685b08523d12305d9afcbbc7551.tar.gz
chromium_src-9040ad23a3950685b08523d12305d9afcbbc7551.tar.bz2
- Adding Chrome preferences for ibus-pinyin.
- Moving all input method related constants from preferences.cc to language_preferences.h. This change is necessary to implement a configuration dialog for Pinyin input method. BUG=crosbug.com/488 TEST=ran browser_tests Review URL: http://codereview.chromium.org/1631030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45292 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/cros/cros_in_process_browser_test.cc2
-rw-r--r--chrome/browser/chromeos/language_preferences.h69
-rw-r--r--chrome/browser/chromeos/preferences.cc55
-rw-r--r--chrome/browser/chromeos/preferences.h27
-rw-r--r--chrome/browser/sync/glue/synchronized_preferences.h14
-rw-r--r--chrome/common/pref_names.cc41
-rw-r--r--chrome/common/pref_names.h14
7 files changed, 185 insertions, 37 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 467e674..36fc43d 100644
--- a/chrome/browser/chromeos/cros/cros_in_process_browser_test.cc
+++ b/chrome/browser/chromeos/cros/cros_in_process_browser_test.cc
@@ -114,7 +114,7 @@ void CrosInProcessBrowserTest::SetLanguageLibraryStatusAreaExpectations() {
.WillOnce((ReturnRef(ime_properties_)))
.RetiresOnSaturation();
EXPECT_CALL(*mock_language_library_, SetImeConfig(_, _, _))
- .Times(5)
+ .Times(AnyNumber())
.WillRepeatedly((Return(true)))
.RetiresOnSaturation();
EXPECT_CALL(*mock_language_library_, RemoveObserver(_))
diff --git a/chrome/browser/chromeos/language_preferences.h b/chrome/browser/chromeos/language_preferences.h
index 400246f..add4a2a 100644
--- a/chrome/browser/chromeos/language_preferences.h
+++ b/chrome/browser/chromeos/language_preferences.h
@@ -5,9 +5,28 @@
#ifndef CHROME_BROWSER_CHROMEOS_LANGUAGE_PREFERENCES_H_
#define CHROME_BROWSER_CHROMEOS_LANGUAGE_PREFERENCES_H_
+#include "chrome/common/pref_names.h"
+
+// Section and config names for the IBus configuration daemon.
namespace chromeos {
-// For Korean IME (ibus-hangul)
+// For ibus-daemon
+const char kGeneralSectionName[] = "general";
+const char kHotKeySectionName[] = "general/hotkey";
+const char kUseGlobalEngineConfigName[] = "use_global_engine";
+const char kPreloadEnginesConfigName[] = "preload_engines";
+const char kNextEngineConfigName[] = "next_engine";
+const char kTriggerConfigName[] = "trigger";
+
+// TODO(yusukes): We'll add more "next engine" hot-keys like "Zenkaku_Hankaku"
+// (Japanese keyboard specific).
+const wchar_t kHotkeyNextEngine[] = L"Shift+Alt_L,Alt+Shift_L,Alt+grave";
+const wchar_t kHotkeyTrigger[] = L""; // We don't allow users to disable IBus.
+
+// For Korean input method (ibus-hangul)
+const char kHangulSectionName[] = "engine/Hangul";
+const char kHangulKeyboardConfigName[] = "HangulKeyboard";
+
const struct HangulKeyboardNameIDPair {
const wchar_t* keyboard_name;
const wchar_t* keyboard_id;
@@ -22,15 +41,47 @@ const struct HangulKeyboardNameIDPair {
// jshin first.
};
-// For ibus-daemon
-// TODO(yusukes): We'll add more "next engine" hot-keys like "Zenkaku_Hankaku"
-// (Japanese keyboard specific).
-const wchar_t kHotkeyNextEngine[] = L"Shift+Alt_L,Alt+Shift_L,Alt+grave";
-const wchar_t kHotkeyTrigger[] = L""; // We don't allow users to disable IBus.
+// For Simplified Chinese input method (ibus-pinyin)
+const char kPinyinSectionName[] = "engine/Pinyin";
+
+// We have to sync the |ibus_config_name|s with those in
+// ibus-pinyin/files/src/Config.cc.
+const struct {
+ const wchar_t* pref_name;
+ const char* ibus_config_name;
+ bool default_value;
+} kPinyinBooleanPrefs[] = {
+ { prefs::kLanguagePinyinCorrectPinyin, "correct_pinyin", true },
+ { prefs::kLanguagePinyinFuzzyPinyin, "fuzzy_pinyin", false },
+ { prefs::kLanguagePinyinShiftSelectCandidate, "shift_select_candidate",
+ false },
+ { prefs::kLanguagePinyinMinusEqualPage, "minus_equal_page", true },
+ { prefs::kLanguagePinyinCommaPeriodPage, "comma_period_page", true },
+ { prefs::kLanguagePinyinAutoCommit, "auto_commit", false },
+ { prefs::kLanguagePinyinDoublePinyin, "double_pinyin", false },
+ { prefs::kLanguagePinyinInitChinese, "init_chinese", true },
+ { prefs::kLanguagePinyinInitFull, "init_full", false },
+ { prefs::kLanguagePinyinInitFullPunct, "init_full_punct", true },
+ { prefs::kLanguagePinyinInitSimplifiedChinese, "init_simplified_chinese",
+ true },
+ { prefs::kLanguagePinyinTradCandidate, "trad_candidate", false },
+ // TODO(yusukes): Support PINYIN_{INCOMPLETE,CORRECT,FUZZY}_... prefs (32
+ // additional boolean prefs.)
+};
+
+const struct {
+ const wchar_t* pref_name;
+ const char* ibus_config_name;
+ int default_value;
+} kPinyinIntegerPrefs[] = {
+ { prefs::kLanguagePinyinDoublePinyinSchema, "double_pinyin_schema", 0 },
+ // TODO(yusukes): the type of lookup_table_page_size on ibus should be uint.
+ { prefs::kLanguagePinyinLookupTablePageSize, "lookup_table_page_size", 5 },
+};
+
+// For Traditional Chinese input method (ibus-chewing)
-// For Simplified Chinese IME (ibus-pinyin)
-// For Traditional Chinese IME (ibus-chewing)
-// For Japanese IME (ibus-google-japanese-input)
+// For Japanese input method (ibus-mozc)
// TODO(yusukes): Add constants for these components.
} // chromeos
diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc
index cd12b0e..a1e62a0 100644
--- a/chrome/browser/chromeos/preferences.cc
+++ b/chrome/browser/chromeos/preferences.cc
@@ -9,28 +9,12 @@
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/language_library.h"
#include "chrome/browser/chromeos/cros/synaptics_library.h"
-#include "chrome/browser/chromeos/language_preferences.h"
#include "chrome/browser/pref_member.h"
#include "chrome/browser/pref_service.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
#include "unicode/timezone.h"
-namespace {
-
-// Section and config names for the IBus configuration daemon.
-const char kGeneralSectionName[] = "general";
-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";
-
-} // namespace
-
namespace chromeos {
// static
@@ -48,6 +32,14 @@ void Preferences::RegisterUserPrefs(PrefService* prefs) {
UTF8ToWide(kFallbackInputMethodId)); // EN layout
prefs->RegisterStringPref(prefs::kLanguageHangulKeyboard,
kHangulKeyboardNameIDPairs[0].keyboard_id);
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kPinyinBooleanPrefs); ++i) {
+ prefs->RegisterBooleanPref(kPinyinBooleanPrefs[i].pref_name,
+ kPinyinBooleanPrefs[i].default_value);
+ }
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kPinyinIntegerPrefs); ++i) {
+ prefs->RegisterIntegerPref(kPinyinIntegerPrefs[i].pref_name,
+ kPinyinIntegerPrefs[i].default_value);
+ }
}
void Preferences::Init(PrefService* prefs) {
@@ -63,6 +55,14 @@ void Preferences::Init(PrefService* prefs) {
language_hotkey_trigger_.Init(prefs::kLanguageHotkeyTrigger, prefs, this);
language_preload_engines_.Init(prefs::kLanguagePreloadEngines, prefs, this);
language_hangul_keyboard_.Init(prefs::kLanguageHangulKeyboard, prefs, this);
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kPinyinBooleanPrefs); ++i) {
+ language_pinyin_boolean_prefs_[i].Init(
+ kPinyinBooleanPrefs[i].pref_name, prefs, this);
+ }
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kPinyinIntegerPrefs); ++i) {
+ language_pinyin_int_prefs_[i].Init(
+ kPinyinIntegerPrefs[i].pref_name, prefs, this);
+ }
// Initialize touchpad settings to what's saved in user preferences.
NotifyPrefChanged(NULL);
@@ -112,6 +112,20 @@ void Preferences::NotifyPrefChanged(const std::wstring* pref_name) {
if (!pref_name || *pref_name == prefs::kLanguageHangulKeyboard)
SetLanguageConfigString(kHangulSectionName, kHangulKeyboardConfigName,
language_hangul_keyboard_.GetValue());
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kPinyinBooleanPrefs); ++i) {
+ if (!pref_name || *pref_name == kPinyinBooleanPrefs[i].pref_name) {
+ SetLanguageConfigBoolean(kPinyinSectionName,
+ kPinyinBooleanPrefs[i].ibus_config_name,
+ language_pinyin_boolean_prefs_[i].GetValue());
+ }
+ }
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kPinyinIntegerPrefs); ++i) {
+ if (!pref_name || *pref_name == kPinyinIntegerPrefs[i].pref_name) {
+ SetLanguageConfigInteger(kPinyinSectionName,
+ kPinyinIntegerPrefs[i].ibus_config_name,
+ language_pinyin_int_prefs_[i].GetValue());
+ }
+ }
}
void Preferences::SetTimeZone(const std::wstring& id) {
@@ -129,6 +143,15 @@ void Preferences::SetLanguageConfigBoolean(const char* section,
CrosLibrary::Get()->GetLanguageLibrary()->SetImeConfig(section, name, config);
}
+void Preferences::SetLanguageConfigInteger(const char* section,
+ const char* name,
+ int value) {
+ ImeConfigValue config;
+ config.type = ImeConfigValue::kValueTypeInt;
+ config.int_value = value;
+ CrosLibrary::Get()->GetLanguageLibrary()->SetImeConfig(section, name, config);
+}
+
void Preferences::SetLanguageConfigString(const char* section,
const char* name,
const std::wstring& value) {
diff --git a/chrome/browser/chromeos/preferences.h b/chrome/browser/chromeos/preferences.h
index 04cf176..94a0032 100644
--- a/chrome/browser/chromeos/preferences.h
+++ b/chrome/browser/chromeos/preferences.h
@@ -8,6 +8,7 @@
#include <string>
#include <vector>
+#include "chrome/browser/chromeos/language_preferences.h"
#include "chrome/browser/pref_member.h"
#include "chrome/common/notification_observer.h"
@@ -44,20 +45,27 @@ class Preferences : public NotificationObserver {
private:
void SetTimeZone(const std::wstring& id);
- // Writes boolean |value| to the IME (IBus) configuration daemon. |section|
- // (e.g. "general") and |name| (e.g. "use_global_engine") should not be NULL.
+ // Writes boolean |value| to the input method (IBus) configuration daemon.
+ // |section| (e.g. "general") and |name| (e.g. "use_global_engine") should
+ // not be NULL.
void SetLanguageConfigBoolean(const char* section,
const char* name,
bool value);
- // Writes string |value| to the IME (IBus) configuration daemon. |section|
- // and |name| should not be NULL.
+ // Writes integer |value| to the input method (IBus) configuration daemon.
+ // |section| and |name| should not be NULL.
+ void SetLanguageConfigInteger(const char* section,
+ const char* name,
+ int value);
+
+ // Writes string |value| to the input method (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.
+ // Writes a string list to the input method (IBus) configuration daemon.
+ // |section| and |name| should not be NULL.
void SetLanguageConfigStringList(const char* section,
const char* name,
const std::vector<std::wstring>& values);
@@ -73,12 +81,17 @@ class Preferences : public NotificationObserver {
BooleanPrefMember vert_edge_scroll_enabled_;
IntegerPrefMember speed_factor_;
IntegerPrefMember sensitivity_;
- // Language (IME) preferences.
+
+ // Input method preferences.
BooleanPrefMember language_use_global_engine_;
StringPrefMember language_hotkey_next_engine_;
StringPrefMember language_hotkey_trigger_;
StringPrefMember language_preload_engines_;
StringPrefMember language_hangul_keyboard_;
+ BooleanPrefMember language_pinyin_boolean_prefs_[
+ ARRAYSIZE_UNSAFE(kPinyinBooleanPrefs)];
+ IntegerPrefMember language_pinyin_int_prefs_[
+ ARRAYSIZE_UNSAFE(kPinyinIntegerPrefs)];
DISALLOW_COPY_AND_ASSIGN(Preferences);
};
diff --git a/chrome/browser/sync/glue/synchronized_preferences.h b/chrome/browser/sync/glue/synchronized_preferences.h
index a295ec8..77b38c4 100644
--- a/chrome/browser/sync/glue/synchronized_preferences.h
+++ b/chrome/browser/sync/glue/synchronized_preferences.h
@@ -106,6 +106,20 @@ static const wchar_t* kSynchronizedPreferences[] = {
prefs::kLanguageHotkeyTrigger,
prefs::kLanguagePreloadEngines,
prefs::kLanguageHangulKeyboard,
+ prefs::kLanguagePinyinCorrectPinyin,
+ prefs::kLanguagePinyinFuzzyPinyin,
+ prefs::kLanguagePinyinLookupTablePageSize,
+ prefs::kLanguagePinyinShiftSelectCandidate,
+ prefs::kLanguagePinyinMinusEqualPage,
+ prefs::kLanguagePinyinCommaPeriodPage,
+ prefs::kLanguagePinyinAutoCommit,
+ prefs::kLanguagePinyinDoublePinyin,
+ prefs::kLanguagePinyinDoublePinyinSchema,
+ prefs::kLanguagePinyinInitChinese,
+ prefs::kLanguagePinyinInitFull,
+ prefs::kLanguagePinyinInitFullPunct,
+ prefs::kLanguagePinyinInitSimplifiedChinese,
+ prefs::kLanguagePinyinTradCandidate,
#endif
};
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 226618d..584d2b2 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -198,8 +198,8 @@ const wchar_t kTouchpadSpeedFactor[] = L"settings.touchpad.speed_factor";
// A integer pref for the touchpad sensitivity.
const wchar_t kTouchpadSensitivity[] = L"settings.touchpad.sensitivity";
-// Boolean that is true when one IME status can be shared by all input contexts
-// in all Chrome processes.
+// Boolean that is true when one input method status can be shared by all input
+// contexts in all Chrome processes.
const wchar_t kLanguageUseGlobalEngine[] =
L"settings.language.use_global_engine";
@@ -210,11 +210,44 @@ const wchar_t kLanguageHotkeyNextEngine[] =
// 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.
+// A string pref (comma-separated list) set to the preloaded (active) input
+// method IDs.
const wchar_t kLanguagePreloadEngines[] = L"settings.language.preload_engines";
-// A string pref which determines the keyboard layout for Hangul IME.
+// A string pref which determines the keyboard layout for Hangul input method.
const wchar_t kLanguageHangulKeyboard[] = L"settings.language.hangul_keyboard";
+
+// A boolean prefs for ibus-pinyin Chinese input method.
+const wchar_t kLanguagePinyinCorrectPinyin[] =
+ L"settings.language.pinyin_correct_pinyin";
+const wchar_t kLanguagePinyinFuzzyPinyin[] =
+ L"settings.language.pinyin_fuzzy_pinyin";
+const wchar_t kLanguagePinyinShiftSelectCandidate[] =
+ L"settings.language.pinyin_shift_select_candidate";
+const wchar_t kLanguagePinyinMinusEqualPage[] =
+ L"settings.language.pinyin_minus_equal_page";
+const wchar_t kLanguagePinyinCommaPeriodPage[] =
+ L"settings.language.pinyin_comma_period_page";
+const wchar_t kLanguagePinyinAutoCommit[] =
+ L"settings.language.pinyin_auto_commit";
+const wchar_t kLanguagePinyinDoublePinyin[] =
+ L"settings.language.pinyin_double_pinyin";
+const wchar_t kLanguagePinyinInitChinese[] =
+ L"settings.language.pinyin_init_chinese";
+const wchar_t kLanguagePinyinInitFull[] =
+ L"settings.language.pinyin_init_full";
+const wchar_t kLanguagePinyinInitFullPunct[] =
+ L"settings.language.pinyin_init_full_punct";
+const wchar_t kLanguagePinyinInitSimplifiedChinese[] =
+ L"settings.language.pinyin_init_simplified_chinese";
+const wchar_t kLanguagePinyinTradCandidate[] =
+ L"settings.language.pinyin_trad_candidate";
+
+// A integer prefs for ibus-pinyin Chinese input method.
+const wchar_t kLanguagePinyinDoublePinyinSchema[] =
+ L"settings.language.pinyin_double_pinyin_schema";
+const wchar_t kLanguagePinyinLookupTablePageSize[] =
+ L"settings.language.pinyin_lookup_table_page_size";
#endif
// The disabled messages in IPC logging.
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 3ab864e..f75866d 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -78,6 +78,20 @@ extern const wchar_t kLanguageHotkeyNextEngine[];
extern const wchar_t kLanguageHotkeyTrigger[];
extern const wchar_t kLanguagePreloadEngines[];
extern const wchar_t kLanguageHangulKeyboard[];
+extern const wchar_t kLanguagePinyinCorrectPinyin[];
+extern const wchar_t kLanguagePinyinFuzzyPinyin[];
+extern const wchar_t kLanguagePinyinLookupTablePageSize[];
+extern const wchar_t kLanguagePinyinShiftSelectCandidate[];
+extern const wchar_t kLanguagePinyinMinusEqualPage[];
+extern const wchar_t kLanguagePinyinCommaPeriodPage[];
+extern const wchar_t kLanguagePinyinAutoCommit[];
+extern const wchar_t kLanguagePinyinDoublePinyin[];
+extern const wchar_t kLanguagePinyinDoublePinyinSchema[];
+extern const wchar_t kLanguagePinyinInitChinese[];
+extern const wchar_t kLanguagePinyinInitFull[];
+extern const wchar_t kLanguagePinyinInitFullPunct[];
+extern const wchar_t kLanguagePinyinInitSimplifiedChinese[];
+extern const wchar_t kLanguagePinyinTradCandidate[];
#endif
extern const wchar_t kIpcDisabledMessages[];
extern const wchar_t kShowHomeButton[];