| Index: chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc
|
| diff --git a/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc b/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc
|
| index d2a9f317a36ff6a0a6fd5186f1c473bf09f0879a..ba65d6e641a76aae36fe10e220cc98507a004502 100644
|
| --- a/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc
|
| +++ b/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc
|
| @@ -33,12 +33,9 @@ namespace chromeos {
|
| namespace settings {
|
|
|
| KeyboardHandler::KeyboardHandler(content::WebUI* webui)
|
| - : profile_(Profile::FromWebUI(webui)) {
|
| - ui::DeviceDataManager::GetInstance()->AddObserver(this);
|
| -}
|
| + : profile_(Profile::FromWebUI(webui)), observer_(this) {}
|
|
|
| KeyboardHandler::~KeyboardHandler() {
|
| - ui::DeviceDataManager::GetInstance()->RemoveObserver(this);
|
| }
|
|
|
| void KeyboardHandler::RegisterMessages() {
|
| @@ -52,11 +49,20 @@ void KeyboardHandler::RegisterMessages() {
|
| base::Unretained(this)));
|
| }
|
|
|
| +void KeyboardHandler::OnJavascriptAllowed() {
|
| + observer_.Add(ui::DeviceDataManager::GetInstance());
|
| +}
|
| +
|
| +void KeyboardHandler::OnJavascriptDisallowed() {
|
| + observer_.RemoveAll();
|
| +}
|
| +
|
| void KeyboardHandler::OnKeyboardDeviceConfigurationChanged() {
|
| UpdateShowKeys();
|
| }
|
|
|
| void KeyboardHandler::HandleInitialize(const base::ListValue* args) {
|
| + AllowJavascript();
|
| UpdateShowKeys();
|
| }
|
|
|
| @@ -65,15 +71,14 @@ void KeyboardHandler::HandleShowKeyboardShortcutsOverlay(
|
| ash::Shell::GetInstance()->new_window_delegate()->ShowKeyboardOverlay();
|
| }
|
|
|
| -void KeyboardHandler::UpdateShowKeys() const {
|
| +void KeyboardHandler::UpdateShowKeys() {
|
| const base::FundamentalValue has_caps_lock(HasExternalKeyboard());
|
| const base::FundamentalValue has_diamond_key(
|
| base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| chromeos::switches::kHasChromeOSDiamondKey));
|
| - web_ui()->CallJavascriptFunction("cr.webUIListenerCallback",
|
| - base::StringValue("show-keys-changed"),
|
| - has_caps_lock,
|
| - has_diamond_key);
|
| + CallJavascriptFunction("cr.webUIListenerCallback",
|
| + base::StringValue("show-keys-changed"), has_caps_lock,
|
| + has_diamond_key);
|
| }
|
|
|
| } // namespace settings
|
|
|