Chromium Code Reviews| Index: chrome/browser/resources/settings/site_settings/protocol_handlers.js |
| diff --git a/chrome/browser/resources/settings/site_settings/protocol_handlers.js b/chrome/browser/resources/settings/site_settings/protocol_handlers.js |
| index 404d3df1dae065d45fdc772379c1a1835e0784fb..58f03ff27e066c3f3d7f67b34807aef18800c7e5 100644 |
| --- a/chrome/browser/resources/settings/site_settings/protocol_handlers.js |
| +++ b/chrome/browser/resources/settings/site_settings/protocol_handlers.js |
| @@ -51,14 +51,10 @@ Polymer({ |
| protocols: Array, |
| /** |
| - * The possible menu actions. |
| - * @type {MenuActions} |
| + * The targetted object for menu operations. |
| + * @private {?Object} |
| */ |
| - menuActions_: { |
| - type: Object, |
| - value: MenuActions, |
| - readOnly: true, |
| - }, |
| + actionMenuModel_: Object |
| }, |
| ready: function() { |
| @@ -133,18 +129,49 @@ Polymer({ |
| }, |
| /** |
| - * A handler when an action is selected in the action menu. |
| - * @param {!{model: !{item: ProtocolHandlerEntry}, |
| - * detail: !{selected: string}}} event |
| + * The handler for when "Set Default" is selected in the action menu. |
| * @private |
| */ |
| - onActionMenuIronActivate_: function(event) { |
| - var protocol = event.model.item.protocol; |
| - var url = event.model.item.spec; |
| - if (event.detail.selected == MenuActions.SET_DEFAULT) { |
| - this.browserProxy.setProtocolDefault(protocol, url); |
| - } else if (event.detail.selected == MenuActions.REMOVE) { |
| - this.browserProxy.removeProtocolHandler(protocol, url); |
| - } |
| + onDefaultTap_: function() { |
| + var item = this.actionMenuModel_.item; |
| + |
| + this.$$('dialog[is=cr-action-menu]').close(); |
| + this.actionMenuModel_ = null; |
| + this.browserProxy.setProtocolDefault(item.protocol, item.spec); |
| + }, |
| + |
| + /** |
| + * The handler for when "Remove" is selected in the action menu. |
| + * @private |
| + */ |
| + onRemoveTap_: function() { |
| + var item = this.actionMenuModel_.item; |
| + |
| + this.$$('dialog[is=cr-action-menu]').close(); |
| + this.actionMenuModel_ = null; |
| + this.browserProxy.removeProtocolHandler(item.protocol, item.spec); |
| }, |
| + |
| + /** |
| + * Checks whether or not the selected actionMenuModel is the default handler |
| + * for its protocol. |
| + * @return {boolean} if actionMenuModel_ is default handler of its protocol. |
| + */ |
| + 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
|
| + 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.
|
| + }, |
| + |
| + /** |
| + * A handler to show the action menu next to the clicked menu button. |
| + * @param {!{model: !{protocol: HandlerEntry, item: ProtocolEntry, |
| + * index: number}}} event |
| + * @private |
| + */ |
| + showMenu_: function(event) { |
| + this.actionMenuModel_ = event.model; |
| + /** @type {!CrActionMenuElement} */ ( |
| + this.$$('dialog[is=cr-action-menu]')).showAt( |
| + /** @type {!Element} */ ( |
| + Polymer.dom(/** @type {!Event} */ (event)).localTarget)); |
| + } |
| }); |