Commit 99c6cbea authored by yusukes@google.com's avatar yusukes@google.com

Rename chromeos::input_method::kLeftControl to chromeos::input_method::kControl.

The new name would be better since we support remapping the right control key. Do the same for chromeos::input_method::kLeftAlt.

This cleanup is for issue 115112.

BUG=115112
TEST=none
TBR=csilv@chromium.org

Review URL: https://chromiumcodereview.appspot.com/10416028

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138449 0039d316-1c4b-4281-b951-d872f2087c98
parent bd507a97
......@@ -42,8 +42,8 @@ const char kSetxkbmapCommand[] = "/usr/bin/setxkbmap";
// See the comment at ModifierKey in the .h file.
ModifierKey kCustomizableKeys[] = {
kSearchKey,
kLeftControlKey,
kLeftAltKey
kControlKey,
kAltKey
};
// A string for obtaining a mask value for Num Lock.
......@@ -325,10 +325,10 @@ std::string XKeyboardImpl::CreateFullXkbLayoutName(
case kSearchKey:
target = &use_search_key_as_str;
break;
case kLeftControlKey:
case kControlKey:
target = &use_left_control_key_as_str;
break;
case kLeftAltKey:
case kAltKey:
target = &use_left_alt_key_as_str;
break;
default:
......@@ -465,9 +465,9 @@ std::string XKeyboardImpl::ModifierKeyToString(ModifierKey key) {
switch (key) {
case kSearchKey:
return "search";
case kLeftControlKey:
case kControlKey:
return "leftcontrol";
case kLeftAltKey:
case kAltKey:
return "leftalt";
case kVoidKey:
return "disabled";
......
......@@ -29,8 +29,8 @@ enum ModifierLockStatus {
// TODO(yusukes): Remove this enum when crbug.com/115112 is implemented.
enum ModifierKey {
kSearchKey = 0, // Customizable.
kLeftControlKey, // Customizable.
kLeftAltKey, // Customizable.
kControlKey, // Customizable.
kAltKey, // Customizable.
kVoidKey,
kCapsLockKey,
// IMPORTANT: You should update kCustomizableKeys[] in .cc file, if you
......
......@@ -51,29 +51,29 @@ class XKeyboardTest : public testing::Test {
// Returns a ModifierMap object that contains the following mapping:
// - kSearchKey is mapped to |search|.
// - kLeftControl key is mapped to |control|.
// - kLeftAlt key is mapped to |alt|.
// - kControl key is mapped to |control|.
// - kAlt key is mapped to |alt|.
ModifierMap GetMap(ModifierKey search, ModifierKey control, ModifierKey alt) {
ModifierMap modifier_key;
// Use the Search key as |search|.
modifier_key.push_back(ModifierKeyPair(kSearchKey, search));
modifier_key.push_back(ModifierKeyPair(kLeftControlKey, control));
modifier_key.push_back(ModifierKeyPair(kLeftAltKey, alt));
modifier_key.push_back(ModifierKeyPair(kControlKey, control));
modifier_key.push_back(ModifierKeyPair(kAltKey, alt));
return modifier_key;
}
// Checks |modifier_map| and returns true if the following conditions are met:
// - kSearchKey is mapped to |search|.
// - kLeftControl key is mapped to |control|.
// - kLeftAlt key is mapped to |alt|.
// - kControl key is mapped to |control|.
// - kAlt key is mapped to |alt|.
bool CheckMap(const ModifierMap& modifier_map,
ModifierKey search, ModifierKey control, ModifierKey alt) {
ModifierMap::const_iterator begin = modifier_map.begin();
ModifierMap::const_iterator end = modifier_map.end();
if ((std::count(begin, end, ModifierKeyPair(kSearchKey, search)) == 1) &&
(std::count(begin, end,
ModifierKeyPair(kLeftControlKey, control)) == 1) &&
(std::count(begin, end, ModifierKeyPair(kLeftAltKey, alt)) == 1)) {
ModifierKeyPair(kControlKey, control)) == 1) &&
(std::count(begin, end, ModifierKeyPair(kAltKey, alt)) == 1)) {
return true;
}
return false;
......@@ -106,10 +106,10 @@ TEST_F(XKeyboardTest, TestCreateFullXkbLayoutNameBasic) {
tmp_map.push_back(ModifierKeyPair(kSearchKey, kVoidKey)); // two search maps
EXPECT_STREQ("", xkey_->CreateFullXkbLayoutName("us", tmp_map).c_str());
tmp_map = GetMap(kVoidKey, kVoidKey, kVoidKey);
tmp_map.push_back(ModifierKeyPair(kLeftControlKey, kVoidKey)); // two ctrls
tmp_map.push_back(ModifierKeyPair(kControlKey, kVoidKey)); // two ctrls
EXPECT_STREQ("", xkey_->CreateFullXkbLayoutName("us", tmp_map).c_str());
tmp_map = GetMap(kVoidKey, kVoidKey, kVoidKey);
tmp_map.push_back(ModifierKeyPair(kLeftAltKey, kVoidKey)); // two alts.
tmp_map.push_back(ModifierKeyPair(kAltKey, kVoidKey)); // two alts.
EXPECT_STREQ("", xkey_->CreateFullXkbLayoutName("us", tmp_map).c_str());
// CreateFullXkbLayoutName should not accept invalid ModifierMaps.
......@@ -182,10 +182,10 @@ TEST_F(XKeyboardTest, TestCreateFullXkbLayoutNameKeepCapsLock) {
GetMap(kVoidKey, kVoidKey, kVoidKey)).c_str());
EXPECT_STREQ("de(neo)+chromeos(search_leftcontrol_leftcontrol_keepralt)",
xkey_->CreateFullXkbLayoutName(
// The 1st kLeftControlKey should be ignored.
"de(neo)", GetMap(kLeftControlKey,
kLeftControlKey,
kLeftControlKey)).c_str());
// The 1st kControlKey should be ignored.
"de(neo)", GetMap(kControlKey,
kControlKey,
kControlKey)).c_str());
EXPECT_STREQ("gb(extd)+chromeos(disabled_disabled_disabled_keepralt)",
xkey_->CreateFullXkbLayoutName(
"gb(extd)",
......@@ -199,9 +199,9 @@ TEST_F(XKeyboardTest, TestCreateFullXkbLayoutNameKeepAlt) {
EXPECT_STREQ("kr(kr104)+"
"chromeos(leftcontrol_leftcontrol_leftcontrol_keepralt)",
xkey_->CreateFullXkbLayoutName(
"kr(kr104)", GetMap(kLeftControlKey,
kLeftControlKey,
kLeftControlKey)).c_str());
"kr(kr104)", GetMap(kControlKey,
kControlKey,
kControlKey)).c_str());
}
// Tests if CreateFullXkbLayoutName and ExtractLayoutNameFromFullXkbLayoutName
......
......@@ -217,10 +217,10 @@ void Preferences::RegisterUserPrefs(PrefService* prefs) {
input_method::kSearchKey,
PrefService::SYNCABLE_PREF);
prefs->RegisterIntegerPref(prefs::kLanguageXkbRemapControlKeyTo,
input_method::kLeftControlKey,
input_method::kControlKey,
PrefService::SYNCABLE_PREF);
prefs->RegisterIntegerPref(prefs::kLanguageXkbRemapAltKeyTo,
input_method::kLeftAltKey,
input_method::kAltKey,
PrefService::SYNCABLE_PREF);
// We don't sync the following keyboard prefs since they are not user-
// configurable.
......@@ -678,11 +678,11 @@ void Preferences::UpdateModifierKeyMapping() {
input_method::ModifierKey(search_remap)));
modifier_map.push_back(
input_method::ModifierKeyPair(
input_method::kLeftControlKey,
input_method::kControlKey,
input_method::ModifierKey(control_remap)));
modifier_map.push_back(
input_method::ModifierKeyPair(
input_method::kLeftAltKey,
input_method::kAltKey,
input_method::ModifierKey(alt_remap)));
input_method_manager_->GetXKeyboard()->RemapModifierKeys(modifier_map);
} else {
......
......@@ -47,8 +47,8 @@ struct ModifierToLabel {
const char* label;
} kModifierToLabels[] = {
{chromeos::input_method::kSearchKey, "search"},
{chromeos::input_method::kLeftControlKey, "ctrl"},
{chromeos::input_method::kLeftAltKey, "alt"},
{chromeos::input_method::kControlKey, "ctrl"},
{chromeos::input_method::kAltKey, "alt"},
{chromeos::input_method::kVoidKey, "disabled"},
{chromeos::input_method::kCapsLockKey, "caps lock"},
};
......@@ -288,10 +288,9 @@ void KeyboardOverlayHandler::GetLabelMap(const ListValue* args) {
ModifierMap modifier_map;
modifier_map[chromeos::input_method::kSearchKey] = static_cast<ModifierKey>(
pref_service->GetInteger(prefs::kLanguageXkbRemapSearchKeyTo));
modifier_map[chromeos::input_method::kLeftControlKey] =
static_cast<ModifierKey>(
pref_service->GetInteger(prefs::kLanguageXkbRemapControlKeyTo));
modifier_map[chromeos::input_method::kLeftAltKey] = static_cast<ModifierKey>(
modifier_map[chromeos::input_method::kControlKey] = static_cast<ModifierKey>(
pref_service->GetInteger(prefs::kLanguageXkbRemapControlKeyTo));
modifier_map[chromeos::input_method::kAltKey] = static_cast<ModifierKey>(
pref_service->GetInteger(prefs::kLanguageXkbRemapAltKeyTo));
DictionaryValue dict;
......
......@@ -17,9 +17,9 @@ const struct ModifierKeysSelectItem {
{ IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_KEY_SEARCH,
chromeos::input_method::kSearchKey },
{ IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_KEY_LEFT_CTRL,
chromeos::input_method::kLeftControlKey },
chromeos::input_method::kControlKey },
{ IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_KEY_LEFT_ALT,
chromeos::input_method::kLeftAltKey },
chromeos::input_method::kAltKey },
{ IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_KEY_VOID,
chromeos::input_method::kVoidKey },
{ IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_KEY_CAPS_LOCK,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment