Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 * 'protocol-handlers' is the polymer element for showing the | 7 * 'protocol-handlers' is the polymer element for showing the |
| 8 * protocol handlers category under Site Settings. | 8 * protocol handlers category under Site Settings. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 */ | 44 */ |
| 45 categoryEnabled: Boolean, | 45 categoryEnabled: Boolean, |
| 46 | 46 |
| 47 /** | 47 /** |
| 48 * Array of protocols and their handlers. | 48 * Array of protocols and their handlers. |
| 49 * @type {!Array<!ProtocolEntry>} | 49 * @type {!Array<!ProtocolEntry>} |
| 50 */ | 50 */ |
| 51 protocols: Array, | 51 protocols: Array, |
| 52 | 52 |
| 53 /** | 53 /** |
| 54 * The possible menu actions. | 54 * The targetted object for menu operations. |
| 55 * @type {MenuActions} | 55 * @private {?Object} |
| 56 */ | 56 */ |
| 57 menuActions_: { | 57 actionMenuModel_: Object |
| 58 type: Object, | |
| 59 value: MenuActions, | |
| 60 readOnly: true, | |
| 61 }, | |
| 62 }, | 58 }, |
| 63 | 59 |
| 64 ready: function() { | 60 ready: function() { |
| 65 this.addWebUIListener('setHandlersEnabled', | 61 this.addWebUIListener('setHandlersEnabled', |
| 66 this.setHandlersEnabled_.bind(this)); | 62 this.setHandlersEnabled_.bind(this)); |
| 67 this.addWebUIListener('setProtocolHandlers', | 63 this.addWebUIListener('setProtocolHandlers', |
| 68 this.setProtocolHandlers_.bind(this)); | 64 this.setProtocolHandlers_.bind(this)); |
| 69 this.addWebUIListener('setIgnoredProtocolHandlers', | 65 this.addWebUIListener('setIgnoredProtocolHandlers', |
| 70 this.setIgnoredProtocolHandlers_.bind(this)); | 66 this.setIgnoredProtocolHandlers_.bind(this)); |
| 71 this.browserProxy.initializeProtocolHandlerList(); | 67 this.browserProxy.initializeProtocolHandlerList(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 | 122 |
| 127 /** | 123 /** |
| 128 * A handler when the toggle is flipped. | 124 * A handler when the toggle is flipped. |
| 129 * @private | 125 * @private |
| 130 */ | 126 */ |
| 131 onToggleChange_: function(event) { | 127 onToggleChange_: function(event) { |
| 132 this.browserProxy.setProtocolHandlerDefault(this.categoryEnabled); | 128 this.browserProxy.setProtocolHandlerDefault(this.categoryEnabled); |
| 133 }, | 129 }, |
| 134 | 130 |
| 135 /** | 131 /** |
| 136 * A handler when an action is selected in the action menu. | 132 * The handler for when "Set Default" is selected in the action menu. |
| 137 * @param {!{model: !{item: ProtocolHandlerEntry}, | |
| 138 * detail: !{selected: string}}} event | |
| 139 * @private | 133 * @private |
| 140 */ | 134 */ |
| 141 onActionMenuIronActivate_: function(event) { | 135 onDefaultTap_: function() { |
| 142 var protocol = event.model.item.protocol; | 136 var item = this.actionMenuModel_.item; |
| 143 var url = event.model.item.spec; | 137 var protocol = item.protocol; |
| 144 if (event.detail.selected == MenuActions.SET_DEFAULT) { | 138 var url = item.spec; |
| 145 this.browserProxy.setProtocolDefault(protocol, url); | 139 |
| 146 } else if (event.detail.selected == MenuActions.REMOVE) { | 140 this.$$('dialog[is=cr-action-menu]').close(); |
| 147 this.browserProxy.removeProtocolHandler(protocol, url); | 141 this.actionMenuModel_ = null; |
| 148 } | 142 this.browserProxy.setProtocolDefault(protocol, url); |
| 149 }, | 143 }, |
| 144 | |
| 145 /** | |
| 146 * The handler for when "Remove" is selected in the action menu. | |
| 147 * @private | |
| 148 */ | |
| 149 onRemoveTap_: function() { | |
| 150 var item = this.actionMenuModel_.item; | |
| 151 var protocol = item.protocol; | |
| 152 var url = item.spec; | |
| 153 | |
| 154 this.$$('dialog[is=cr-action-menu]').close(); | |
| 155 this.actionMenuModel_ = null; | |
| 156 this.browserProxy.removeProtocolHandler(protocol, url); | |
|
dpapad
2016/11/14 18:26:20
Nit: local vars protocol and url, don't seem to ad
scottchen
2016/11/14 21:38:36
Done.
| |
| 157 }, | |
| 158 | |
| 159 /** | |
| 160 * A handler to show the action menu next to the clicked menu button. | |
| 161 * @param {!{model: !{protocol: HandlerEntry, item: ProtocolEntry, | |
| 162 * index: number}}} event | |
| 163 * @private | |
| 164 */ | |
| 165 showMenu_: function(event) { | |
| 166 this.actionMenuModel_ = event.model; | |
| 167 /** @type {!CrActionMenuElement} */ ( | |
| 168 this.$$('dialog[is=cr-action-menu]')).showAt( | |
| 169 /** @type {!Element} */ ( | |
| 170 Polymer.dom(/** @type {!Event} */ (event)).localTarget)); | |
| 171 } | |
| 150 }); | 172 }); |
| OLD | NEW |