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 |
| 144 if (event.detail.selected == MenuActions.SET_DEFAULT) { | 138 this.$$('dialog[is=cr-action-menu]').close(); |
| 145 this.browserProxy.setProtocolDefault(protocol, url); | 139 this.actionMenuModel_ = null; |
| 146 } else if (event.detail.selected == MenuActions.REMOVE) { | 140 this.browserProxy.setProtocolDefault(item.protocol, item.spec); |
| 147 this.browserProxy.removeProtocolHandler(protocol, url); | |
| 148 } | |
| 149 }, | 141 }, |
| 142 | |
| 143 /** | |
| 144 * The handler for when "Remove" is selected in the action menu. | |
| 145 * @private | |
| 146 */ | |
| 147 onRemoveTap_: function() { | |
| 148 var item = this.actionMenuModel_.item; | |
| 149 | |
| 150 this.$$('dialog[is=cr-action-menu]').close(); | |
| 151 this.actionMenuModel_ = null; | |
| 152 this.browserProxy.removeProtocolHandler(item.protocol, item.spec); | |
| 153 }, | |
| 154 | |
| 155 /** | |
| 156 * Checks whether or not the selected actionMenuModel is the default handler | |
| 157 * for its protocol. | |
| 158 * @return {boolean} if actionMenuModel_ is default handler of its protocol. | |
| 159 */ | |
| 160 isModelDefault_: function(model) { | |
|
dpapad
2016/11/14 21:54:09
Do you need to declare the parameter here? Why not
scottchen
2016/11/14 22:06:01
Ah, this is the remnant of my attempt to merge the
| |
| 161 return model && (model.index == model.protocol.default_handler); | |
|
dpapad
2016/11/14 21:54:09
Indentation off by 1.
scottchen
2016/11/14 22:06:14
Done.
| |
| 162 }, | |
| 163 | |
| 164 /** | |
| 165 * A handler to show the action menu next to the clicked menu button. | |
| 166 * @param {!{model: !{protocol: HandlerEntry, item: ProtocolEntry, | |
| 167 * index: number}}} event | |
| 168 * @private | |
| 169 */ | |
| 170 showMenu_: function(event) { | |
| 171 this.actionMenuModel_ = event.model; | |
| 172 /** @type {!CrActionMenuElement} */ ( | |
| 173 this.$$('dialog[is=cr-action-menu]')).showAt( | |
| 174 /** @type {!Element} */ ( | |
| 175 Polymer.dom(/** @type {!Event} */ (event)).localTarget)); | |
| 176 } | |
| 150 }); | 177 }); |
| OLD | NEW |