1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 * Provides the UI for dump creation.
9 var DumpCreator
= (function() {
11 * @param {Element} containerElement The parent element of the dump creation
15 function DumpCreator(containerElement
) {
17 * The root element of the dump creation UI.
21 this.root_
= document
.createElement('details');
23 this.root_
.className
= 'peer-connection-dump-root';
24 containerElement
.appendChild(this.root_
);
25 var summary
= document
.createElement('summary');
26 this.root_
.appendChild(summary
);
27 summary
.textContent
= 'Create Dump';
28 var content
= document
.createElement('div');
29 this.root_
.appendChild(content
);
31 content
.innerHTML
= '<div><a><button>' +
32 'Download the PeerConnection updates and stats data' +
33 '</button></a></div>' +
34 '<p><label><input type=checkbox>' +
35 'Enable diagnostic audio recordings.</label></p>' +
36 '<p>A diagnostic audio recording is used for analyzing audio' +
37 ' problems. It contains the audio played out from the speaker and' +
38 ' recorded from the microphone and is saved to the local disk.' +
39 ' Checking this box will enable the recording for future WebRTC' +
40 ' calls. When the box is unchecked or this page is closed, this' +
41 ' recording functionality will be disabled.</p>';
43 content
.getElementsByTagName('a')[0].addEventListener(
44 'click', this.onDownloadData_
.bind(this));
45 content
.getElementsByTagName('input')[0].addEventListener(
46 'click', this.onAecRecordingChanged_
.bind(this));
49 DumpCreator
.prototype = {
50 /** Mark the AEC recording checkbox checked.*/
51 enableAecRecording: function() {
52 this.root_
.getElementsByTagName('input')[0].checked
= true;
56 * Downloads the PeerConnection updates and stats data as a file.
60 onDownloadData_: function() {
62 new Blob([JSON
.stringify(peerConnectionDataStore
, null, ' ')],
63 {type
: 'octet/stream'});
64 var URL
= window
.URL
.createObjectURL(textBlob
);
65 this.root_
.getElementsByTagName('a')[0].href
= URL
;
66 // The default action of the anchor will download the URL.
70 * Handles the event of toggling the AEC recording state.
74 onAecRecordingChanged_: function() {
75 var enabled
= this.root_
.getElementsByTagName('input')[0].checked
;
77 chrome
.send('enableAecRecording');
79 chrome
.send('disableAecRecording');