diff options
Diffstat (limited to 'chrome/browser/chromeos/options/language_config_view.h')
-rw-r--r-- | chrome/browser/chromeos/options/language_config_view.h | 68 |
1 files changed, 50 insertions, 18 deletions
diff --git a/chrome/browser/chromeos/options/language_config_view.h b/chrome/browser/chromeos/options/language_config_view.h index 0604e99..2a1b932 100644 --- a/chrome/browser/chromeos/options/language_config_view.h +++ b/chrome/browser/chromeos/options/language_config_view.h @@ -11,7 +11,8 @@ #include <vector> #include "app/table_model.h" -#include "chrome/browser/chromeos/cros/language_library.h" +#include "chrome/browser/pref_member.h" +#include "chrome/browser/views/options/options_page_view.h" #include "views/controls/button/native_button.h" #include "views/controls/label.h" #include "views/controls/table/table_view2.h" @@ -30,7 +31,7 @@ class LanguageConfigView : public TableModel, public views::ButtonListener, public views::DialogDelegate, public views::TableViewObserver, - public views::View { + public OptionsPageView { public: explicit LanguageConfigView(Profile* profile); virtual ~LanguageConfigView(); @@ -47,9 +48,6 @@ class LanguageConfigView : public TableModel, // views::View overrides: virtual void Layout(); virtual gfx::Size GetPreferredSize(); - virtual void ViewHierarchyChanged(bool is_add, - views::View* parent, - views::View* child); // views::TableViewObserver overrides: virtual void OnSelectionChanged(); @@ -66,6 +64,18 @@ class LanguageConfigView : public TableModel, // Invoked when a language is added from the add button. void OnAddLanguage(const std::string& language_code); + // OptionsPageView overrides. + virtual void InitControlLayout(); + + // NotificationObserver overrides. + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details); + + // Gets the list of supported language codes like "en" and "ja". + void GetSupportedLangageCodes( + std::vector<std::string>* out_language_codes) const; + // Rewrites the language name and returns the modified version if // necessary. Otherwise, returns the given language name as is. // In particular, this rewrites the special language name used for input @@ -74,16 +84,12 @@ class LanguageConfigView : public TableModel, const std::wstring& language_name); private: - // Initializes the view. - void Init(); - - // Initializes the preferred language table codes based on the active - // input languages. - void InitPreferredLanguageCodes(); - // Initializes the input method config view. void InitInputMethodConfigViewMap(); + // Initialize id_to_{code,display_name}_map_ member variables. + void InitLanguageIdMaps(); + // Creates the contents on the left, including the language table. views::View* CreateContentsOnLeft(); @@ -93,16 +99,38 @@ class LanguageConfigView : public TableModel, // Deactivates the input languages for the given language code. void DeactivateInputLanguagesFor(const std::string& language_code); - // Creates the input method config view based on the given |language|. + // Creates the input method config view based on the given |language_id|. // Returns NULL if the config view is not found. views::DialogDelegate* CreateInputMethodConfigureView( - const InputLanguage& language); + const std::string& language_id); + + // Activates or deactivates an IME whose ID is |language_id|. + void SetLanguageActivated(const std::string& language_id, bool activated); - // The profile object. Does not take ownership of the object. - Profile* profile_; + // Returns true if an IME of |language_id| is activated. + bool LanguageIsActivated(const std::string& language_id); + + // Gets the list of active IME IDs like "pinyin" and "m17n:ar:kbd". + void GetActiveLanguageIDs(std::vector<std::string>* out_language_ids); + + // Gets the list of supported IME IDs like "pinyin" and "m17n:ar:kbd". + void GetSupportedLangageIDs(std::vector<std::string>* out_language_ids) const; + + // Converts a language ID to a language code of the IME. Returns "" when + // |language_id| is unknown. + // Example: "hangul" => "ko" + std::string GetLanguageCodeFromID(const std::string& language_id) const; + + // Converts a language ID to a display name of the IME. Returns "" when + // |language_id| is unknown. + // Examples: "pinyin" => "Pinyin" + // "m17n:ar:kbd" => "kbd (m17n)" + std::string GetDisplayNameFromID(const std::string& language_id) const; + + // Callback for |preload_engines_| pref updates. Initializes the preferred + // language codes based on the updated pref value. + void NotifyPrefChanged(); - // The language library interface. - LanguageLibrary* language_library_; // The codes of the preferred languages. std::vector<std::string> preferred_language_codes_; // The map of the input language id to a pointer to the function for @@ -123,6 +151,10 @@ class LanguageConfigView : public TableModel, views::NativeButton* remove_language_button_; views::TableView2* preferred_language_table_; + StringPrefMember preload_engines_; + std::map<std::string, std::string> id_to_language_code_map_; + std::map<std::string, std::string> id_to_display_name_map_; + DISALLOW_COPY_AND_ASSIGN(LanguageConfigView); }; |