Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DEVICE_KEYBOARD_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DEVICE_KEYBOARD_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DEVICE_KEYBOARD_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DEVICE_KEYBOARD_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/scoped_observer.h" | |
| 9 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" | 10 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" |
| 10 #include "ui/events/devices/input_device_event_observer.h" | 11 #include "ui/events/devices/input_device_event_observer.h" |
| 11 | 12 |
| 12 namespace base { | 13 namespace base { |
| 13 class ListValue; | 14 class ListValue; |
| 14 } | 15 } |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 class WebUI; | 18 class WebUI; |
| 18 } | 19 } |
| 19 | 20 |
| 21 namespace ui { | |
| 22 class DeviceDataManager; | |
| 23 } | |
| 24 | |
| 20 class Profile; | 25 class Profile; |
| 21 | 26 |
| 22 namespace chromeos { | 27 namespace chromeos { |
| 23 namespace settings { | 28 namespace settings { |
| 24 | 29 |
| 25 // Chrome OS "Keyboard" settings page UI handler. | 30 // Chrome OS "Keyboard" settings page UI handler. |
| 26 class KeyboardHandler | 31 class KeyboardHandler |
| 27 : public ::settings::SettingsPageUIHandler, | 32 : public ::settings::SettingsPageUIHandler, |
| 28 public ui::InputDeviceEventObserver { | 33 public ui::InputDeviceEventObserver { |
| 29 public: | 34 public: |
| 30 explicit KeyboardHandler(content::WebUI* webui); | 35 explicit KeyboardHandler(content::WebUI* webui); |
| 31 ~KeyboardHandler() override; | 36 ~KeyboardHandler() override; |
| 32 | 37 |
| 33 // SettingsPageUIHandler implementation. | 38 // SettingsPageUIHandler implementation. |
| 34 void RegisterMessages() override; | 39 void RegisterMessages() override; |
| 40 void OnJavascriptAllowed() override; | |
| 41 void OnJavascriptDisallowed() override; | |
|
michaelpg
2016/05/11 17:31:21
if Allowed has been called, will Disallowed always
tommycli
2016/05/11 17:32:44
No.
I wish I could make it always be called, but
Dan Beam
2016/05/11 17:33:48
not currently. thought it *might* if we start to
Dan Beam
2016/05/11 17:34:06
though it might*
| |
| 35 | 42 |
| 36 // ui::InputDeviceEventObserver implementation. | 43 // ui::InputDeviceEventObserver implementation. |
| 37 void OnKeyboardDeviceConfigurationChanged() override; | 44 void OnKeyboardDeviceConfigurationChanged() override; |
| 38 | 45 |
| 39 private: | 46 private: |
| 40 // Initializes the page with the current keyboard information. | 47 // Initializes the page with the current keyboard information. |
| 41 void HandleInitialize(const base::ListValue* args); | 48 void HandleInitialize(const base::ListValue* args); |
| 42 | 49 |
| 43 // Shows the Ash keyboard shortcuts overlay. | 50 // Shows the Ash keyboard shortcuts overlay. |
| 44 void HandleShowKeyboardShortcutsOverlay(const base::ListValue* args) const; | 51 void HandleShowKeyboardShortcutsOverlay(const base::ListValue* args) const; |
| 45 | 52 |
| 46 // Shows or hides the Caps Lock and Diamond key settings based on whether the | 53 // Shows or hides the Caps Lock and Diamond key settings based on whether the |
| 47 // system status. | 54 // system status. |
| 48 void UpdateShowKeys() const; | 55 void UpdateShowKeys(); |
| 49 | 56 |
| 50 Profile* profile_; // Weak pointer. | 57 Profile* profile_; // Weak pointer. |
| 51 | 58 |
| 59 ScopedObserver<ui::DeviceDataManager, KeyboardHandler> observer_; | |
|
michaelpg
2016/05/11 17:31:21
the OnJavascriptAllowed/Disallowed stuff is great.
tommycli
2016/05/11 17:32:44
The only reason I had to change it: OnJavascriptDi
tommycli
2016/05/11 17:35:20
(If I don't have a ScopedObserver, since OnJavascr
Dan Beam
2016/05/11 17:35:22
this sugar is less error-prone as well
| |
| 60 | |
| 52 DISALLOW_COPY_AND_ASSIGN(KeyboardHandler); | 61 DISALLOW_COPY_AND_ASSIGN(KeyboardHandler); |
| 53 }; | 62 }; |
| 54 | 63 |
| 55 } // namespace settings | 64 } // namespace settings |
| 56 } // namespace chromeos | 65 } // namespace chromeos |
| 57 | 66 |
| 58 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DEVICE_KEYBOARD_HANDLER_H_ | 67 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DEVICE_KEYBOARD_HANDLER_H_ |
| OLD | NEW |