OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** @suppress {duplicate} */ | 7 /** @suppress {duplicate} */ |
8 var remoting = remoting || {}; | 8 var remoting = remoting || {}; |
9 | 9 |
10 /** | 10 /** |
11 * Namespace for window manager functions. | 11 * Namespace for window manager functions. |
12 * @type {Object} | 12 * @type {Object} |
13 */ | 13 */ |
14 remoting.MessageWindowManager = {}; | 14 remoting.MessageWindowManager = {}; |
15 | 15 |
16 /** | 16 /** |
17 * Mapping from window id to corresponding MessageWindow. | 17 * Mapping from window id to corresponding MessageWindow. |
18 * | 18 * |
19 * @type {Object.<number, remoting.MessageWindow>} | 19 * @type {Object<number, remoting.MessageWindow>} |
20 * @private | 20 * @private |
21 */ | 21 */ |
22 remoting.MessageWindowManager.messageWindows_ = {}; | 22 remoting.MessageWindowManager.messageWindows_ = {}; |
23 | 23 |
24 /** | 24 /** |
25 * The next window id to auto-assign. | 25 * The next window id to auto-assign. |
26 * @type {number} | 26 * @type {number} |
27 * @private | 27 * @private |
28 */ | 28 */ |
29 remoting.MessageWindowManager.nextId_ = 1; | 29 remoting.MessageWindowManager.nextId_ = 1; |
(...skipping 21 matching lines...) Expand all Loading... |
51 * @param {number} id The window id to delete. | 51 * @param {number} id The window id to delete. |
52 */ | 52 */ |
53 remoting.MessageWindowManager.deleteMessageWindow = function(id) { | 53 remoting.MessageWindowManager.deleteMessageWindow = function(id) { |
54 delete remoting.MessageWindowManager.messageWindows_[id]; | 54 delete remoting.MessageWindowManager.messageWindows_[id]; |
55 }; | 55 }; |
56 | 56 |
57 /** | 57 /** |
58 * Close all of the registered MessageWindows | 58 * Close all of the registered MessageWindows |
59 */ | 59 */ |
60 remoting.MessageWindowManager.closeAllMessageWindows = function() { | 60 remoting.MessageWindowManager.closeAllMessageWindows = function() { |
61 /** @type {Array.<remoting.MessageWindow>} */ | 61 /** @type {Array<remoting.MessageWindow>} */ |
62 var windows = []; | 62 var windows = []; |
63 // Make a list of the windows to close. | 63 // Make a list of the windows to close. |
64 // We don't delete the window directly in this loop because close() can | 64 // We don't delete the window directly in this loop because close() can |
65 // call deleteMessageWindow which will update messageWindows_. | 65 // call deleteMessageWindow which will update messageWindows_. |
66 for (var win_id in remoting.MessageWindowManager.messageWindows_) { | 66 for (var win_id in remoting.MessageWindowManager.messageWindows_) { |
67 /** @type {remoting.MessageWindow} */ | 67 /** @type {remoting.MessageWindow} */ |
68 var win = remoting.MessageWindowManager.getMessageWindow( | 68 var win = remoting.MessageWindowManager.getMessageWindow( |
69 parseInt(win_id, 10)); | 69 parseInt(win_id, 10)); |
70 base.debug.assert(win != null); | 70 base.debug.assert(win != null); |
71 windows.push(win); | 71 windows.push(win); |
(...skipping 30 matching lines...) Expand all Loading... |
102 } | 102 } |
103 | 103 |
104 messageWindow.handleResult(result); | 104 messageWindow.handleResult(result); |
105 messageWindow.close(); | 105 messageWindow.close(); |
106 } | 106 } |
107 }; | 107 }; |
108 | 108 |
109 | 109 |
110 window.addEventListener('message', remoting.MessageWindowManager.onMessage_, | 110 window.addEventListener('message', remoting.MessageWindowManager.onMessage_, |
111 false); | 111 false); |
OLD | NEW |