From f1c42aa16ff81a4983d17b717513e231e1850ab2 Mon Sep 17 00:00:00 2001 From: "satorux@chromium.org" Date: Tue, 19 Jan 2010 06:17:30 +0000 Subject: Add GetSupportedLanguages(), ActiveLanguage(), and DeactivateLanguage(). These are wrappers for functions added in libcros http://git.chromium.org/cgi-bin/gitweb.cgi?p=cros.git;a=commit;h=adc84eae83d75cc6c2a59c89e5276d072ca69c8d TEST=none BUG=none Review URL: http://codereview.chromium.org/542108 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36512 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/chromeos/language_library.cc | 28 ++++++++++++++++++++++++++++ chrome/browser/chromeos/language_library.h | 21 ++++++++++++++++++--- 2 files changed, 46 insertions(+), 3 deletions(-) (limited to 'chrome') diff --git a/chrome/browser/chromeos/language_library.cc b/chrome/browser/chromeos/language_library.cc index 7db0a2b..fcb0604 100644 --- a/chrome/browser/chromeos/language_library.cc +++ b/chrome/browser/chromeos/language_library.cc @@ -60,6 +60,14 @@ chromeos::InputLanguageList* LanguageLibrary::GetLanguages() { return result ? result : CreateFallbackInputLanguageList(); } +chromeos::InputLanguageList* LanguageLibrary::GetSupportedLanguages() { + chromeos::InputLanguageList* result = NULL; + if (EnsureLoaded()) { + result = chromeos::GetSupportedLanguages(language_status_connection_); + } + return result ? result : CreateFallbackInputLanguageList(); +} + void LanguageLibrary::ChangeLanguage( LanguageCategory category, const std::string& id) { if (EnsureLoaded()) { @@ -67,6 +75,26 @@ void LanguageLibrary::ChangeLanguage( } } +bool LanguageLibrary::ActivateLanguage( + LanguageCategory category, const std::string& id) { + bool success = false; + if (EnsureLoaded()) { + success = chromeos::ActivateLanguage(language_status_connection_, + category, id.c_str()); + } + return success; +} + +bool LanguageLibrary::DeactivateLanguage( + LanguageCategory category, const std::string& id) { + bool success = false; + if (EnsureLoaded()) { + success = chromeos::DeactivateLanguage(language_status_connection_, + category, id.c_str()); + } + return success; +} + // static void LanguageLibrary::LanguageChangedHandler( void* object, const chromeos::InputLanguage& current_language) { diff --git a/chrome/browser/chromeos/language_library.h b/chrome/browser/chromeos/language_library.h index e79d159..88c197c 100644 --- a/chrome/browser/chromeos/language_library.h +++ b/chrome/browser/chromeos/language_library.h @@ -35,11 +35,18 @@ class LanguageLibrary { void AddObserver(Observer* observer); void RemoveObserver(Observer* observer); - // Returns the list of IMEs and keyboard layouts we can select. If the cros - // library is not found or IBus/DBus daemon is not alive, this function - // returns a fallback language list (and never returns NULL). + // Returns the list of IMEs and keyboard layouts we can select + // (i.e. active). If the cros library is not found or IBus/DBus daemon + // is not alive, this function returns a fallback language list (and + // never returns NULL). InputLanguageList* GetLanguages(); + // Returns the list of IMEs and keyboard layouts we support, including + // ones not active. If the cros library is not found or IBus/DBus + // daemon is not alive, this function returns a fallback language list + // (and never returns NULL). + InputLanguageList* GetSupportedLanguages(); + // Changes the current IME engine to |id| and enable IME (when |category| // is LANGUAGE_CATEGORY_IME). Changes the current XKB layout to |id| and // disable IME (when |category| is LANGUAGE_CATEGORY_XKB). |id| is a unique @@ -47,6 +54,14 @@ class LanguageLibrary { // in src third_party/cros/ for details. void ChangeLanguage(LanguageCategory category, const std::string& id); + // Activates the language specified by |category| and |id|. Returns true + // on success. + bool ActivateLanguage(LanguageCategory category, const std::string& id); + + // Dectivates the language specified by |category| and |id|. Returns + // true on success. + bool DeactivateLanguage(LanguageCategory category, const std::string& id); + const InputLanguage& current_language() const { return current_language_; } -- cgit v1.1