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