| 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 /** | 5 /** |
| 6 * @fileoverview 'settings-device-page' is the settings page for device and | 6 * @fileoverview 'settings-device-page' is the settings page for device and |
| 7 * peripheral settings. | 7 * peripheral settings. |
| 8 */ | 8 */ |
| 9 Polymer({ | 9 Polymer({ |
| 10 is: 'settings-device-page', | 10 is: 'settings-device-page', |
| 11 | 11 |
| 12 behaviors: [ | 12 behaviors: [ |
| 13 I18nBehavior, | 13 I18nBehavior, |
| 14 WebUIListenerBehavior, | 14 WebUIListenerBehavior, |
| 15 settings.RouteObserverBehavior, | 15 settings.RouteObserverBehavior, |
| 16 ], | 16 ], |
| 17 | 17 |
| 18 properties: { | 18 properties: { |
| 19 /** Preferences state. */ | |
| 20 prefs: { | 19 prefs: { |
| 21 type: Object, | 20 type: Object, |
| 22 notify: true, | 21 notify: true, |
| 23 }, | 22 }, |
| 24 | 23 |
| 25 /** @private */ | 24 /** |
| 26 hasMouse_: { | 25 * |hasMouse_| and |hasTouchpad_| start undefined so observers don't trigger |
| 27 type: Boolean, | 26 * until both have been populated. |
| 28 value: false, | 27 * @private |
| 29 }, | 28 */ |
| 29 hasMouse_: Boolean, |
| 30 | 30 |
| 31 /** @private */ | 31 /** @private */ |
| 32 hasTouchpad_: { | 32 hasTouchpad_: Boolean, |
| 33 type: Boolean, | |
| 34 value: false, | |
| 35 }, | |
| 36 | 33 |
| 37 /** @private */ | 34 /** @private */ |
| 38 stylusAllowed_: { | 35 stylusAllowed_: { |
| 39 type: Boolean, | 36 type: Boolean, |
| 40 value: function() { | 37 value: function() { |
| 41 return loadTimeData.getBoolean('stylusAllowed'); | 38 return loadTimeData.getBoolean('stylusAllowed'); |
| 42 }, | 39 }, |
| 43 readOnly: true, | 40 readOnly: true, |
| 44 }, | 41 }, |
| 45 }, | 42 }, |
| 46 | 43 |
| 47 observers: [ | 44 observers: [ |
| 48 'pointersChanged_(hasMouse_, hasTouchpad_)', | 45 'pointersChanged_(hasMouse_, hasTouchpad_)', |
| 49 ], | 46 ], |
| 50 | 47 |
| 48 /** @override */ |
| 51 ready: function() { | 49 ready: function() { |
| 52 cr.addWebUIListener('has-mouse-changed', this.set.bind(this, 'hasMouse_')); | 50 settings.DevicePageBrowserProxyImpl.getInstance().initializePointers(); |
| 53 cr.addWebUIListener( | 51 }, |
| 52 |
| 53 /** @override */ |
| 54 attached: function() { |
| 55 this.addWebUIListener( |
| 56 'has-mouse-changed', this.set.bind(this, 'hasMouse_')); |
| 57 this.addWebUIListener( |
| 54 'has-touchpad-changed', this.set.bind(this, 'hasTouchpad_')); | 58 'has-touchpad-changed', this.set.bind(this, 'hasTouchpad_')); |
| 55 settings.DevicePageBrowserProxyImpl.getInstance().initializePointers(); | |
| 56 }, | 59 }, |
| 57 | 60 |
| 58 /** | 61 /** |
| 59 * @return {string} | 62 * @return {string} |
| 60 * @private | 63 * @private |
| 61 */ | 64 */ |
| 62 getPointersTitle_: function() { | 65 getPointersTitle_: function() { |
| 63 if (this.hasMouse_ && this.hasTouchpad_) | 66 if (this.hasMouse_ && this.hasTouchpad_) |
| 64 return this.i18n('mouseAndTouchpadTitle'); | 67 return this.i18n('mouseAndTouchpadTitle'); |
| 65 if (this.hasMouse_) | 68 if (this.hasMouse_) |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 pointersChanged_: function(hasMouse, hasTouchpad) { | 137 pointersChanged_: function(hasMouse, hasTouchpad) { |
| 135 this.$.pointersRow.hidden = !hasMouse && !hasTouchpad; | 138 this.$.pointersRow.hidden = !hasMouse && !hasTouchpad; |
| 136 this.checkPointerSubpage_(); | 139 this.checkPointerSubpage_(); |
| 137 }, | 140 }, |
| 138 | 141 |
| 139 /** | 142 /** |
| 140 * Leaves the pointer subpage if all pointing devices are detached. | 143 * Leaves the pointer subpage if all pointing devices are detached. |
| 141 * @private | 144 * @private |
| 142 */ | 145 */ |
| 143 checkPointerSubpage_: function() { | 146 checkPointerSubpage_: function() { |
| 144 if (!this.hasMouse_ && !this.hasTouchpad_ && | 147 // Check that the properties have explicitly been set to false. |
| 148 if (this.hasMouse_ === false && this.hasTouchpad_ === false && |
| 145 settings.getCurrentRoute() == settings.Route.POINTERS) { | 149 settings.getCurrentRoute() == settings.Route.POINTERS) { |
| 146 settings.navigateTo(settings.Route.DEVICE); | 150 settings.navigateTo(settings.Route.DEVICE); |
| 147 } | 151 } |
| 148 }, | 152 }, |
| 149 }); | 153 }); |
| OLD | NEW |