Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: chrome/browser/resources/chromeos/emulator/battery_settings.js

Issue 2938933002: WebUI: swap paper-dropdown-menu out for md-select. (Closed)
Patch Set: switch md_user_manager/create_profile dropdown Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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: {
(...skipping 13 matching lines...) Expand all
56 {id: '5', name: 'Dual-role USB 2', type: 'DualRoleUSB', 57 {id: '5', name: 'Dual-role USB 2', type: 'DualRoleUSB',
57 port: 1, connected: false, power: 'low'}, 58 port: 1, connected: false, power: 'low'},
58 {id: '6', name: 'Dual-role USB 3', type: 'DualRoleUSB', 59 {id: '6', name: 'Dual-role USB 3', type: 'DualRoleUSB',
59 port: 2, connected: false, power: 'low'}, 60 port: 2, connected: false, power: 'low'},
60 {id: '7', name: 'Dual-role USB 4', type: 'DualRoleUSB', 61 {id: '7', name: 'Dual-role USB 4', type: 'DualRoleUSB',
61 port: 3, connected: false, power: 'low'}, 62 port: 3, connected: false, power: 'low'},
62 ]; 63 ];
63 }, 64 },
64 }, 65 },
65 66
67 // Possible power levels for power sources.
68 powerOptions: {
69 type: Array,
70 value: function() {
71 return ['high', 'low'];
72 }
73 },
74
66 /** The ID of the current power source, or the empty string. */ 75 /** The ID of the current power source, or the empty string. */
67 selectedPowerSourceId: String, 76 selectedPowerSourceId: String,
68 77
69 /** A string representing the time left until the battery is discharged. */ 78 /** A string representing the time left until the battery is discharged. */
70 timeUntilEmpty: String, 79 timeUntilEmpty: String,
71 80
72 /** A string representing the time left until the battery is at 100%. */ 81 /** A string representing the time left until the battery is at 100%. */
73 timeUntilFull: String, 82 timeUntilFull: String,
74 }, 83 },
75 84
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 if (!isNaN(this.timeUntilEmpty)) 121 if (!isNaN(this.timeUntilEmpty))
113 chrome.send('updateTimeToEmpty', [this.timeUntilEmpty]); 122 chrome.send('updateTimeToEmpty', [this.timeUntilEmpty]);
114 }, 123 },
115 124
116 onTimeUntilFullChange: function(e) { 125 onTimeUntilFullChange: function(e) {
117 this.timeUntilFull = parseInt(e.target.value); 126 this.timeUntilFull = parseInt(e.target.value);
118 if (!isNaN(this.timeUntilFull)) 127 if (!isNaN(this.timeUntilFull))
119 chrome.send('updateTimeToFull', [this.timeUntilFull]); 128 chrome.send('updateTimeToFull', [this.timeUntilFull]);
120 }, 129 },
121 130
131 onPowerChanged: function(e) {
132 e.model.set('item.power', e.target.value);
133 },
134
122 updatePowerProperties: function(power_properties) { 135 updatePowerProperties: function(power_properties) {
123 this.batteryPercent = power_properties.battery_percent; 136 this.batteryPercent = power_properties.battery_percent;
124 this.batteryState = 137 this.batteryState =
125 this.batteryStateOptions[power_properties.battery_state]; 138 this.batteryStateOptions[power_properties.battery_state];
126 this.timeUntilEmpty = power_properties.battery_time_to_empty_sec; 139 this.timeUntilEmpty = power_properties.battery_time_to_empty_sec;
127 this.timeUntilFull = power_properties.battery_time_to_full_sec; 140 this.timeUntilFull = power_properties.battery_time_to_full_sec;
128 this.selectedPowerSourceId = power_properties.external_power_source_id; 141 this.selectedPowerSourceId = power_properties.external_power_source_id;
129 }, 142 },
130 143
131 isBatteryPresent: function() { 144 isBatteryPresent: function() {
132 return this.batteryState != 'Not Present'; 145 return this.batteryState != 'Not Present';
133 }, 146 },
134 147
135 isDualRole: function(source) { 148 isDualRole: function(source) {
136 return source.type == 'DualRoleUSB'; 149 return source.type == 'DualRoleUSB';
137 }, 150 },
138 151
152 isPowerEqual: function(itemPower, option) {
153 return itemPower == option;
154 },
155
139 isSelectedSource: function(source) { 156 isSelectedSource: function(source) {
140 return source.id == this.selectedPowerSourceId; 157 return source.id == this.selectedPowerSourceId;
141 }, 158 },
142 159
143 canAmpsChange: function(type) { 160 canAmpsChange: function(type) {
144 return type == 'USB'; 161 return type == 'USB';
145 }, 162 },
146 163
147 canBecomeSource: function(source, selectedId, powerSourceOptionsChange) { 164 canBecomeSource: function(source, selectedId, powerSourceOptionsChange) {
148 if (!source.connected || !this.isDualRole(source)) 165 if (!source.connected || !this.isDualRole(source))
149 return false; 166 return false;
150 return !this.powerSourceOptions.some(function(source) { 167 return !this.powerSourceOptions.some(function(source) {
151 return source.connected && source.type == 'DedicatedCharger'; 168 return source.connected && source.type == 'DedicatedCharger';
152 }); 169 });
153 }, 170 },
154 }); 171 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698