Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(559)

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/keyboard_handler.cc

Issue 11943009: Add diamond-key remapping support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make tests disabled. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/options/chromeos/keyboard_handler.h" 5 #include "chrome/browser/ui/webui/options/chromeos/keyboard_handler.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/chromeos/input_method/xkeyboard.h" 9 #include "chrome/browser/chromeos/input_method/xkeyboard.h"
10 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
(...skipping 16 matching lines...) Expand all
27 chromeos::input_method::kVoidKey }, 27 chromeos::input_method::kVoidKey },
28 { IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_CAPS_LOCK, 28 { IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_CAPS_LOCK,
29 chromeos::input_method::kCapsLockKey }, 29 chromeos::input_method::kCapsLockKey },
30 }; 30 };
31 31
32 const char* kDataValuesNames[] = { 32 const char* kDataValuesNames[] = {
33 "remapSearchKeyToValue", 33 "remapSearchKeyToValue",
34 "remapControlKeyToValue", 34 "remapControlKeyToValue",
35 "remapAltKeyToValue", 35 "remapAltKeyToValue",
36 "remapCapsLockKeyToValue", 36 "remapCapsLockKeyToValue",
37 "remapDiamondKeyToValue",
37 }; 38 };
38 } // namespace 39 } // namespace
39 40
40 namespace chromeos { 41 namespace chromeos {
41 namespace options { 42 namespace options {
42 43
43 KeyboardHandler::KeyboardHandler() { 44 KeyboardHandler::KeyboardHandler() {
44 } 45 }
45 46
46 KeyboardHandler::~KeyboardHandler() { 47 KeyboardHandler::~KeyboardHandler() {
47 } 48 }
48 49
49 void KeyboardHandler::GetLocalizedValues(DictionaryValue* localized_strings) { 50 void KeyboardHandler::GetLocalizedValues(DictionaryValue* localized_strings) {
50 DCHECK(localized_strings); 51 DCHECK(localized_strings);
51 52
52 localized_strings->SetString("keyboardOverlayTitle", 53 localized_strings->SetString("keyboardOverlayTitle",
53 l10n_util::GetStringUTF16(IDS_OPTIONS_KEYBOARD_OVERLAY_TITLE)); 54 l10n_util::GetStringUTF16(IDS_OPTIONS_KEYBOARD_OVERLAY_TITLE));
54 localized_strings->SetString("remapSearchKeyToContent", 55 localized_strings->SetString("remapSearchKeyToContent",
55 l10n_util::GetStringUTF16( 56 l10n_util::GetStringUTF16(
56 IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_SEARCH_LABEL)); 57 IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_SEARCH_LABEL));
57 localized_strings->SetString("remapControlKeyToContent", 58 localized_strings->SetString("remapControlKeyToContent",
58 l10n_util::GetStringUTF16( 59 l10n_util::GetStringUTF16(
59 IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_LEFT_CTRL_LABEL)); 60 IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_LEFT_CTRL_LABEL));
60 localized_strings->SetString("remapAltKeyToContent", 61 localized_strings->SetString("remapAltKeyToContent",
61 l10n_util::GetStringUTF16( 62 l10n_util::GetStringUTF16(
62 IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_LEFT_ALT_LABEL)); 63 IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_LEFT_ALT_LABEL));
63 localized_strings->SetString("remapCapsLockKeyToContent", 64 localized_strings->SetString("remapCapsLockKeyToContent",
64 l10n_util::GetStringUTF16( 65 l10n_util::GetStringUTF16(
65 IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_CAPS_LOCK_LABEL)); 66 IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_CAPS_LOCK_LABEL));
67 localized_strings->SetString("remapDiamondKeyToContent",
68 l10n_util::GetStringUTF16(
69 IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_DIAMOND_KEY_LABEL));
66 localized_strings->SetString("changeLanguageAndInputSettings", 70 localized_strings->SetString("changeLanguageAndInputSettings",
67 l10n_util::GetStringUTF16( 71 l10n_util::GetStringUTF16(
68 IDS_OPTIONS_SETTINGS_CHANGE_LANGUAGE_AND_INPUT_SETTINGS)); 72 IDS_OPTIONS_SETTINGS_CHANGE_LANGUAGE_AND_INPUT_SETTINGS));
69 73
70 for (size_t i = 0; i < arraysize(kDataValuesNames); ++i) { 74 for (size_t i = 0; i < arraysize(kDataValuesNames); ++i) {
71 ListValue* list_value = new ListValue(); 75 ListValue* list_value = new ListValue();
72 for (size_t j = 0; j < arraysize(kModifierKeysSelectItems); ++j) { 76 for (size_t j = 0; j < arraysize(kModifierKeysSelectItems); ++j) {
73 const input_method::ModifierKey value = 77 const input_method::ModifierKey value =
74 kModifierKeysSelectItems[j].value; 78 kModifierKeysSelectItems[j].value;
75 const int message_id = kModifierKeysSelectItems[j].message_id; 79 const int message_id = kModifierKeysSelectItems[j].message_id;
76 // Only the seach key can be remapped to the caps lock key. 80 // Only the seach key can be remapped to the caps lock key.
77 if (kDataValuesNames[i] != std::string("remapSearchKeyToValue") && 81 if (kDataValuesNames[i] != std::string("remapSearchKeyToValue") &&
78 kDataValuesNames[i] != std::string("remapCapsLockKeyToValue") && 82 kDataValuesNames[i] != std::string("remapCapsLockKeyToValue") &&
79 value == input_method::kCapsLockKey) { 83 value == input_method::kCapsLockKey) {
80 continue; 84 continue;
81 } 85 }
82 ListValue* option = new ListValue(); 86 ListValue* option = new ListValue();
83 option->Append(new base::FundamentalValue(value)); 87 option->Append(new base::FundamentalValue(value));
84 option->Append(new base::StringValue(l10n_util::GetStringUTF16( 88 option->Append(new base::StringValue(l10n_util::GetStringUTF16(
85 message_id))); 89 message_id)));
86 list_value->Append(option); 90 list_value->Append(option);
87 } 91 }
88 localized_strings->Set(kDataValuesNames[i], list_value); 92 localized_strings->Set(kDataValuesNames[i], list_value);
89 } 93 }
90 } 94 }
91 95
92 void KeyboardHandler::InitializePage() { 96 void KeyboardHandler::InitializePage() {
93 bool chromeos_keyboard = CommandLine::ForCurrentProcess()->HasSwitch( 97 bool chromeos_keyboard = CommandLine::ForCurrentProcess()->HasSwitch(
94 switches::kHasChromeOSKeyboard); 98 switches::kHasChromeOSKeyboard);
99 const base::FundamentalValue show_caps_lock_options(chromeos_keyboard);
95 100
96 const base::FundamentalValue show_options(true); 101 bool has_diamond_key = CommandLine::ForCurrentProcess()->HasSwitch(
102 switches::kHasChromeOSDiamondKey);
103 const base::FundamentalValue show_diamond_key_options(has_diamond_key);
97 104
98 if (!chromeos_keyboard) { 105 web_ui()->CallJavascriptFunction(
99 web_ui()->CallJavascriptFunction( 106 "options.KeyboardOverlay.showCapsLockOptions",
100 "options.KeyboardOverlay.showCapsLockOptions", show_options); 107 show_caps_lock_options);
101 } 108 web_ui()->CallJavascriptFunction(
109 "options.KeyboardOverlay.showDiamondKeyOptions",
110 show_diamond_key_options);
102 } 111 }
103 112
104 } // namespace options 113 } // namespace options
105 } // namespace chromeos 114 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698