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 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * Helper class for submenus that should add or remove the parent menu entry | 7 * Helper class for submenus that should add or remove the parent menu entry |
8 * depending on whether or not any child items exist. | 8 * depending on whether or not any child items exist. |
9 */ | 9 */ |
10 | 10 |
11 'use strict'; | 11 'use strict'; |
12 | 12 |
13 /** @suppress {duplicate} */ | 13 /** @suppress {duplicate} */ |
14 var remoting = remoting || {}; | 14 var remoting = remoting || {}; |
15 | 15 |
16 /** | 16 /** |
17 * @param {remoting.ContextMenuAdapter} adapter | 17 * @param {remoting.ContextMenuAdapter} adapter |
18 * @param {string} title The title of the parent menu item. | 18 * @param {string} title The title of the parent menu item. |
19 * @param {boolean} checkable True if the child menus should be checkable. | 19 * @param {boolean} checkable True if the child menus should be checkable. |
20 * @constructor | 20 * @constructor |
21 */ | 21 */ |
22 remoting.SubmenuManager = function(adapter, title, checkable) { | 22 remoting.SubmenuManager = function(adapter, title, checkable) { |
23 /** | 23 /** @private {remoting.ContextMenuAdapter} */ |
24 * @type {remoting.ContextMenuAdapter} | |
25 * @private | |
26 */ | |
27 this.adapter_ = adapter; | 24 this.adapter_ = adapter; |
28 /** | 25 /** @private {string} */ |
29 * @type {string} | |
30 * @private | |
31 */ | |
32 this.title_ = title; | 26 this.title_ = title; |
33 /** | 27 /** @private {boolean} */ |
34 * @type {boolean} | |
35 * @private | |
36 */ | |
37 this.checkable_ = checkable; | 28 this.checkable_ = checkable; |
38 /** | 29 /** @private {!Object} */ |
39 * @type {!Object} | |
40 * @private | |
41 */ | |
42 this.childIds_ = {}; | 30 this.childIds_ = {}; |
43 /** | 31 /** @private {string} */ |
44 * @type {string} | |
45 * @private | |
46 */ | |
47 this.parentId_ = ''; | 32 this.parentId_ = ''; |
48 }; | 33 }; |
49 | 34 |
50 /** | 35 /** |
51 * Add a submenu item, or update the title of an existing submenu item. | 36 * Add a submenu item, or update the title of an existing submenu item. |
52 * | 37 * |
53 * @param {string} id The child id. | 38 * @param {string} id The child id. |
54 * @param {string} title The window title. | 39 * @param {string} title The window title. |
55 * @return {boolean} True if a new menu item was created, false if an existing | 40 * @return {boolean} True if a new menu item was created, false if an existing |
56 * menu item was renamed. | 41 * menu item was renamed. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 this.parentId_ = base.generateXsrfToken(); // Use a random id | 85 this.parentId_ = base.generateXsrfToken(); // Use a random id |
101 this.adapter_.create(this.parentId_, this.title_, false); | 86 this.adapter_.create(this.parentId_, this.title_, false); |
102 } | 87 } |
103 } else { | 88 } else { |
104 if (this.parentId_) { | 89 if (this.parentId_) { |
105 this.adapter_.remove(this.parentId_); | 90 this.adapter_.remove(this.parentId_); |
106 this.parentId_ = ''; | 91 this.parentId_ = ''; |
107 } | 92 } |
108 } | 93 } |
109 }; | 94 }; |
OLD | NEW |