summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authoryusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-05 08:30:34 +0000
committeryusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-05 08:30:34 +0000
commit70aa5b3f170b0f0edbaae0dfcf079740b39a2d68 (patch)
treeb3049ea800bb9da0595c08d02cc460bc4612de77 /chrome
parent8ec2dc84ce04328a0760cc2df988ce3fe8a7dd1e (diff)
downloadchromium_src-70aa5b3f170b0f0edbaae0dfcf079740b39a2d68.zip
chromium_src-70aa5b3f170b0f0edbaae0dfcf079740b39a2d68.tar.gz
chromium_src-70aa5b3f170b0f0edbaae0dfcf079740b39a2d68.tar.bz2
Adding "preload_engines" and "use_global_engine" preferences to Chrome side (2nd try; see r43475 and r43481).
Modified chrome/browser/chromeos/cros/cros_in_process_browser_test.cc not to break browser_tests. Other files are not modified since the previous CL (r43475). BUG=crosbug.com/488 TEST=none Review URL: http://codereview.chromium.org/1599017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43603 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/chromeos/cros/cros_in_process_browser_test.cc12
-rw-r--r--chrome/browser/chromeos/language_preferences.h3
-rw-r--r--chrome/browser/chromeos/preferences.cc49
-rw-r--r--chrome/browser/chromeos/preferences.h19
-rw-r--r--chrome/common/pref_names.cc8
-rw-r--r--chrome/common/pref_names.h2
6 files changed, 88 insertions, 5 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 724987b..1c910b0 100644
--- a/chrome/browser/chromeos/cros/cros_in_process_browser_test.cc
+++ b/chrome/browser/chromeos/cros/cros_in_process_browser_test.cc
@@ -101,9 +101,15 @@ void CrosInProcessBrowserTest::SetLanguageLibraryStatusAreaExpectations() {
.Times(1)
.RetiresOnSaturation();
EXPECT_CALL(*mock_language_library_, GetActiveLanguages())
- .Times(1)
+ .Times(2)
+ // Don't use WillRepeatedly since the fucntion should be evaluated twice.
+ .WillOnce(Return(CreateFallbackInputLanguageList()))
.WillOnce(Return(CreateFallbackInputLanguageList()))
.RetiresOnSaturation();
+ EXPECT_CALL(*mock_language_library_, SetLanguageActivated(_, _, _))
+ .Times(1)
+ .WillOnce((Return(true)))
+ .RetiresOnSaturation();
EXPECT_CALL(*mock_language_library_, current_ime_properties())
.Times(1)
.WillOnce((ReturnRef(ime_properties_)))
@@ -113,8 +119,8 @@ void CrosInProcessBrowserTest::SetLanguageLibraryStatusAreaExpectations() {
.WillOnce((ReturnRef(language_)))
.RetiresOnSaturation();
EXPECT_CALL(*mock_language_library_, SetImeConfig(_, _, _))
- .Times(1)
- .WillOnce((Return(true)))
+ .Times(2)
+ .WillRepeatedly((Return(true)))
.RetiresOnSaturation();
EXPECT_CALL(*mock_language_library_, RemoveObserver(_))
.Times(1)
diff --git a/chrome/browser/chromeos/language_preferences.h b/chrome/browser/chromeos/language_preferences.h
index 3fee2e3..a98986b 100644
--- a/chrome/browser/chromeos/language_preferences.h
+++ b/chrome/browser/chromeos/language_preferences.h
@@ -22,6 +22,9 @@ const struct HangulKeyboardNameIDPair {
};
// For ibus-daemon
+// TODO(yusukes): replace "USA" with "xkb:..." when ibus-xkb-layout gets ready.
+const wchar_t kDefaultPreloadEngine[] = L"USA";
+
// 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 043e6c3..6009748 100644
--- a/chrome/browser/chromeos/preferences.cc
+++ b/chrome/browser/chromeos/preferences.cc
@@ -19,6 +19,8 @@
namespace {
// Section and config names for the IBus configuration daemon.
+const char kGeneralSectionName[] = "general";
+const char kUseGlobalEngineConfigName[] = "use_global_engine";
const char kHangulSectionName[] = "engine/Hangul";
const char kHangulKeyboardConfigName[] = "HangulKeyboard";
@@ -33,6 +35,9 @@ void Preferences::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterBooleanPref(prefs::kVertEdgeScrollEnabled, false);
prefs->RegisterIntegerPref(prefs::kTouchpadSpeedFactor, 5);
prefs->RegisterIntegerPref(prefs::kTouchpadSensitivity, 5);
+ prefs->RegisterBooleanPref(prefs::kLanguageUseGlobalEngine, true);
+ prefs->RegisterStringPref(prefs::kLanguagePreloadEngines,
+ kDefaultPreloadEngine);
prefs->RegisterStringPref(prefs::kLanguageHangulKeyboard,
kHangulKeyboardNameIDPairs[0].keyboard_id);
}
@@ -43,6 +48,9 @@ void Preferences::Init(PrefService* prefs) {
vert_edge_scroll_enabled_.Init(prefs::kVertEdgeScrollEnabled, prefs, this);
speed_factor_.Init(prefs::kTouchpadSpeedFactor, prefs, this);
sensitivity_.Init(prefs::kTouchpadSensitivity, prefs, this);
+ language_use_global_engine_.Init(
+ prefs::kLanguageUseGlobalEngine, prefs, this);
+ language_preload_engines_.Init(prefs::kLanguagePreloadEngines, prefs, this);
language_hangul_keyboard_.Init(prefs::kLanguageHangulKeyboard, prefs, this);
// Initialize touchpad settings to what's saved in user preferences.
@@ -75,6 +83,11 @@ void Preferences::NotifyPrefChanged(const std::wstring* pref_name) {
CrosLibrary::Get()->GetSynapticsLibrary()->SetRangeParameter(
PARAM_RANGE_TOUCH_SENSITIVITY,
sensitivity_.GetValue());
+ if (!pref_name || *pref_name == prefs::kLanguageUseGlobalEngine)
+ SetLanguageConfigBoolean(kGeneralSectionName, kUseGlobalEngineConfigName,
+ language_use_global_engine_.GetValue());
+ if (!pref_name || *pref_name == prefs::kLanguagePreloadEngines)
+ SetPreloadEngines(language_preload_engines_.GetValue());
if (!pref_name || *pref_name == prefs::kLanguageHangulKeyboard)
SetLanguageConfigString(kHangulSectionName, kHangulKeyboardConfigName,
language_hangul_keyboard_.GetValue());
@@ -86,6 +99,15 @@ void Preferences::SetTimeZone(const std::wstring& id) {
icu::TimeZone::adoptDefault(timezone);
}
+void Preferences::SetLanguageConfigBoolean(const char* section,
+ const char* name,
+ bool value) {
+ ImeConfigValue config;
+ config.type = ImeConfigValue::kValueTypeBool;
+ config.bool_value = value;
+ CrosLibrary::Get()->GetLanguageLibrary()->SetImeConfig(section, name, config);
+}
+
void Preferences::SetLanguageConfigString(const char* section,
const char* name,
const std::wstring& value) {
@@ -95,4 +117,31 @@ void Preferences::SetLanguageConfigString(const char* section,
CrosLibrary::Get()->GetLanguageLibrary()->SetImeConfig(section, name, config);
}
+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> engine_ids;
+ SplitString(value, L',', &engine_ids);
+ LOG(INFO) << "Setting preload_engines to '" << value << "'";
+
+ // Activate languages in |value|.
+ for (size_t i = 0; i < engine_ids.size(); ++i) {
+ library->SetLanguageActivated(
+ LANGUAGE_CATEGORY_IME, WideToUTF8(engine_ids[i]), true);
+ }
+
+ // Deactivate languages that are currently active, but are not in |value|.
+ const std::set<std::wstring> id_set(engine_ids.begin(), engine_ids.end());
+ scoped_ptr<InputLanguageList> active_engines(library->GetActiveLanguages());
+ for (size_t i = 0; i < active_engines->size(); ++i) {
+ const InputLanguage& active_engine = active_engines->at(i);
+ if (id_set.count(UTF8ToWide(active_engine.id)) == 0) {
+ library->SetLanguageActivated(
+ active_engine.category, active_engine.id, false);
+ }
+ }
+}
+
} // namespace chromeos
diff --git a/chrome/browser/chromeos/preferences.h b/chrome/browser/chromeos/preferences.h
index f4cb2e3..d324e09 100644
--- a/chrome/browser/chromeos/preferences.h
+++ b/chrome/browser/chromeos/preferences.h
@@ -43,17 +43,32 @@ class Preferences : public NotificationObserver {
private:
void SetTimeZone(const std::wstring& id);
- // Writes |value| to the IME (IBus) configuration daemon. |section| (e.g.
- // "engine/Hangul") and |name| (e.g. "HangulKeyboard") should not be NULL.
+ // Writes boolean |value| to the IME (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 stromg |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);
+ // 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);
+
StringPrefMember timezone_;
BooleanPrefMember tap_to_click_enabled_;
BooleanPrefMember vert_edge_scroll_enabled_;
IntegerPrefMember speed_factor_;
IntegerPrefMember sensitivity_;
+ // Language (IME) preferences.
+ BooleanPrefMember language_use_global_engine_;
+ StringPrefMember language_preload_engines_;
StringPrefMember language_hangul_keyboard_;
DISALLOW_COPY_AND_ASSIGN(Preferences);
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index d1cb8b7..79afae1 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -194,6 +194,14 @@ 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.
+const wchar_t kLanguageUseGlobalEngine[] =
+ L"settings.language.use_global_engine";
+
+// A string pref (comma-separated list) set to the preloaded (active) IME IDs.
+const wchar_t kLanguagePreloadEngines[] = L"settings.language.preload_engines";
+
// A string pref which determines the keyboard layout for Hangul IME.
const wchar_t kLanguageHangulKeyboard[] = L"settings.language.hangul_keyboard";
#endif
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 44323e6..cbbb603 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -72,6 +72,8 @@ extern const wchar_t kTapToClickEnabled[];
extern const wchar_t kVertEdgeScrollEnabled[];
extern const wchar_t kTouchpadSpeedFactor[];
extern const wchar_t kTouchpadSensitivity[];
+extern const wchar_t kLanguageUseGlobalEngine[];
+extern const wchar_t kLanguagePreloadEngines[];
extern const wchar_t kLanguageHangulKeyboard[];
#endif
extern const wchar_t kIpcDisabledMessages[];