Chromium Code Reviews| Index: ui/file_manager/file_manager/background/js/background.js |
| diff --git a/ui/file_manager/file_manager/background/js/background.js b/ui/file_manager/file_manager/background/js/background.js |
| index 8a12975ca011d2cb054bc5fe8521da9197efe000..657dcf16bf0f793bab609b1031fd5e0fae129197 100644 |
| --- a/ui/file_manager/file_manager/background/js/background.js |
| +++ b/ui/file_manager/file_manager/background/js/background.js |
| @@ -20,12 +20,18 @@ var LaunchType = Object.freeze({ |
| */ |
| function Background() { |
| /** |
| - * Map of all currently open app windows. The key is an app id. |
| + * Map of all currently open app windows. The key is an app ID. |
| * @type {Object.<string, AppWindow>} |
| */ |
| this.appWindows = {}; |
| /** |
| + * Map of all currently open file dialogs. The key is an app ID. |
| + * @type {Object.<string, DOMWindow>} |
| + */ |
| + this.dialogs = {}; |
| + |
| + /** |
| * Synchronous queue for asynchronous calls. |
| * @type {AsyncUtil.Queue} |
| */ |
| @@ -536,20 +542,38 @@ SingletonAppWindowWrapper.prototype.reopen = function(opt_callback) { |
| /** |
| * Prefix for the file manager window ID. |
| + * @type {string} |
| + * @const |
| */ |
| var FILES_ID_PREFIX = 'files#'; |
| /** |
| * Regexp matching a file manager window ID. |
| + * @type {string} |
|
fukino
2014/06/17 05:59:10
nit: s/string/RegExp/ ?
hirono
2014/06/17 07:07:14
Done.
|
| + * @const |
| */ |
| var FILES_ID_PATTERN = new RegExp('^' + FILES_ID_PREFIX + '(\\d*)$'); |
| /** |
| + * Prefix for the dialog ID. |
| + * @type {string} |
| + * @const |
| + */ |
| +var DIALOG_ID_PREFIX = 'dialog#'; |
| + |
| +/** |
| * Value of the next file manager window ID. |
| + * @type {number} |
| */ |
| var nextFileManagerWindowID = 0; |
| /** |
| + * Value of the next file manager dialog ID. |
| + * @type {number} |
| + */ |
| +var nextFileManagerDialogID = 0; |
| + |
| +/** |
| * File manager window create options. |
| * @type {Object} |
| * @const |
| @@ -685,6 +709,19 @@ function launchFileManager(opt_appState, opt_id, opt_type, opt_callback) { |
| } |
| /** |
| + * Registers dialog window to the background page. |
| + * |
| + * @param {DOMWindow} dialogWindow Window of the dialog. |
| + */ |
| +function registerDialog(dialogWindow) { |
| + var id = DIALOG_ID_PREFIX + (nextFileManagerDialogID++); |
| + background.dialogs[id] = dialogWindow; |
| + dialogWindow.addEventListener('pagehide', function() { |
| + delete background.dialogs[id]; |
| + }); |
| +} |
| + |
| +/** |
| * Executes a file browser task. |
| * |
| * @param {string} action Task id. |