Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / ui / webui / options / chromeos / keyboard_handler.cc
blobaeaf8baad5236fc0107f05faea54a9594385e580
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/webui/options/chromeos/keyboard_handler.h"
7 #include "base/command_line.h"
8 #include "base/values.h"
9 #include "chromeos/chromeos_switches.h"
10 #include "chromeos/ime/ime_keyboard.h"
11 #include "content/public/browser/web_ui.h"
12 #include "grit/generated_resources.h"
13 #include "ui/base/l10n/l10n_util.h"
15 namespace {
16 const struct ModifierKeysSelectItem {
17 int message_id;
18 chromeos::input_method::ModifierKey value;
19 } kModifierKeysSelectItems[] = {
20 { IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_SEARCH,
21 chromeos::input_method::kSearchKey },
22 { IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_LEFT_CTRL,
23 chromeos::input_method::kControlKey },
24 { IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_LEFT_ALT,
25 chromeos::input_method::kAltKey },
26 { IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_VOID,
27 chromeos::input_method::kVoidKey },
28 { IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_CAPS_LOCK,
29 chromeos::input_method::kCapsLockKey },
30 { IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_ESCAPE,
31 chromeos::input_method::kEscapeKey },
34 const char* kDataValuesNames[] = {
35 "remapSearchKeyToValue",
36 "remapControlKeyToValue",
37 "remapAltKeyToValue",
38 "remapCapsLockKeyToValue",
39 "remapDiamondKeyToValue",
41 } // namespace
43 namespace chromeos {
44 namespace options {
46 KeyboardHandler::KeyboardHandler() {
49 KeyboardHandler::~KeyboardHandler() {
52 void KeyboardHandler::GetLocalizedValues(
53 base::DictionaryValue* localized_strings) {
54 DCHECK(localized_strings);
56 localized_strings->SetString("keyboardOverlayTitle",
57 l10n_util::GetStringUTF16(IDS_OPTIONS_KEYBOARD_OVERLAY_TITLE));
58 localized_strings->SetString("remapSearchKeyToContent",
59 l10n_util::GetStringUTF16(
60 IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_SEARCH_LABEL));
61 localized_strings->SetString("remapControlKeyToContent",
62 l10n_util::GetStringUTF16(
63 IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_LEFT_CTRL_LABEL));
64 localized_strings->SetString("remapAltKeyToContent",
65 l10n_util::GetStringUTF16(
66 IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_LEFT_ALT_LABEL));
67 localized_strings->SetString("remapCapsLockKeyToContent",
68 l10n_util::GetStringUTF16(
69 IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_CAPS_LOCK_LABEL));
70 localized_strings->SetString("remapDiamondKeyToContent",
71 l10n_util::GetStringUTF16(
72 IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_DIAMOND_KEY_LABEL));
73 localized_strings->SetString("sendFunctionKeys",
74 l10n_util::GetStringUTF16(
75 IDS_OPTIONS_SETTINGS_LANGUAGES_SEND_FUNCTION_KEYS));
76 localized_strings->SetString("sendFunctionKeysDescription",
77 l10n_util::GetStringUTF16(
78 IDS_OPTIONS_SETTINGS_LANGUAGES_SEND_FUNCTION_KEYS_DESCRIPTION));
79 localized_strings->SetString("changeLanguageAndInputSettings",
80 l10n_util::GetStringUTF16(
81 IDS_OPTIONS_SETTINGS_CHANGE_LANGUAGE_AND_INPUT_SETTINGS));
83 for (size_t i = 0; i < arraysize(kDataValuesNames); ++i) {
84 base::ListValue* list_value = new base::ListValue();
85 for (size_t j = 0; j < arraysize(kModifierKeysSelectItems); ++j) {
86 const input_method::ModifierKey value =
87 kModifierKeysSelectItems[j].value;
88 const int message_id = kModifierKeysSelectItems[j].message_id;
89 // Only the seach key can be remapped to the caps lock key.
90 if (kDataValuesNames[i] != std::string("remapSearchKeyToValue") &&
91 kDataValuesNames[i] != std::string("remapCapsLockKeyToValue") &&
92 value == input_method::kCapsLockKey) {
93 continue;
95 base::ListValue* option = new base::ListValue();
96 option->Append(new base::FundamentalValue(value));
97 option->Append(new base::StringValue(l10n_util::GetStringUTF16(
98 message_id)));
99 list_value->Append(option);
101 localized_strings->Set(kDataValuesNames[i], list_value);
105 void KeyboardHandler::InitializePage() {
106 bool chromeos_keyboard = CommandLine::ForCurrentProcess()->HasSwitch(
107 chromeos::switches::kHasChromeOSKeyboard);
108 const base::FundamentalValue show_caps_lock_options(!chromeos_keyboard);
110 bool has_diamond_key = CommandLine::ForCurrentProcess()->HasSwitch(
111 chromeos::switches::kHasChromeOSDiamondKey);
112 const base::FundamentalValue show_diamond_key_options(has_diamond_key);
114 web_ui()->CallJavascriptFunction(
115 "options.KeyboardOverlay.showCapsLockOptions",
116 show_caps_lock_options);
117 web_ui()->CallJavascriptFunction(
118 "options.KeyboardOverlay.showDiamondKeyOptions",
119 show_diamond_key_options);
122 } // namespace options
123 } // namespace chromeos