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