OLD | NEW |
| (Empty) |
1 // Copyright 2017 The Chromium OS 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. | |
4 | |
5 window.onload = function() { | |
6 chrome.runtime.getBackgroundPage(function(backgroundPage) { | |
7 | |
8 // Called from the background page. We need to place this function here | |
9 // because chrome.fileSystem.chooseEntry only works on forground page. | |
10 backgroundPage.unpacker.Compressor.prototype.createArchiveFileForeground_ = | |
11 function(compressorId) { | |
12 var compressor = | |
13 backgroundPage.unpacker.app.compressors[compressorId]; | |
14 var suggestedName = compressor.archiveName_; | |
15 // Create an archive file. | |
16 chrome.fileSystem.chooseEntry( | |
17 {type: 'saveFile', suggestedName: suggestedName}, | |
18 function(entry, fileEntries) { | |
19 if (!entry) { | |
20 console.error('Failed to create an archive file.'); | |
21 compressor.onError_(compressor.compressorId_); | |
22 return; | |
23 } | |
24 | |
25 compressor.archiveFileEntry_ = entry; | |
26 | |
27 compressor.sendCreateArchiveRequest_(); | |
28 }); | |
29 }; | |
30 | |
31 // Some compressors are waiting for this foreground page to be loaded. | |
32 backgroundPage.unpacker.Compressor.CompressorIdQueue.forEach( | |
33 function(compressorId) { | |
34 var compressor = | |
35 backgroundPage.unpacker.app.compressors[compressorId]; | |
36 compressor.createArchiveFileForeground_(compressorId); | |
37 }); | |
38 }); | |
39 }; | |
OLD | NEW |