1 // Copyright 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.
8 * While FileOperationManager is run in the background page, this class is
9 * used to communicate with it.
10 * @param {DOMWindow} backgroundPage Window object of the background page.
13 function FileOperationManagerWrapper(backgroundPage) {
14 this.fileOperationManager_ =
15 backgroundPage.FileOperationManager.getInstance();
19 * Create a new instance or get existing instance of FCMW.
20 * @param {DOMWindow} backgroundPage Window object of the background page.
21 * @return {FileOperationManagerWrapper} FileOperationManagerWrapper instance.
23 FileOperationManagerWrapper.getInstance = function(backgroundPage) {
24 if (!FileOperationManagerWrapper.instance_)
25 FileOperationManagerWrapper.instance_ =
26 new FileOperationManagerWrapper(backgroundPage);
28 return FileOperationManagerWrapper.instance_;
32 * @return {boolean} True if there is a running task.
34 FileOperationManagerWrapper.prototype.isRunning = function() {
35 return this.fileOperationManager_.hasQueuedTasks();
39 * Decorates a FileOperationManager method, so it will be executed after
40 * initializing the FileOperationManager instance in background page.
41 * @param {string} method The method name.
43 FileOperationManagerWrapper.decorateAsyncMethod = function(method) {
44 FileOperationManagerWrapper.prototype[method] = function() {
45 this.fileOperationManager_[method].apply(
46 this.fileOperationManager_, arguments);
50 FileOperationManagerWrapper.decorateAsyncMethod('paste');
51 FileOperationManagerWrapper.decorateAsyncMethod('deleteEntries');
52 FileOperationManagerWrapper.decorateAsyncMethod('forceDeleteTask');
53 FileOperationManagerWrapper.decorateAsyncMethod('cancelDeleteTask');
54 FileOperationManagerWrapper.decorateAsyncMethod('zipSelection');
55 FileOperationManagerWrapper.decorateAsyncMethod('addEventListener');
56 FileOperationManagerWrapper.decorateAsyncMethod('removeEventListener');