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

Side by Side 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 unified diff | Download patch
OLDNEW
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
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
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() {
161 return !!this.actionMenuModel_ && (this.actionMenuModel_.index ==
162 this.actionMenuModel_.protocol.default_handler);
163 },
164
165 /**
166 * A handler to show the action menu next to the clicked menu button.
167 * @param {!{model: !{protocol: HandlerEntry, item: ProtocolEntry,
168 * index: number}}} event
169 * @private
170 */
171 showMenu_: function(event) {
172 this.actionMenuModel_ = event.model;
173 /** @type {!CrActionMenuElement} */ (
174 this.$$('dialog[is=cr-action-menu]')).showAt(
175 /** @type {!Element} */ (
176 Polymer.dom(/** @type {!Event} */ (event)).localTarget));
177 }
150 }); 178 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698