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

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

Issue 1999593002: Update chrome://device-emulator with newer Polymer guidelines (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: narrow mode drawer + webui safety Created 4 years, 7 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 /** @enum {string} */ var AudioNodeType = { 5 /** @enum {string} */ var AudioNodeType = {
6 HEADPHONE: 'HEADPHONE', 6 HEADPHONE: 'HEADPHONE',
7 MIC: 'MIC', 7 MIC: 'MIC',
8 USB: 'USB', 8 USB: 'USB',
9 BLUETOOTH: 'BLUETOOTH', 9 BLUETOOTH: 'BLUETOOTH',
10 HDMI: 'HDMI', 10 HDMI: 'HDMI',
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // Whether the node is active or not. 42 // Whether the node is active or not.
43 this.active = false; 43 this.active = false;
44 44
45 // The time the node was plugged in (in seconds). 45 // The time the node was plugged in (in seconds).
46 this.pluggedTime = 0; 46 this.pluggedTime = 0;
47 }; 47 };
48 48
49 Polymer({ 49 Polymer({
50 is: 'audio-settings', 50 is: 'audio-settings',
51 51
52 behaviors: [Polymer.NeonAnimatableBehavior],
53
52 properties: { 54 properties: {
53 /** 55 /**
54 * An AudioNode which is currently being edited. 56 * An AudioNode which is currently being edited.
55 * @type {AudioNode} 57 * @type {AudioNode}
56 */ 58 */
57 currentEditableObject: { 59 currentEditableObject: {
58 type: Object, 60 type: Object,
59 value: function() { return {}; } 61 value: function() { return {}; }
60 }, 62 },
61 63
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 {name: 'Internal Speaker', type: AudioNodeType.INTERNAL_SPEAKER}, 98 {name: 'Internal Speaker', type: AudioNodeType.INTERNAL_SPEAKER},
97 {name: 'Internal Mic', type: AudioNodeType.INTERNAL_MIC}, 99 {name: 'Internal Mic', type: AudioNodeType.INTERNAL_MIC},
98 {name: 'Keyboard Mic', type: AudioNodeType.KEYBOARD_MIC}, 100 {name: 'Keyboard Mic', type: AudioNodeType.KEYBOARD_MIC},
99 {name: 'Aokr', type: AudioNodeType.AOKR}, 101 {name: 'Aokr', type: AudioNodeType.AOKR},
100 {name: 'Post Mix Loopback', type: AudioNodeType.POST_MIX_LOOPBACK}, 102 {name: 'Post Mix Loopback', type: AudioNodeType.POST_MIX_LOOPBACK},
101 {name: 'Post Dsp Loopback', type: AudioNodeType.POST_DSP_LOOPBACK}, 103 {name: 'Post Dsp Loopback', type: AudioNodeType.POST_DSP_LOOPBACK},
102 {name: 'Other', type: AudioNodeType.OTHER} 104 {name: 'Other', type: AudioNodeType.OTHER}
103 ]; 105 ];
104 } 106 }
105 }, 107 },
106
107 /**
108 * The title to be displayed in a heading element for the element.
109 */
110 title: {type: String},
111 }, 108 },
112 109
113 ready: function() { 110 ready: function() {
114 this.title = 'Audio'; 111 this.title = 'Audio';
115 }, 112 },
116 113
117 initialize: function() { 114 initialize: function() {
118 if (!this.initialized) { 115 if (!this.initialized) {
119 chrome.send('requestAudioNodes'); 116 chrome.send('requestAudioNodes');
120 this.initialized = true; 117 this.initialized = true;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 Object.assign(newNode, this.nodes[event.model.index]); 174 Object.assign(newNode, this.nodes[event.model.index]);
178 newNode.name += ' (Copy)'; 175 newNode.name += ' (Copy)';
179 newNode.deviceName += ' (Copy)'; 176 newNode.deviceName += ' (Copy)';
180 newNode.id += this.nodeCount; 177 newNode.id += this.nodeCount;
181 this.nodeCount++; 178 this.nodeCount++;
182 179
183 this.push('nodes', newNode); 180 this.push('nodes', newNode);
184 }, 181 },
185 182
186 /** 183 /**
187 * Shows a modal dialog to edit the selected node's properties. 184 * Shows a dialog to edit the selected node's properties.
188 * @param {Event} event Contains event data. |event.model.index| is the index 185 * @param {Event} event Contains event data. |event.model.index| is the index
189 * of the item which the target is contained in. 186 * of the item which the target is contained in.
190 */ 187 */
191 showEditModal: function(event) { 188 showEditDialog: function(event) {
192 var index = event.model.index; 189 var index = event.model.index;
193 this.currentEditIndex = index; 190 this.currentEditIndex = index;
194 this.currentEditableObject = this.nodes[index]; 191 this.currentEditableObject = this.nodes[index];
195 this.$.editModal.toggle(); 192 this.$.editDialog.toggle();
196 }, 193 },
197 194
198 /** 195 /**
199 * Called by the WebUI which provides a list of nodes. 196 * Called by the WebUI which provides a list of nodes.
200 * @param {!Array<!AudioNode>} nodeList A list of audio nodes. 197 * @param {!Array<!AudioNode>} nodeList A list of audio nodes.
201 */ 198 */
202 updateAudioNodes: function(nodeList) { 199 updateAudioNodes: function(nodeList) {
203 /** @type {!Array<!AudioNode>} */ var newNodeList = []; 200 /** @type {!Array<!AudioNode>} */ var newNodeList = [];
204 for (var i = 0; i < nodeList.length; ++i) { 201 for (var i = 0; i < nodeList.length; ++i) {
205 // Create a new audio node and add all the properties from |nodeList[i]|. 202 // Create a new audio node and add all the properties from |nodeList[i]|.
206 var node = new AudioNode(); 203 var node = new AudioNode();
207 Object.assign(node, nodeList[i]); 204 Object.assign(node, nodeList[i]);
208 newNodeList.push(node); 205 newNodeList.push(node);
209 } 206 }
210 this.nodes = newNodeList; 207 this.nodes = newNodeList;
211 } 208 }
212 }); 209 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698