OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 var BatterySettings = Polymer({ | 5 var BatterySettings = Polymer({ |
6 is: 'battery-settings', | 6 is: 'battery-settings', |
7 | 7 |
8 behaviors: [Polymer.NeonAnimatableBehavior], | 8 behaviors: [Polymer.NeonAnimatableBehavior], |
9 | 9 |
10 properties: { | 10 properties: { |
(...skipping 10 matching lines...) Expand all Loading... |
21 }, | 21 }, |
22 | 22 |
23 /** | 23 /** |
24 * An array representing the battery state options. | 24 * An array representing the battery state options. |
25 * The names are ordered based on the | 25 * The names are ordered based on the |
26 * PowerSupplyProperties_BatteryState enumeration. These values must be | 26 * PowerSupplyProperties_BatteryState enumeration. These values must be |
27 * in sync. | 27 * in sync. |
28 */ | 28 */ |
29 batteryStateOptions: { | 29 batteryStateOptions: { |
30 type: Array, | 30 type: Array, |
31 value: function() { return ['Full', 'Charging', 'Discharging', | 31 value: function() { |
32 'Not Present']; }, | 32 return ['Full', 'Charging', 'Discharging', 'Not Present']; |
| 33 }, |
33 }, | 34 }, |
34 | 35 |
35 /** | 36 /** |
36 * Example charging devices that can be connected. Chargers are split | 37 * Example charging devices that can be connected. Chargers are split |
37 * between dedicated chargers (which will always provide power if no | 38 * between dedicated chargers (which will always provide power if no |
38 * higher-power dedicated charger is connected) and dual-role USB chargers | 39 * higher-power dedicated charger is connected) and dual-role USB chargers |
39 * (which only provide power if configured as a source and no dedicated | 40 * (which only provide power if configured as a source and no dedicated |
40 * charger is connected). | 41 * charger is connected). |
41 */ | 42 */ |
42 powerSourceOptions: { | 43 powerSourceOptions: { |
43 type: Array, | 44 type: Array, |
44 value: function() { | 45 value: function() { |
45 return [ | 46 return [ |
46 {id: '0', name: 'AC Charger 1', type: 'DedicatedCharger', | 47 { |
47 port: 0, connected: false, power: 'high'}, | 48 id: '0', |
48 {id: '1', name: 'AC Charger 2', type: 'DedicatedCharger', | 49 name: 'AC Charger 1', |
49 port: 0, connected: false, power: 'high'}, | 50 type: 'DedicatedCharger', |
50 {id: '2', name: 'USB Charger 1', type: 'DedicatedCharger', | 51 port: 0, |
51 port: 0, connected: false, power: 'low', variablePower: true}, | 52 connected: false, |
52 {id: '3', name: 'USB Charger 2', type: 'DedicatedCharger', | 53 power: 'high' |
53 port: 0, connected: false, power: 'low', variablePower: true}, | 54 }, |
54 {id: '4', name: 'Dual-role USB 1', type: 'DualRoleUSB', | 55 { |
55 port: 0, connected: false, power: 'low'}, | 56 id: '1', |
56 {id: '5', name: 'Dual-role USB 2', type: 'DualRoleUSB', | 57 name: 'AC Charger 2', |
57 port: 1, connected: false, power: 'low'}, | 58 type: 'DedicatedCharger', |
58 {id: '6', name: 'Dual-role USB 3', type: 'DualRoleUSB', | 59 port: 0, |
59 port: 2, connected: false, power: 'low'}, | 60 connected: false, |
60 {id: '7', name: 'Dual-role USB 4', type: 'DualRoleUSB', | 61 power: 'high' |
61 port: 3, connected: false, power: 'low'}, | 62 }, |
| 63 { |
| 64 id: '2', |
| 65 name: 'USB Charger 1', |
| 66 type: 'DedicatedCharger', |
| 67 port: 0, |
| 68 connected: false, |
| 69 power: 'low', |
| 70 variablePower: true |
| 71 }, |
| 72 { |
| 73 id: '3', |
| 74 name: 'USB Charger 2', |
| 75 type: 'DedicatedCharger', |
| 76 port: 0, |
| 77 connected: false, |
| 78 power: 'low', |
| 79 variablePower: true |
| 80 }, |
| 81 { |
| 82 id: '4', |
| 83 name: 'Dual-role USB 1', |
| 84 type: 'DualRoleUSB', |
| 85 port: 0, |
| 86 connected: false, |
| 87 power: 'low' |
| 88 }, |
| 89 { |
| 90 id: '5', |
| 91 name: 'Dual-role USB 2', |
| 92 type: 'DualRoleUSB', |
| 93 port: 1, |
| 94 connected: false, |
| 95 power: 'low' |
| 96 }, |
| 97 { |
| 98 id: '6', |
| 99 name: 'Dual-role USB 3', |
| 100 type: 'DualRoleUSB', |
| 101 port: 2, |
| 102 connected: false, |
| 103 power: 'low' |
| 104 }, |
| 105 { |
| 106 id: '7', |
| 107 name: 'Dual-role USB 4', |
| 108 type: 'DualRoleUSB', |
| 109 port: 3, |
| 110 connected: false, |
| 111 power: 'low' |
| 112 }, |
62 ]; | 113 ]; |
63 }, | 114 }, |
64 }, | 115 }, |
65 | 116 |
66 /** The ID of the current power source, or the empty string. */ | 117 /** The ID of the current power source, or the empty string. */ |
67 selectedPowerSourceId: String, | 118 selectedPowerSourceId: String, |
68 | 119 |
69 /** A string representing the time left until the battery is discharged. */ | 120 /** A string representing the time left until the battery is discharged. */ |
70 timeUntilEmpty: String, | 121 timeUntilEmpty: String, |
71 | 122 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 }, | 196 }, |
146 | 197 |
147 canBecomeSource: function(source, selectedId, powerSourceOptionsChange) { | 198 canBecomeSource: function(source, selectedId, powerSourceOptionsChange) { |
148 if (!source.connected || !this.isDualRole(source)) | 199 if (!source.connected || !this.isDualRole(source)) |
149 return false; | 200 return false; |
150 return !this.powerSourceOptions.some(function(source) { | 201 return !this.powerSourceOptions.some(function(source) { |
151 return source.connected && source.type == 'DedicatedCharger'; | 202 return source.connected && source.type == 'DedicatedCharger'; |
152 }); | 203 }); |
153 }, | 204 }, |
154 }); | 205 }); |
OLD | NEW |