Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3402)

Unified Diff: chrome/browser/resources/settings/site_settings/protocol_handlers.js

Issue 2500513003: Make setting's protocol handler use cr-action-menu instead of paper-item. (Closed)
Patch Set: fix return type of boolean function Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..b175e83ed827e2b9d1efc0606dbcef6e70a219a1 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,50 @@ 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() {
+ return !!this.actionMenuModel_ && (this.actionMenuModel_.index ==
+ this.actionMenuModel_.protocol.default_handler);
+ },
+
+ /**
+ * 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));
+ }
});

Powered by Google App Engine
This is Rietveld 408576698