Chromium Code Reviews| Index: chrome/browser/resources/settings/device_page/device_page.js |
| diff --git a/chrome/browser/resources/settings/device_page/device_page.js b/chrome/browser/resources/settings/device_page/device_page.js |
| index f11e2a7db9cefbc6307500cdbc4327ad13c4ad2c..60361bed77ef3e810a10ade451ebcf873f575bbe 100644 |
| --- a/chrome/browser/resources/settings/device_page/device_page.js |
| +++ b/chrome/browser/resources/settings/device_page/device_page.js |
| @@ -9,6 +9,11 @@ |
| Polymer({ |
| is: 'settings-device-page', |
| + behaviors: [ |
| + I18nBehavior, |
| + WebUIListenerBehavior, |
| + ], |
| + |
| properties: { |
| /** The current active route. */ |
| currentRoute: { |
| @@ -21,14 +26,78 @@ Polymer({ |
| type: Object, |
| notify: true, |
| }, |
| + |
| + /** @private */ |
| + hasMouse_: { |
| + type: Boolean, |
| + value: false, |
| + }, |
| + |
| + /** @private */ |
| + hasTouchpad_: { |
| + type: Boolean, |
| + value: false, |
| + }, |
| + }, |
| + |
| + ready: function() { |
| + cr.addWebUIListener( |
| + 'has-mouse-changed', this.hasMouseChanged_.bind(this)); |
| + cr.addWebUIListener( |
| + 'has-touchpad-changed', this.hasTouchpadChanged_.bind(this)); |
| + settings.DevicePageBrowserProxyImpl.getInstance().initializePointers(); |
| + }, |
| + |
| + /** |
| + * Callback to set whether a mouse is connected. |
| + * @param {boolean} hasMouse |
| + * @private |
| + */ |
| + hasMouseChanged_: function(hasMouse) { |
| + this.hasMouse_ = hasMouse; |
| + }, |
| + |
| + /** |
| + * Callback to set whether a touchpad is connected. |
| + * @param {boolean} hasTouchpad |
| + * @private |
| + */ |
| + hasTouchpadChanged_: function(hasTouchpad) { |
| + this.hasTouchpad_ = hasTouchpad; |
| + }, |
|
stevenjb
2016/06/30 00:07:49
nit: Any reason not to just inline these two fairl
michaelpg
2016/07/09 04:11:30
Done.
|
| + |
| + /** |
| + * @return {string} |
| + * @private |
| + */ |
| + getPointersTitle_: function() { |
| + if (this.hasMouse_ && this.hasTouchpad_) |
| + return this.i18n('mouseAndTouchpadTitle'); |
| + if (this.hasMouse_) |
| + return this.i18n('mouseTitle'); |
| + if (this.hasTouchpad_) |
| + return this.i18n('touchpadTitle'); |
| + return ''; |
| + }, |
| + |
| + /** |
| + * @return {string} |
| + * @private |
| + */ |
| + getPointersIcon_: function() { |
| + if (this.hasMouse_) |
| + return 'settings:mouse'; |
| + if (this.hasTouchpad_) |
| + return 'settings:touch-app'; |
| + return ''; |
| }, |
| /** |
| - * Handler for tapping the Touchpad settings menu item. |
| + * Handler for tapping the mouse and touchpad settings menu item. |
| * @private |
| */ |
| - onTouchpadTap_: function() { |
| - this.$.pages.setSubpageChain(['touchpad']); |
| + onPointersTap_: function() { |
| + this.$.pages.setSubpageChain(['pointers']); |
| }, |
| /** |
| @@ -46,4 +115,12 @@ Polymer({ |
| onDisplayTap_: function() { |
| this.$.pages.setSubpageChain(['display']); |
| }, |
| + |
| + /** |
| + * @return {boolean} |
| + * @private |
| + */ |
| + showPointers_: function(hasMouse, hasTouchpad) { |
| + return hasMouse || hasTouchpad; |
| + }, |
| }); |