IndexedDBFactory now ForceCloses databases.
[chromium-blink-merge.git] / content / browser / resources / media / dump_creator.js
blob28c53dd9e22bd6f57d49986f4d2bea115001b535
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.
6 /**
7 * Provides the UI for dump creation.
8 */
9 var DumpCreator = (function() {
10 /**
11 * @param {Element} containerElement The parent element of the dump creation
12 * UI.
13 * @constructor
15 function DumpCreator(containerElement) {
16 /**
17 * The root element of the dump creation UI.
18 * @type {Element}
19 * @private
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;
55 /**
56 * Downloads the PeerConnection updates and stats data as a file.
58 * @private
60 onDownloadData_: function() {
61 var textBlob =
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.
69 /**
70 * Handles the event of toggling the AEC recording state.
72 * @private
74 onAecRecordingChanged_: function() {
75 var enabled = this.root_.getElementsByTagName('input')[0].checked;
76 if (enabled) {
77 chrome.send('enableAecRecording');
78 } else {
79 chrome.send('disableAecRecording');
83 return DumpCreator;
84 })();