OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "ash/new_window_delegate.h" | 9 #include "ash/new_window_delegate.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 } | 148 } |
149 localized_strings->Set(kDataValuesNames[i], list_value); | 149 localized_strings->Set(kDataValuesNames[i], list_value); |
150 } | 150 } |
151 } | 151 } |
152 | 152 |
153 void KeyboardHandler::InitializePage() { | 153 void KeyboardHandler::InitializePage() { |
154 bool has_diamond_key = base::CommandLine::ForCurrentProcess()->HasSwitch( | 154 bool has_diamond_key = base::CommandLine::ForCurrentProcess()->HasSwitch( |
155 chromeos::switches::kHasChromeOSDiamondKey); | 155 chromeos::switches::kHasChromeOSDiamondKey); |
156 const base::FundamentalValue show_diamond_key_options(has_diamond_key); | 156 const base::FundamentalValue show_diamond_key_options(has_diamond_key); |
157 | 157 |
158 web_ui()->CallJavascriptFunction( | 158 web_ui()->CallJavascriptFunctionUnsafe( |
159 "options.KeyboardOverlay.showDiamondKeyOptions", | 159 "options.KeyboardOverlay.showDiamondKeyOptions", |
160 show_diamond_key_options); | 160 show_diamond_key_options); |
161 | 161 |
162 UpdateCapsLockOptions(); | 162 UpdateCapsLockOptions(); |
163 } | 163 } |
164 | 164 |
165 void KeyboardHandler::RegisterMessages() { | 165 void KeyboardHandler::RegisterMessages() { |
166 // Callback to show keyboard overlay. | 166 // Callback to show keyboard overlay. |
167 web_ui()->RegisterMessageCallback( | 167 web_ui()->RegisterMessageCallback( |
168 "showKeyboardShortcuts", | 168 "showKeyboardShortcuts", |
169 base::Bind(&KeyboardHandler::HandleShowKeyboardShortcuts, | 169 base::Bind(&KeyboardHandler::HandleShowKeyboardShortcuts, |
170 base::Unretained(this))); | 170 base::Unretained(this))); |
171 } | 171 } |
172 | 172 |
173 void KeyboardHandler::OnKeyboardDeviceConfigurationChanged() { | 173 void KeyboardHandler::OnKeyboardDeviceConfigurationChanged() { |
174 UpdateCapsLockOptions(); | 174 UpdateCapsLockOptions(); |
175 } | 175 } |
176 | 176 |
177 void KeyboardHandler::HandleShowKeyboardShortcuts(const base::ListValue* args) { | 177 void KeyboardHandler::HandleShowKeyboardShortcuts(const base::ListValue* args) { |
178 ash::Shell::GetInstance()->new_window_delegate()->ShowKeyboardOverlay(); | 178 ash::Shell::GetInstance()->new_window_delegate()->ShowKeyboardOverlay(); |
179 } | 179 } |
180 | 180 |
181 void KeyboardHandler::UpdateCapsLockOptions() const { | 181 void KeyboardHandler::UpdateCapsLockOptions() const { |
182 const base::FundamentalValue show_caps_lock_options(HasExternalKeyboard()); | 182 const base::FundamentalValue show_caps_lock_options(HasExternalKeyboard()); |
183 web_ui()->CallJavascriptFunction( | 183 web_ui()->CallJavascriptFunctionUnsafe( |
184 "options.KeyboardOverlay.showCapsLockOptions", | 184 "options.KeyboardOverlay.showCapsLockOptions", show_caps_lock_options); |
185 show_caps_lock_options); | |
186 } | 185 } |
187 | 186 |
188 } // namespace options | 187 } // namespace options |
189 } // namespace chromeos | 188 } // namespace chromeos |
OLD | NEW |