OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 /** | 5 /** |
6 * This view displays options for exporting the captured data. | 6 * This view displays options for exporting the captured data. |
7 */ | 7 */ |
8 var ExportView = (function() { | 8 var ExportView = (function() { |
9 'use strict'; | 9 'use strict'; |
10 | 10 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 /** | 106 /** |
107 * If not already busy saving a log dump, triggers asynchronous | 107 * If not already busy saving a log dump, triggers asynchronous |
108 * generation of log dump and starts waiting for it to complete. | 108 * generation of log dump and starts waiting for it to complete. |
109 */ | 109 */ |
110 onSaveFile_: function() { | 110 onSaveFile_: function() { |
111 if (this.saveFileButton_.disabled) | 111 if (this.saveFileButton_.disabled) |
112 return; | 112 return; |
113 | 113 |
114 // Clean up previous blob, if any, to reduce resource usage. | 114 // Clean up previous blob, if any, to reduce resource usage. |
115 if (this.lastBlobURL_) { | 115 if (this.lastBlobURL_) { |
116 window.webkitURL.revokeObjectURL(this.lastBlobURL_); | 116 window.URL.revokeObjectURL(this.lastBlobURL_); |
117 this.lastBlobURL_ = null; | 117 this.lastBlobURL_ = null; |
118 } | 118 } |
119 this.createLogDump_(this.onLogDumpCreated_.bind(this)); | 119 this.createLogDump_(this.onLogDumpCreated_.bind(this)); |
120 }, | 120 }, |
121 | 121 |
122 /** | 122 /** |
123 * Creates a log dump, and either synchronously or asynchronously calls | 123 * Creates a log dump, and either synchronously or asynchronously calls |
124 * |callback| if it succeeds. Separate from onSaveFile_ for unit tests. | 124 * |callback| if it succeeds. Separate from onSaveFile_ for unit tests. |
125 */ | 125 */ |
126 createLogDump_: function(callback) { | 126 createLogDump_: function(callback) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 } | 178 } |
179 | 179 |
180 return value; | 180 return value; |
181 }, | 181 }, |
182 | 182 |
183 /** | 183 /** |
184 * Creates a blob url and starts downloading it. | 184 * Creates a blob url and starts downloading it. |
185 */ | 185 */ |
186 onLogDumpCreated_: function(dumpText) { | 186 onLogDumpCreated_: function(dumpText) { |
187 var textBlob = new Blob([dumpText], {type: 'octet/stream'}); | 187 var textBlob = new Blob([dumpText], {type: 'octet/stream'}); |
188 this.lastBlobURL_ = window.webkitURL.createObjectURL(textBlob); | 188 this.lastBlobURL_ = window.URL.createObjectURL(textBlob); |
189 | 189 |
190 // Update the anchor tag and simulate a click on it to start the | 190 // Update the anchor tag and simulate a click on it to start the |
191 // download. | 191 // download. |
192 var downloadAnchor = $(ExportView.DOWNLOAD_ANCHOR_ID); | 192 var downloadAnchor = $(ExportView.DOWNLOAD_ANCHOR_ID); |
193 downloadAnchor.href = this.lastBlobURL_; | 193 downloadAnchor.href = this.lastBlobURL_; |
194 downloadAnchor.click(); | 194 downloadAnchor.click(); |
195 | 195 |
196 this.setSaveFileStatus('Dump successful', false); | 196 this.setSaveFileStatus('Dump successful', false); |
197 } | 197 } |
198 }; | 198 }; |
199 | 199 |
200 return ExportView; | 200 return ExportView; |
201 })(); | 201 })(); |
OLD | NEW |