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 /** | 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. */ | 19 /** Preferences state. */ |
| 20 prefs: { | 20 prefs: { |
| 21 type: Object, | 21 type: Object, |
| 22 notify: true, | 22 notify: true, |
| 23 }, | 23 }, |
| 24 | 24 |
| 25 /** @private */ | 25 /** |
| 26 hasMouse_: { | 26 * |hasMouse_| and |hasTouchpad_| start undefined so observers don't trigger |
| 27 type: Boolean, | 27 * until both have been populated. |
| 28 value: false, | 28 * @private |
| 29 }, | 29 */ |
| 30 hasMouse_: Boolean, | |
| 30 | 31 |
| 31 /** @private */ | 32 /** @private */ |
| 32 hasTouchpad_: { | 33 hasTouchpad_: Boolean, |
| 33 type: Boolean, | |
| 34 value: false, | |
| 35 }, | |
| 36 | 34 |
| 37 /** @private */ | 35 /** @private */ |
| 38 stylusAllowed_: { | 36 stylusAllowed_: { |
| 39 type: Boolean, | 37 type: Boolean, |
| 40 value: function() { | 38 value: function() { |
| 41 return loadTimeData.getBoolean('stylusAllowed'); | 39 return loadTimeData.getBoolean('stylusAllowed'); |
| 42 }, | 40 }, |
| 43 readOnly: true, | 41 readOnly: true, |
| 44 }, | 42 }, |
| 45 }, | 43 }, |
| 46 | 44 |
| 47 observers: [ | 45 observers: [ |
| 48 'pointersChanged_(hasMouse_, hasTouchpad_)', | 46 'pointersChanged_(hasMouse_, hasTouchpad_)', |
| 49 ], | 47 ], |
| 50 | 48 |
| 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 attached: function() { | |
|
dpapad
2016/12/16 01:20:53
Nit: @override
michaelpg
2016/12/16 23:32:30
Done + some other minor closure cleanup.
| |
| 54 this.addWebUIListener( | |
| 55 'has-mouse-changed', this.set.bind(this, 'hasMouse_')); | |
| 56 this.addWebUIListener( | |
| 54 'has-touchpad-changed', this.set.bind(this, 'hasTouchpad_')); | 57 'has-touchpad-changed', this.set.bind(this, 'hasTouchpad_')); |
| 55 settings.DevicePageBrowserProxyImpl.getInstance().initializePointers(); | |
| 56 }, | 58 }, |
| 57 | 59 |
| 58 /** | 60 /** |
| 59 * @return {string} | 61 * @return {string} |
| 60 * @private | 62 * @private |
| 61 */ | 63 */ |
| 62 getPointersTitle_: function() { | 64 getPointersTitle_: function() { |
| 63 if (this.hasMouse_ && this.hasTouchpad_) | 65 if (this.hasMouse_ && this.hasTouchpad_) |
| 64 return this.i18n('mouseAndTouchpadTitle'); | 66 return this.i18n('mouseAndTouchpadTitle'); |
| 65 if (this.hasMouse_) | 67 if (this.hasMouse_) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 /** | 118 /** |
| 117 * Handler for tapping the Storage settings menu item. | 119 * Handler for tapping the Storage settings menu item. |
| 118 * @private | 120 * @private |
| 119 */ | 121 */ |
| 120 onStorageTap_: function() { | 122 onStorageTap_: function() { |
| 121 settings.navigateTo(settings.Route.STORAGE); | 123 settings.navigateTo(settings.Route.STORAGE); |
| 122 }, | 124 }, |
| 123 | 125 |
| 124 /** @protected */ | 126 /** @protected */ |
| 125 currentRouteChanged: function() { | 127 currentRouteChanged: function() { |
| 126 this.checkPointerSubpage_(); | 128 this.checkPointerSubpage_(); |
|
dpapad
2016/12/16 01:20:53
Is this call necessary? IIUC sometimes the desired
michaelpg
2016/12/16 23:32:31
Oops, I replied to this as a message.
dpapad
2016/12/17 01:05:08
Preferably there would be a message "Nothing to se
michaelpg
2016/12/17 03:04:47
Sure, that's doable - "patches welcome" :-)
This
| |
| 127 }, | 129 }, |
| 128 | 130 |
| 129 /** | 131 /** |
| 130 * @param {boolean} hasMouse | 132 * @param {boolean} hasMouse |
| 131 * @param {boolean} hasTouchpad | 133 * @param {boolean} hasTouchpad |
| 132 * @private | 134 * @private |
| 133 */ | 135 */ |
| 134 pointersChanged_: function(hasMouse, hasTouchpad) { | 136 pointersChanged_: function(hasMouse, hasTouchpad) { |
| 135 this.$.pointersRow.hidden = !hasMouse && !hasTouchpad; | 137 this.$.pointersRow.hidden = !hasMouse && !hasTouchpad; |
| 136 this.checkPointerSubpage_(); | 138 this.checkPointerSubpage_(); |
| 137 }, | 139 }, |
| 138 | 140 |
| 139 /** | 141 /** |
| 140 * Leaves the pointer subpage if all pointing devices are detached. | 142 * Leaves the pointer subpage if all pointing devices are detached. |
| 141 * @private | 143 * @private |
| 142 */ | 144 */ |
| 143 checkPointerSubpage_: function() { | 145 checkPointerSubpage_: function() { |
| 144 if (!this.hasMouse_ && !this.hasTouchpad_ && | 146 // Check that the properties have explicitly been set to false. |
| 147 if (this.hasMouse_ === false && this.hasTouchpad_ === false && | |
| 145 settings.getCurrentRoute() == settings.Route.POINTERS) { | 148 settings.getCurrentRoute() == settings.Route.POINTERS) { |
| 146 settings.navigateTo(settings.Route.DEVICE); | 149 settings.navigateTo(settings.Route.DEVICE); |
| 147 } | 150 } |
| 148 }, | 151 }, |
| 149 }); | 152 }); |
| OLD | NEW |