summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authoryusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-24 08:18:44 +0000
committeryusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-24 08:18:44 +0000
commit6e5c4b8b5a1ff4ac9c453ea577008232fba264b7 (patch)
tree9d115be21716c368ca1e474d12b605d2208ee443 /chrome
parent82a28229452b01e1dd919540b2b58a8aacb411d7 (diff)
downloadchromium_src-6e5c4b8b5a1ff4ac9c453ea577008232fba264b7.zip
chromium_src-6e5c4b8b5a1ff4ac9c453ea577008232fba264b7.tar.gz
chromium_src-6e5c4b8b5a1ff4ac9c453ea577008232fba264b7.tar.bz2
Initial implementation of a config dialog for ibus-mozc.
- Implemented the dialog which shows 4 pref items: Input method (Romaji/Kana), keymap (MSIME/ATOK/Kotoeri), punctuation style, and symbol style. - Added string resources for the dialog to generated_resources.grd. - Added chrome prefs to pref_names.cc. - Added mappings from the mozc engine name to the dialog to language_config_view.cc while it's commented out now. - Added comments to sync/glue/synchronized_preferences.h. BUG=chromium-os:2625 TEST=manual Review URL: http://codereview.chromium.org/2068014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48021 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/generated_resources.grd80
-rw-r--r--chrome/browser/chromeos/language_preferences.h107
-rw-r--r--chrome/browser/chromeos/options/language_config_view.cc15
-rw-r--r--chrome/browser/chromeos/options/language_hangul_config_view.cc4
-rw-r--r--chrome/browser/chromeos/options/language_hangul_config_view.h3
-rw-r--r--chrome/browser/chromeos/options/language_mozc_config_view.cc217
-rw-r--r--chrome/browser/chromeos/options/language_mozc_config_view.h71
-rw-r--r--chrome/browser/chromeos/options/language_pinyin_config_view.cc4
-rw-r--r--chrome/browser/chromeos/preferences.cc20
-rw-r--r--chrome/browser/chromeos/preferences.h2
-rw-r--r--chrome/browser/sync/glue/synchronized_preferences.h6
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--chrome/common/pref_names.cc12
-rw-r--r--chrome/common/pref_names.h4
14 files changed, 513 insertions, 34 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 4dfd6d8..a72eecd 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -7505,6 +7505,86 @@ Keep your key file in a safe place. You will need it to create new versions of y
desc="The checkbox label for a Pinyin input method preference">
Display candidates in Traditional Chinese
</message>
+ <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SETTINGS_TITLE"
+ desc="The title for the Mozc Japanese input settings dialog">
+ Japanese Input Settings
+ </message>
+ <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_PREEDIT_METHOD"
+ desc="The combobox description for the Mozc input method preference">
+ Input Method
+ </message>
+ <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_PREEDIT_METHOD_ROMAN"
+ desc="The combobox value for the Mozc input method preference">
+ Romaji
+ </message>
+ <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_PREEDIT_METHOD_KANA"
+ desc="The combobox value for the Mozc input method preference">
+ Kana
+ </message>
+ <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SESSION_KEYMAP"
+ desc="The combobox description for the Mozc input method preference">
+ Keymap style
+ </message>
+ <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SESSION_KEYMAP_ATOK"
+ desc="The combobox value for the Mozc input method preference (might be non-translateable?)">
+ ATOK
+ </message>
+ <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SESSION_KEYMAP_MSIME"
+ desc="The combobox value for the Mozc input method preference (might be non-translateable?)">
+ MS-IME
+ </message>
+ <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SESSION_KEYMAP_KOTOERI"
+ desc="The combobox value for the Mozc input method preference. When lang is ja, it should be written in Hiragana">
+ Kotoeri
+ </message>
+ <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_PUNCTUATION_METHOD"
+ desc="The combobox description for the Mozc input method preference">
+ Punctuation style
+ </message>
+ <message translateable="false"
+ name="IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_PUNCTUATION_METHOD_KUTEN_TOUTEN"
+ desc="The combobox value for the Mozc input method preference">
+ &#x3001;&#x3002;
+ </message>
+ <message translateable="false"
+ name="IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_PUNCTUATION_METHOD_COMMA_PERIOD"
+ desc="The combobox value for the Mozc input method preference">
+ &#xff0c;&#xff0e;
+ </message>
+ <message translateable="false"
+ name="IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_PUNCTUATION_METHOD_KUTEN_PERIOD"
+ desc="The combobox value for the Mozc input method preference">
+ &#x3001;&#xff0e;
+ </message>
+ <message translateable="false"
+ name="IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_PUNCTUATION_METHOD_COMMA_TOUTEN"
+ desc="The combobox value for the Mozc input method preference">
+ &#xff0c;&#x3002;
+ </message>
+ <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SYMBOL_METHOD"
+ desc="The combobox description for the Mozc input method preference">
+ Symbol style
+ </message>
+ <message translateable="false"
+ name="IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SYMBOL_CORNER_BRACKET_MIDDLE_DOT"
+ desc="The combobox value for the Mozc input method preference">
+ &#x300c;&#x300d;&#x30fb;
+ </message>
+ <message translateable="false"
+ name="IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SYMBOL_SQUARE_BRACKET_SLASH"
+ desc="The combobox value for the Mozc input method preference">
+ &#xff3b;&#xff3d;&#xff0f;
+ </message>
+ <message translateable="false"
+ name="IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SYMBOL_CORNER_BRACKET_SLASH"
+ desc="The combobox value for the Mozc input method preference">
+ &#x300c;&#x300d;&#xff0f;
+ </message>
+ <message translateable="false"
+ name="IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SYMBOL_SQUARE_BRACKET_MIDDLE_DOT"
+ desc="The combobox value for the Mozc input method preference">
+ &#xff3b;&#xff3d;&#x30fb;
+ </message>
<message name="IDS_OPTIONS_SETTINGS_LANGUAGES_CONFIGURE"
desc="The label for the configure button for input methods">
Configure...
diff --git a/chrome/browser/chromeos/language_preferences.h b/chrome/browser/chromeos/language_preferences.h
index b5d7793..c4ae77b 100644
--- a/chrome/browser/chromeos/language_preferences.h
+++ b/chrome/browser/chromeos/language_preferences.h
@@ -59,35 +59,34 @@ 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 wchar_t* pref_name; // Chrome preference name.
+ bool default_pref_value;
const char* ibus_config_name;
- bool default_value;
int message_id;
} kPinyinBooleanPrefs[] = {
- { prefs::kLanguagePinyinCorrectPinyin, "CorrectPinyin", true,
+ { prefs::kLanguagePinyinCorrectPinyin, true, "CorrectPinyin",
IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_SETTING_CORRECT_PINYIN },
- { prefs::kLanguagePinyinFuzzyPinyin, "FuzzyPinyin", false,
+ { prefs::kLanguagePinyinFuzzyPinyin, false, "FuzzyPinyin",
IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_SETTING_FUZZY_PINYIN },
- { prefs::kLanguagePinyinShiftSelectCandidate, "ShiftSelectCandidate",
- false, IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_SETTING_SHIFT_SELECT_PINYIN },
- { prefs::kLanguagePinyinMinusEqualPage, "MinusEqualPage", true,
+ { prefs::kLanguagePinyinShiftSelectCandidate, false, "ShiftSelectCandidate",
+ IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_SETTING_SHIFT_SELECT_PINYIN },
+ { prefs::kLanguagePinyinMinusEqualPage, true, "MinusEqualPage",
IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_SETTING_MINUS_EQUAL_PAGE },
- { prefs::kLanguagePinyinCommaPeriodPage, "CommaPeriodPage", true,
+ { prefs::kLanguagePinyinCommaPeriodPage, true, "CommaPeriodPage",
IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_SETTING_COMMA_PERIOD_PAGE },
- { prefs::kLanguagePinyinAutoCommit, "AutoCommit", false,
+ { prefs::kLanguagePinyinAutoCommit, false, "AutoCommit",
IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_SETTING_AUTO_COMMIT },
- { prefs::kLanguagePinyinDoublePinyin, "DoublePinyin", false,
+ { prefs::kLanguagePinyinDoublePinyin, false, "DoublePinyin",
IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_SETTING_DOUBLE_PINYIN },
- { prefs::kLanguagePinyinInitChinese, "InitChinese", true,
+ { prefs::kLanguagePinyinInitChinese, true, "InitChinese",
IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_SETTING_INIT_CHINESE },
- { prefs::kLanguagePinyinInitFull, "InitFull", false,
+ { prefs::kLanguagePinyinInitFull, false, "InitFull",
IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_SETTING_INIT_FULL },
- { prefs::kLanguagePinyinInitFullPunct, "InitFullPunct", true,
+ { prefs::kLanguagePinyinInitFullPunct, true, "InitFullPunct",
IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_SETTING_INIT_FULL_PUNCT },
- { prefs::kLanguagePinyinInitSimplifiedChinese, "InitSimplifiedChinese",
- true,
+ { prefs::kLanguagePinyinInitSimplifiedChinese, true, "InitSimplifiedChinese",
IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_SETTING_INIT_SIMPLIFIED_CHINESE },
- { prefs::kLanguagePinyinTradCandidate, "TradCandidate", false,
+ { prefs::kLanguagePinyinTradCandidate, false, "TradCandidate",
IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_SETTING_TRAD_CANDIDATE },
// TODO(yusukes): Support PINYIN_{INCOMPLETE,CORRECT,FUZZY}_... prefs (32
// additional boolean prefs.)
@@ -96,22 +95,84 @@ const size_t kNumPinyinBooleanPrefs = ARRAYSIZE_UNSAFE(kPinyinBooleanPrefs);
// TODO(yusukes): Support HalfWidthPuncts and IncompletePinyin prefs if needed.
const struct {
- const wchar_t* pref_name;
+ const wchar_t* pref_name; // Chrome preference name.
+ int default_pref_value;
const char* ibus_config_name;
- int default_value;
// TODO(yusukes): Add message_id if needed.
} kPinyinIntegerPrefs[] = {
- { prefs::kLanguagePinyinDoublePinyinSchema, "DoublePinyinSchema", 0 },
+ { prefs::kLanguagePinyinDoublePinyinSchema, 0, "DoublePinyinSchema" },
// TODO(yusukes): the type of lookup_table_page_size on ibus should be uint.
- { prefs::kLanguagePinyinLookupTablePageSize, "LookupTablePageSize", 5 },
+ { prefs::kLanguagePinyinLookupTablePageSize, 5, "LookupTablePageSize" },
};
const size_t kNumPinyinIntegerPrefs = ARRAYSIZE_UNSAFE(kPinyinIntegerPrefs);
-// For Traditional Chinese input method (ibus-chewing)
-
// For Japanese input method (ibus-mozc)
+const char kMozcSectionName[] = "engine/Mozc";
+
+const struct MozcMultipleChoicePreference {
+ const wchar_t* pref_name; // Chrome preference name.
+ const wchar_t* default_pref_value;
+ // The config names and values have to be matched with protobuf member names
+ // in chromiumos/src/third_party/ibus-mozc/files/src/session/config.proto
+ // since ibus-mozc uses protobuf reflection APIs to pass prefs to the Mozc
+ // Japanese converter.
+ const char* ibus_config_name;
+ // Currently we have 4 combobox items at most.
+ static const size_t kMaxItems = 4;
+ struct {
+ const char* ibus_config_value;
+ int item_message_id; // Resource grd ID for the combobox item.
+ } values_and_ids[kMaxItems];
+ int label_message_id; // Resource grd ID for the label.
+
+} kMozcMultipleChoicePrefs[] = {
+ { prefs::kLanguageMozcPreeditMethod,
+ L"ROMAN",
+ "preedit_method",
+ {{ "ROMAN", IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_PREEDIT_METHOD_ROMAN },
+ { "KANA", IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_PREEDIT_METHOD_KANA }},
+ IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_PREEDIT_METHOD,
+ },
+ { prefs::kLanguageMozcSessionKeymap,
+ L"MSIME",
+ "session_keymap",
+ {{ "ATOK", IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SESSION_KEYMAP_ATOK },
+ { "MSIME", IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SESSION_KEYMAP_MSIME },
+ { "KOTOERI", IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SESSION_KEYMAP_KOTOERI }},
+ // TODO: Support "CUSTOM" keymap.
+ IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SESSION_KEYMAP,
+ },
+ { prefs::kLanguageMozcPunctuationMethod,
+ L"KUTEN_TOTEN",
+ "punctuation_method",
+ {{ "KUTEN_TOUTEN",
+ IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_PUNCTUATION_METHOD_KUTEN_TOUTEN },
+ { "COMMA_PERIOD",
+ IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_PUNCTUATION_METHOD_COMMA_PERIOD },
+ { "KUTEN_PERIOD",
+ IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_PUNCTUATION_METHOD_KUTEN_PERIOD },
+ { "COMMA_TOUTEN",
+ IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_PUNCTUATION_METHOD_COMMA_TOUTEN }},
+ IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_PUNCTUATION_METHOD,
+ },
+ { prefs::kLanguageMozcSymbolMethod,
+ L"CORNER_BRACKET_MIDDLE_DOT",
+ "symbol_method",
+ {{ "CORNER_BRACKET_MIDDLE_DOT",
+ IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SYMBOL_CORNER_BRACKET_MIDDLE_DOT },
+ { "SQUARE_BRACKET_SLASH",
+ IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SYMBOL_SQUARE_BRACKET_SLASH },
+ { "CORNER_BRACKET_SLASH",
+ IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SYMBOL_CORNER_BRACKET_SLASH },
+ { "SQUARE_BRACKET_MIDDLE_DOT",
+ IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SYMBOL_SQUARE_BRACKET_MIDDLE_DOT }},
+ IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SYMBOL_METHOD,
+ },
+};
+const size_t kNumMozcMultipleChoicePrefs = arraysize(kMozcMultipleChoicePrefs);
-// TODO(yusukes): Add constants for these components.
+// For Traditional Chinese input methods (ibus-pinyin-bopomofo and ibus-chewing)
+// TODO(yusukes): Add constants for Traditional Chinese input methods.
} // chromeos
#endif // CHROME_BROWSER_CHROMEOS_LANGUAGE_PREFERENCES_H_
diff --git a/chrome/browser/chromeos/options/language_config_view.cc b/chrome/browser/chromeos/options/language_config_view.cc
index b5ef9d8..fe3f2c7 100644
--- a/chrome/browser/chromeos/options/language_config_view.cc
+++ b/chrome/browser/chromeos/options/language_config_view.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/language_library.h"
#include "chrome/browser/chromeos/options/language_hangul_config_view.h"
+#include "chrome/browser/chromeos/options/language_mozc_config_view.h"
#include "chrome/browser/chromeos/options/language_pinyin_config_view.h"
#include "chrome/browser/chromeos/options/options_window_view.h"
#include "chrome/browser/chromeos/preferences.h"
@@ -50,6 +51,9 @@ views::DialogDelegate* CreateLanguageHangulConfigView(Profile* profile) {
views::DialogDelegate* CreateLanguagePinyinConfigView(Profile* profile) {
return new LanguagePinyinConfigView(profile);
}
+views::DialogDelegate* CreateLanguageMozcConfigView(Profile* profile) {
+ return new LanguageMozcConfigView(profile);
+}
// The tags are used to identify buttons in ButtonPressed().
enum ButtonTag {
@@ -500,10 +504,13 @@ void LanguageConfigView::InitControlLayout() {
}
void LanguageConfigView::InitInputMethodConfigViewMap() {
- input_method_config_view_map_["hangul"] =
- CreateLanguageHangulConfigView;
- input_method_config_view_map_["pinyin"] =
- CreateLanguagePinyinConfigView;
+ input_method_config_view_map_["hangul"] = CreateLanguageHangulConfigView;
+ input_method_config_view_map_["pinyin"] = CreateLanguagePinyinConfigView;
+
+ // TODO(yusukes): Enable the following two mappings when ibus-mozc starts
+ // supporting IBus style configs.
+ // input_method_config_view_map_["mozc"] = CreateLanguageMozcConfigView;
+ // input_method_config_view_map_["mozc-jp"] = CreateLanguageMozcConfigView;
}
void LanguageConfigView::InitInputMethodIdMaps() {
diff --git a/chrome/browser/chromeos/options/language_hangul_config_view.cc b/chrome/browser/chromeos/options/language_hangul_config_view.cc
index 52e3aa6..0b0d82b 100644
--- a/chrome/browser/chromeos/options/language_hangul_config_view.cc
+++ b/chrome/browser/chromeos/options/language_hangul_config_view.cc
@@ -109,8 +109,8 @@ std::wstring LanguageHangulConfigView::GetWindowTitle() const {
gfx::Size LanguageHangulConfigView::GetPreferredSize() {
// TODO(satorux): Create our own localized content size once the UI is done.
return gfx::Size(views::Window::GetLocalizedContentsSize(
- IDS_FONTSLANG_DIALOG_WIDTH_CHARS,
- IDS_FONTSLANG_DIALOG_HEIGHT_LINES));
+ IDS_LANGUAGES_INPUT_DIALOG_WIDTH_CHARS,
+ IDS_LANGUAGES_INPUT_DIALOG_HEIGHT_LINES));
}
void LanguageHangulConfigView::InitControlLayout() {
diff --git a/chrome/browser/chromeos/options/language_hangul_config_view.h b/chrome/browser/chromeos/options/language_hangul_config_view.h
index a4c21d3..f0c9115 100644
--- a/chrome/browser/chromeos/options/language_hangul_config_view.h
+++ b/chrome/browser/chromeos/options/language_hangul_config_view.h
@@ -18,7 +18,8 @@
namespace chromeos {
class HangulKeyboardComboboxModel;
-// A dialog box for showing a password textfield.
+
+// A dialog box for showing Korean input method preferences.
class LanguageHangulConfigView : public views::Combobox::Listener,
public views::DialogDelegate,
public OptionsPageView {
diff --git a/chrome/browser/chromeos/options/language_mozc_config_view.cc b/chrome/browser/chromeos/options/language_mozc_config_view.cc
new file mode 100644
index 0000000..0d83aba
--- /dev/null
+++ b/chrome/browser/chromeos/options/language_mozc_config_view.cc
@@ -0,0 +1,217 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/options/language_mozc_config_view.h"
+
+#include "app/combobox_model.h"
+#include "app/l10n_util.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/common/notification_type.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/browser/chromeos/cros/cros_library.h"
+#include "chrome/browser/chromeos/preferences.h"
+#include "chrome/browser/profile.h"
+#include "grit/generated_resources.h"
+#include "grit/locale_settings.h"
+#include "views/grid_layout.h"
+#include "views/standard_layout.h"
+#include "views/window/window.h"
+
+namespace chromeos {
+
+// The combobox model for Mozc Japanese input method prefs.
+class MozcComboboxModel : public ComboboxModel {
+ public:
+ explicit MozcComboboxModel(const MozcMultipleChoicePreference* pref_data)
+ : pref_data_(pref_data), num_items_(0) {
+ // Check how many items are defined in the |pref_data->values_and_ids|
+ // array.
+ for (size_t i = 0; i < MozcMultipleChoicePreference::kMaxItems; ++i) {
+ if ((pref_data_->values_and_ids)[i].ibus_config_value == NULL) {
+ break;
+ }
+ ++num_items_;
+ }
+ }
+
+ // Implements ComboboxModel interface.
+ virtual int GetItemCount() {
+ return num_items_;
+ }
+
+ // Implements ComboboxModel interface.
+ virtual std::wstring GetItemAt(int index) {
+ if (index < 0 || index >= num_items_) {
+ LOG(ERROR) << "Index is out of bounds: " << index;
+ return L"";
+ }
+ const int message_id = (pref_data_->values_and_ids)[index].item_message_id;
+ return l10n_util::GetString(message_id);
+ }
+
+ // Gets a label for the combobox like "Input mode". This function is NOT part
+ // of the ComboboxModel interface.
+ std::wstring GetLabel() const {
+ return l10n_util::GetString(pref_data_->label_message_id);
+ }
+
+ // Gets a config value for the ibus configuration daemon (e.g. "KUTEN_TOUTEN",
+ // "KUTEN_PERIOD", ..) for an item at zero-origin |index|. This function is
+ // NOT part of the ComboboxModel interface.
+ std::wstring GetConfigValueAt(int index) const {
+ if (index < 0 || index >= num_items_) {
+ LOG(ERROR) << "Index is out of bounds: " << index;
+ return L"";
+ }
+ return UTF8ToWide((pref_data_->values_and_ids)[index].ibus_config_value);
+ }
+
+ // Gets an index (>= 0) of an item such that GetConfigValueAt(index) is equal
+ // to the |config_value|. Returns -1 if such item is not found. This function
+ // is NOT part of the ComboboxModel interface.
+ int GetIndexFromConfigValue(const std::wstring& config_value) const {
+ for (int i = 0; i < num_items_; ++i) {
+ if (GetConfigValueAt(i) == config_value) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ private:
+ const MozcMultipleChoicePreference* pref_data_;
+ int num_items_;
+
+ DISALLOW_COPY_AND_ASSIGN(MozcComboboxModel);
+};
+
+// The combobox for the dialog which has minimum width.
+class MozcCombobox : public views::Combobox {
+ public:
+ explicit MozcCombobox(ComboboxModel* model) : Combobox(model) {
+ }
+
+ virtual gfx::Size GetPreferredSize() {
+ gfx::Size size = Combobox::GetPreferredSize();
+ if (size.width() < kMinComboboxWidth) {
+ size.set_width(kMinComboboxWidth);
+ }
+ return size;
+ }
+
+ private:
+ static const int kMinComboboxWidth = 100;
+
+ DISALLOW_COPY_AND_ASSIGN(MozcCombobox);
+};
+
+LanguageMozcConfigView::LanguageMozcConfigView(Profile* profile)
+ : OptionsPageView(profile), contents_(NULL) {
+ for (size_t i = 0; i < kNumMozcMultipleChoicePrefs; ++i) {
+ MozcPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i];
+ current.multiple_choice_pref.Init(
+ kMozcMultipleChoicePrefs[i].pref_name, profile->GetPrefs(), this);
+ current.combobox_model =
+ new MozcComboboxModel(&kMozcMultipleChoicePrefs[i]);
+ current.combobox = NULL;
+ }
+}
+
+LanguageMozcConfigView::~LanguageMozcConfigView() {
+ for (size_t i = 0; i < kNumMozcMultipleChoicePrefs; ++i) {
+ delete prefs_and_comboboxes_[i].combobox_model;
+ }
+}
+
+void LanguageMozcConfigView::ItemChanged(
+ views::Combobox* sender, int prev_index, int new_index) {
+ for (size_t i = 0; i < kNumMozcMultipleChoicePrefs; ++i) {
+ MozcPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i];
+ if (current.combobox == sender) {
+ const std::wstring config_value =
+ current.combobox_model->GetConfigValueAt(new_index);
+ LOG(INFO) << "Changing Mozc pref to " << config_value;
+ // Update the Chrome pref.
+ current.multiple_choice_pref.SetValue(config_value);
+ break;
+ }
+ }
+}
+
+void LanguageMozcConfigView::Layout() {
+ // Not sure why but this is needed to show contents in the dialog.
+ contents_->SetBounds(0, 0, width(), height());
+}
+
+std::wstring LanguageMozcConfigView::GetWindowTitle() const {
+ return l10n_util::GetString(
+ IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SETTINGS_TITLE);
+}
+
+gfx::Size LanguageMozcConfigView::GetPreferredSize() {
+ // TODO(satorux): Create our own localized content size once the UI is done.
+ return gfx::Size(views::Window::GetLocalizedContentsSize(
+ IDS_LANGUAGES_INPUT_DIALOG_WIDTH_CHARS,
+ IDS_LANGUAGES_INPUT_DIALOG_HEIGHT_LINES));
+}
+
+void LanguageMozcConfigView::InitControlLayout() {
+ using views::ColumnSet;
+ using views::GridLayout;
+
+ contents_ = new views::View;
+ AddChildView(contents_);
+
+ GridLayout* layout = new GridLayout(contents_);
+ layout->SetInsets(kPanelVertMargin, kPanelHorizMargin,
+ kPanelVertMargin, kPanelHorizMargin);
+ contents_->SetLayoutManager(layout);
+
+ const int kColumnSetId = 0;
+ ColumnSet* column_set = layout->AddColumnSet(kColumnSetId);
+ column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
+ GridLayout::USE_PREF, 0, 0);
+ column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
+ column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
+ GridLayout::USE_PREF, 0, 0);
+
+ for (size_t i = 0; i < kNumMozcMultipleChoicePrefs; ++i) {
+ MozcPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i];
+ current.combobox = new MozcCombobox(current.combobox_model);
+ current.combobox->set_listener(this);
+ }
+ NotifyPrefChanged(); // Sync the comboboxes with current Chrome prefs.
+
+ // Show the comboboxes.
+ for (size_t i = 0; i < kNumMozcMultipleChoicePrefs; ++i) {
+ const MozcPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i];
+ layout->StartRow(0, kColumnSetId);
+ layout->AddView(new views::Label(current.combobox_model->GetLabel()));
+ layout->AddView(current.combobox);
+ }
+}
+
+void LanguageMozcConfigView::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ if (type == NotificationType::PREF_CHANGED) {
+ NotifyPrefChanged();
+ }
+}
+
+void LanguageMozcConfigView::NotifyPrefChanged() {
+ // Update comboboxes.
+ // TODO(yusukes): We don't have to update all UI controls.
+ for (size_t i = 0; i < kNumMozcMultipleChoicePrefs; ++i) {
+ MozcPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i];
+ const std::wstring value = current.multiple_choice_pref.GetValue();
+ const int combo_index =
+ current.combobox_model->GetIndexFromConfigValue(value);
+ if (combo_index >= 0) {
+ current.combobox->SetSelectedItem(combo_index);
+ }
+ }
+}
+
+} // namespace chromeos
diff --git a/chrome/browser/chromeos/options/language_mozc_config_view.h b/chrome/browser/chromeos/options/language_mozc_config_view.h
new file mode 100644
index 0000000..a89ea7b
--- /dev/null
+++ b/chrome/browser/chromeos/options/language_mozc_config_view.h
@@ -0,0 +1,71 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_OPTIONS_LANGUAGE_MOZC_CONFIG_VIEW_H_
+#define CHROME_BROWSER_CHROMEOS_OPTIONS_LANGUAGE_MOZC_CONFIG_VIEW_H_
+
+#include <string>
+
+#include "base/scoped_ptr.h"
+#include "chrome/browser/chromeos/cros/language_library.h"
+#include "chrome/browser/chromeos/language_preferences.h"
+#include "chrome/browser/pref_member.h"
+#include "chrome/browser/views/options/options_page_view.h"
+#include "views/controls/combobox/combobox.h"
+#include "views/controls/label.h"
+#include "views/window/dialog_delegate.h"
+
+namespace chromeos {
+
+class MozcCombobox;
+class MozcComboboxModel;
+
+// A dialog box for showing Mozc (Japanese input method) preferences.
+class LanguageMozcConfigView : public views::Combobox::Listener,
+ public views::DialogDelegate,
+ public OptionsPageView {
+ public:
+ explicit LanguageMozcConfigView(Profile* profile);
+ virtual ~LanguageMozcConfigView();
+
+ // views::Combobox::Listener overrides.
+ virtual void ItemChanged(views::Combobox* sender,
+ int prev_index,
+ int new_index);
+
+ // views::DialogDelegate overrides.
+ virtual bool IsModal() const { return true; }
+ virtual views::View* GetContentsView() { return this; }
+ virtual std::wstring GetWindowTitle() const;
+
+ // views::View overrides.
+ virtual void Layout();
+ virtual gfx::Size GetPreferredSize();
+
+ // OptionsPageView overrides.
+ virtual void InitControlLayout();
+
+ // NotificationObserver overrides.
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
+ private:
+ // Updates the mozc keyboard combobox.
+ void NotifyPrefChanged();
+
+ views::View* contents_;
+
+ struct MozcPrefAndAssociatedCombobox {
+ StringPrefMember multiple_choice_pref;
+ MozcComboboxModel* combobox_model;
+ MozcCombobox* combobox;
+ } prefs_and_comboboxes_[kNumMozcMultipleChoicePrefs];
+
+ DISALLOW_COPY_AND_ASSIGN(LanguageMozcConfigView);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_OPTIONS_LANGUAGE_MOZC_CONFIG_VIEW_H_
diff --git a/chrome/browser/chromeos/options/language_pinyin_config_view.cc b/chrome/browser/chromeos/options/language_pinyin_config_view.cc
index c04e4c2..f14e2bb 100644
--- a/chrome/browser/chromeos/options/language_pinyin_config_view.cc
+++ b/chrome/browser/chromeos/options/language_pinyin_config_view.cc
@@ -56,8 +56,8 @@ std::wstring LanguagePinyinConfigView::GetWindowTitle() const {
gfx::Size LanguagePinyinConfigView::GetPreferredSize() {
// TODO(satorux): Create our own localized content size once the UI is done.
return gfx::Size(views::Window::GetLocalizedContentsSize(
- IDS_FONTSLANG_DIALOG_WIDTH_CHARS,
- IDS_FONTSLANG_DIALOG_HEIGHT_LINES));
+ IDS_LANGUAGES_INPUT_DIALOG_WIDTH_CHARS,
+ IDS_LANGUAGES_INPUT_DIALOG_HEIGHT_LINES));
}
void LanguagePinyinConfigView::InitControlLayout() {
diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc
index 46e5ade..9055d23 100644
--- a/chrome/browser/chromeos/preferences.cc
+++ b/chrome/browser/chromeos/preferences.cc
@@ -34,11 +34,15 @@ void Preferences::RegisterUserPrefs(PrefService* prefs) {
kHangulKeyboardNameIDPairs[0].keyboard_id);
for (size_t i = 0; i < kNumPinyinBooleanPrefs; ++i) {
prefs->RegisterBooleanPref(kPinyinBooleanPrefs[i].pref_name,
- kPinyinBooleanPrefs[i].default_value);
+ kPinyinBooleanPrefs[i].default_pref_value);
}
for (size_t i = 0; i < kNumPinyinIntegerPrefs; ++i) {
prefs->RegisterIntegerPref(kPinyinIntegerPrefs[i].pref_name,
- kPinyinIntegerPrefs[i].default_value);
+ kPinyinIntegerPrefs[i].default_pref_value);
+ }
+ for (size_t i = 0; i < kNumMozcMultipleChoicePrefs; ++i) {
+ prefs->RegisterStringPref(kMozcMultipleChoicePrefs[i].pref_name,
+ kMozcMultipleChoicePrefs[i].default_pref_value);
}
}
@@ -62,6 +66,10 @@ void Preferences::Init(PrefService* prefs) {
language_pinyin_int_prefs_[i].Init(
kPinyinIntegerPrefs[i].pref_name, prefs, this);
}
+ for (size_t i = 0; i < kNumMozcMultipleChoicePrefs; ++i) {
+ language_mozc_multiple_choice_prefs_[i].Init(
+ kMozcMultipleChoicePrefs[i].pref_name, prefs, this);
+ }
// Initialize touchpad settings to what's saved in user preferences.
NotifyPrefChanged(NULL);
@@ -130,6 +138,14 @@ void Preferences::NotifyPrefChanged(const std::wstring* pref_name) {
language_pinyin_int_prefs_[i].GetValue());
}
}
+ for (size_t i = 0; i < kNumMozcMultipleChoicePrefs; ++i) {
+ if (!pref_name || *pref_name == kMozcMultipleChoicePrefs[i].pref_name) {
+ SetLanguageConfigString(
+ kMozcSectionName,
+ kMozcMultipleChoicePrefs[i].ibus_config_name,
+ language_mozc_multiple_choice_prefs_[i].GetValue());
+ }
+ }
}
void Preferences::SetTimeZone(const std::wstring& id) {
diff --git a/chrome/browser/chromeos/preferences.h b/chrome/browser/chromeos/preferences.h
index d4f9b81..418259a 100644
--- a/chrome/browser/chromeos/preferences.h
+++ b/chrome/browser/chromeos/preferences.h
@@ -89,6 +89,8 @@ class Preferences : public NotificationObserver {
StringPrefMember language_hangul_keyboard_;
BooleanPrefMember language_pinyin_boolean_prefs_[kNumPinyinBooleanPrefs];
IntegerPrefMember language_pinyin_int_prefs_[kNumPinyinIntegerPrefs];
+ StringPrefMember language_mozc_multiple_choice_prefs_[
+ kNumMozcMultipleChoicePrefs];
DISALLOW_COPY_AND_ASSIGN(Preferences);
};
diff --git a/chrome/browser/sync/glue/synchronized_preferences.h b/chrome/browser/sync/glue/synchronized_preferences.h
index 470e512..22cbdda 100644
--- a/chrome/browser/sync/glue/synchronized_preferences.h
+++ b/chrome/browser/sync/glue/synchronized_preferences.h
@@ -115,6 +115,12 @@ static const wchar_t* kSynchronizedPreferences[] = {
prefs::kLanguagePinyinShiftSelectCandidate,
prefs::kLanguagePinyinTradCandidate,
prefs::kLanguagePreloadEngines,
+ // TODO(yusukes): Add prefs for ibus-mozc (Japanese input method).
+ // prefs::kLanguageMozcPreeditMethod,
+ // prefs::kLanguageMozcSessionKeymap,
+ // prefs::kLanguageMozcPunctuationMethod,
+ // prefs::kLanguageMozcSymbolMethod,
+ //
// We don't sync the following IME prefs since they are not user-configurable
// (yet):
// prefs::kLanguageHotkeyNextEngineInMenu,
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 0112c0b..c1bc21c 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -466,6 +466,8 @@
'browser/chromeos/options/language_hangul_config_view.h',
'browser/chromeos/options/language_pinyin_config_view.cc',
'browser/chromeos/options/language_pinyin_config_view.h',
+ 'browser/chromeos/options/language_mozc_config_view.cc',
+ 'browser/chromeos/options/language_mozc_config_view.h',
'browser/chromeos/options/network_config_view.cc',
'browser/chromeos/options/network_config_view.h',
'browser/chromeos/options/options_window_view.cc',
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index caeb962..51eaa01 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -242,6 +242,18 @@ const wchar_t kLanguagePinyinDoublePinyinSchema[] =
L"settings.language.pinyin_double_pinyin_schema";
const wchar_t kLanguagePinyinLookupTablePageSize[] =
L"settings.language.pinyin_lookup_table_page_size";
+
+// A string prefs for ibus-mozc Japanese input method.
+// ibus-mozc converts the string values to protobuf enum values defined in
+// third_party/ibus-mozc/files/src/session/config.proto.
+const wchar_t kLanguageMozcPreeditMethod[] =
+ L"settings.language.mozc_preedit_method";
+const wchar_t kLanguageMozcSessionKeymap[] =
+ L"settings.language.mozc_sessoin_keymap";
+const wchar_t kLanguageMozcPunctuationMethod[] =
+ L"settings.language.mozc_punctuation_method";
+const wchar_t kLanguageMozcSymbolMethod[] =
+ L"settings.language.mozc_symbol_method";
#endif
// The disabled messages in IPC logging.
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 75600ed..9d84318 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -91,6 +91,10 @@ extern const wchar_t kLanguagePinyinInitFull[];
extern const wchar_t kLanguagePinyinInitFullPunct[];
extern const wchar_t kLanguagePinyinInitSimplifiedChinese[];
extern const wchar_t kLanguagePinyinTradCandidate[];
+extern const wchar_t kLanguageMozcPreeditMethod[];
+extern const wchar_t kLanguageMozcSessionKeymap[];
+extern const wchar_t kLanguageMozcPunctuationMethod[];
+extern const wchar_t kLanguageMozcSymbolMethod[];
#endif
extern const wchar_t kIpcDisabledMessages[];
extern const wchar_t kShowHomeButton[];