summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/chromeos/language_preferences.h19
-rw-r--r--chrome/browser/chromeos/language_preferences_unittest.cc4
-rw-r--r--chrome/browser/chromeos/options/language_config_model.h2
-rw-r--r--chrome/browser/chromeos/options/system_page_view.cc47
-rw-r--r--chrome/browser/chromeos/preferences.cc32
-rw-r--r--chrome/browser/chromeos/preferences.h1
6 files changed, 100 insertions, 5 deletions
diff --git a/chrome/browser/chromeos/language_preferences.h b/chrome/browser/chromeos/language_preferences.h
index 1882a37..6e24e0c 100644
--- a/chrome/browser/chromeos/language_preferences.h
+++ b/chrome/browser/chromeos/language_preferences.h
@@ -94,6 +94,25 @@ const LanguageIntegerRangePreference kChewingIntegerPrefs[] = {
};
const size_t kNumChewingIntegerPrefs = ARRAYSIZE_UNSAFE(kChewingIntegerPrefs);
+// Temporary solution for crosbug.com/2636. We'll implement a complete dialog
+// using DOMUI later.
+enum RemapType {
+ kNoRemap = 0,
+ kSwapCtrlAndAlt = 1,
+ kSwapSearchAndCtrl = 2,
+};
+const LanguageMultipleChoicePreference<int> kXkbModifierMultipleChoicePrefs = {
+ prefs::kLanguageXkbModifierRemap,
+ kNoRemap,
+ "dummy", // does not use the ibus configuration service.
+ {{ kNoRemap, IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_MODIFIER_NO_REMAP },
+ { kSwapCtrlAndAlt,
+ IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_MODIFIER_REMAP_CTRL_ALT },
+ { kSwapSearchAndCtrl,
+ IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_MODIFIER_REMAP_SEARCH_CTRL }},
+ 0, // does not use the label.
+};
+
const LanguageMultipleChoicePreference<const char*>
kChewingMultipleChoicePrefs[] = {
{ prefs::kLanguageChewingKeyboardType,
diff --git a/chrome/browser/chromeos/language_preferences_unittest.cc b/chrome/browser/chromeos/language_preferences_unittest.cc
index 49c5472..d941e72 100644
--- a/chrome/browser/chromeos/language_preferences_unittest.cc
+++ b/chrome/browser/chromeos/language_preferences_unittest.cc
@@ -101,6 +101,8 @@ TEST(LanguagePreferencesTest, TestDefaultValuesOfMultipleChoicePrefs) {
EXPECT_TRUE(CheckDefaultValueOfMultipleChoicePrefs(
kChewingMultipleChoicePrefs, kNumChewingMultipleChoicePrefs));
EXPECT_TRUE(CheckDefaultValueOfMultipleChoicePrefs(
+ &kXkbModifierMultipleChoicePrefs, 1));
+ EXPECT_TRUE(CheckDefaultValueOfMultipleChoicePrefs(
&kChewingHsuSelKeyType, 1));
EXPECT_TRUE(CheckDefaultValueOfMultipleChoicePrefs(
&kPinyinDoublePinyinSchema, 1));
@@ -114,6 +116,8 @@ TEST(LanguagePreferencesTest, TestDuplicationOfMultipleChoicePrefs) {
EXPECT_TRUE(CheckDuplicationOfMultipleChoicePrefs(
kChewingMultipleChoicePrefs, kNumChewingMultipleChoicePrefs));
EXPECT_TRUE(CheckDuplicationOfMultipleChoicePrefs(
+ &kXkbModifierMultipleChoicePrefs, 1));
+ EXPECT_TRUE(CheckDuplicationOfMultipleChoicePrefs(
&kChewingHsuSelKeyType, 1));
EXPECT_TRUE(CheckDuplicationOfMultipleChoicePrefs(
&kPinyinDoublePinyinSchema, 1));
diff --git a/chrome/browser/chromeos/options/language_config_model.h b/chrome/browser/chromeos/options/language_config_model.h
index 7084291..5a842f4 100644
--- a/chrome/browser/chromeos/options/language_config_model.h
+++ b/chrome/browser/chromeos/options/language_config_model.h
@@ -22,7 +22,7 @@ namespace chromeos {
// The combobox model is used for adding languages in the language config
// view.
-class AddLanguageComboboxModel : public LanguageComboboxModel {
+class AddLanguageComboboxModel : public ::LanguageComboboxModel {
public:
AddLanguageComboboxModel(Profile* profile,
const std::vector<std::string>& locale_codes);
diff --git a/chrome/browser/chromeos/options/system_page_view.cc b/chrome/browser/chromeos/options/system_page_view.cc
index f074889..e4a97d5 100644
--- a/chrome/browser/chromeos/options/system_page_view.cc
+++ b/chrome/browser/chromeos/options/system_page_view.cc
@@ -12,6 +12,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/system_library.h"
+#include "chrome/browser/chromeos/options/language_config_util.h"
#include "chrome/browser/chromeos/options/language_config_view.h"
#include "chrome/browser/chromeos/options/options_window_view.h"
#include "chrome/browser/pref_member.h"
@@ -349,7 +350,8 @@ void TouchpadSection::NotifyPrefChanged(const std::wstring* pref_name) {
// TextInput section for text input settings.
class LanguageSection : public SettingsPageSection,
- public views::ButtonListener {
+ public views::ButtonListener,
+ public views::Combobox::Listener {
public:
explicit LanguageSection(Profile* profile);
virtual ~LanguageSection() {}
@@ -360,28 +362,49 @@ class LanguageSection : public SettingsPageSection,
};
// Overridden from SettingsPageSection:
virtual void InitContents(GridLayout* layout);
+ void NotifyPrefChanged(const std::wstring* pref_name);
// Overridden from views::ButtonListener:
virtual void ButtonPressed(views::Button* sender,
const views::Event& event);
+ // Overridden from views::Combobox::Listener:
+ virtual void ItemChanged(views::Combobox* sender,
+ int prev_index,
+ int new_index);
+
+ IntegerPrefMember xkb_pref_;
+ views::Combobox* xkb_modifier_combobox_;
+ chromeos::LanguageComboboxModel<int> xkb_modifier_combobox_model_;
+
DISALLOW_COPY_AND_ASSIGN(LanguageSection);
};
LanguageSection::LanguageSection(Profile* profile)
: SettingsPageSection(profile,
- IDS_OPTIONS_SETTINGS_SECTION_TITLE_LANGUAGE) {
+ IDS_OPTIONS_SETTINGS_SECTION_TITLE_LANGUAGE),
+ xkb_modifier_combobox_(NULL),
+ xkb_modifier_combobox_model_(&kXkbModifierMultipleChoicePrefs) {
+ xkb_pref_.Init(prefs::kLanguageXkbModifierRemap, profile->GetPrefs(), this);
}
void LanguageSection::InitContents(GridLayout* layout) {
- // Add the customize button.
- layout->StartRow(0, single_column_view_set_id());
+ // Add the customize button and XKB combobox.
+ layout->StartRow(0, double_column_view_set_id());
views::NativeButton* customize_languages_button = new views::NativeButton(
this,
l10n_util::GetString(IDS_OPTIONS_SETTINGS_LANGUAGES_CUSTOMIZE));
customize_languages_button->set_tag(kCustomizeLanguagesButton);
layout->AddView(customize_languages_button, 1, 1,
GridLayout::LEADING, GridLayout::CENTER);
+
+ xkb_modifier_combobox_ = new views::Combobox(&xkb_modifier_combobox_model_);
+ xkb_modifier_combobox_->set_listener(this);
+ // Initialize the combobox to what's saved in user preferences. Otherwise,
+ // ItemChanged() will be called with |new_index| == 0.
+ NotifyPrefChanged(NULL);
+
+ layout->AddView(xkb_modifier_combobox_);
layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing);
}
@@ -392,6 +415,22 @@ void LanguageSection::ButtonPressed(
}
}
+void LanguageSection::ItemChanged(views::Combobox* sender,
+ int prev_index,
+ int new_index) {
+ LOG(INFO) << "Changing XKB modofier pref to " << new_index;
+ xkb_pref_.SetValue(new_index);
+}
+
+void LanguageSection::NotifyPrefChanged(const std::wstring* pref_name) {
+ if (!pref_name || *pref_name == prefs::kLanguageXkbModifierRemap) {
+ const int id = xkb_pref_.GetValue();
+ if (id >= 0) {
+ xkb_modifier_combobox_->SetSelectedItem(id);
+ }
+ }
+}
+
///////////////////////////////////////////////////////////////////////////////
// AccessibilitySection
diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc
index 7a993d9..d5cbcd1 100644
--- a/chrome/browser/chromeos/preferences.cc
+++ b/chrome/browser/chromeos/preferences.cc
@@ -8,6 +8,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
+#include "chrome/browser/chromeos/cros/keyboard_library.h"
#include "chrome/browser/chromeos/cros/input_method_library.h"
#include "chrome/browser/chromeos/cros/synaptics_library.h"
#include "chrome/browser/chromeos/input_method/input_method_util.h"
@@ -83,6 +84,9 @@ void Preferences::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterIntegerPref(kMozcIntegerPrefs[i].pref_name,
kMozcIntegerPrefs[i].default_pref_value);
}
+ prefs->RegisterIntegerPref(
+ kXkbModifierMultipleChoicePrefs.pref_name,
+ kXkbModifierMultipleChoicePrefs.default_pref_value);
}
void Preferences::Init(PrefService* prefs) {
@@ -137,6 +141,8 @@ void Preferences::Init(PrefService* prefs) {
language_mozc_integer_prefs_[i].Init(
kMozcIntegerPrefs[i].pref_name, prefs, this);
}
+ language_xkb_modifier_remap_.Init(
+ kXkbModifierMultipleChoicePrefs.pref_name, prefs, this);
std::string locale(g_browser_process->GetApplicationLocale());
// Add input methods based on the application locale when the user first
@@ -296,6 +302,32 @@ void Preferences::NotifyPrefChanged(const std::wstring* pref_name) {
language_mozc_integer_prefs_[i].GetValue());
}
}
+ if (!pref_name || *pref_name == kXkbModifierMultipleChoicePrefs.pref_name) {
+ chromeos::ModifierMap modifier_map;
+ const int remap_type = language_xkb_modifier_remap_.GetValue();
+ switch (remap_type) {
+ default:
+ LOG(ERROR) << "Unknown XKB remapping type: " << remap_type;
+ /* fall through */
+ case kNoRemap:
+ modifier_map.push_back(ModifierKeyPair(kSearchKey, kSearchKey));
+ modifier_map.push_back(
+ ModifierKeyPair(kLeftControlKey, kLeftControlKey));
+ modifier_map.push_back(ModifierKeyPair(kLeftAltKey, kLeftAltKey));
+ break;
+ case kSwapCtrlAndAlt:
+ modifier_map.push_back(ModifierKeyPair(kSearchKey, kSearchKey));
+ modifier_map.push_back(ModifierKeyPair(kLeftControlKey, kLeftAltKey));
+ modifier_map.push_back(ModifierKeyPair(kLeftAltKey, kLeftControlKey));
+ break;
+ case kSwapSearchAndCtrl:
+ modifier_map.push_back(ModifierKeyPair(kSearchKey, kLeftControlKey));
+ modifier_map.push_back(ModifierKeyPair(kLeftControlKey, kSearchKey));
+ modifier_map.push_back(ModifierKeyPair(kLeftAltKey, kLeftAltKey));
+ break;
+ }
+ CrosLibrary::Get()->GetKeyboardLibrary()->RemapModifierKeys(modifier_map);
+ }
}
void Preferences::SetLanguageConfigBoolean(const char* section,
diff --git a/chrome/browser/chromeos/preferences.h b/chrome/browser/chromeos/preferences.h
index ba385dc..60aa75e 100644
--- a/chrome/browser/chromeos/preferences.h
+++ b/chrome/browser/chromeos/preferences.h
@@ -100,6 +100,7 @@ class Preferences : public NotificationObserver {
StringPrefMember language_mozc_multiple_choice_prefs_[
kNumMozcMultipleChoicePrefs];
IntegerPrefMember language_mozc_integer_prefs_[kNumMozcIntegerPrefs];
+ IntegerPrefMember language_xkb_modifier_remap_;
DISALLOW_COPY_AND_ASSIGN(Preferences);
};