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

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

Issue 2131953002: Site Settings Desktop: Implement protocol handler section. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months 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
new file mode 100644
index 0000000000000000000000000000000000000000..6302d3d6d0aeaddc407298ebe8b25e5775d9f34f
--- /dev/null
+++ b/chrome/browser/resources/settings/site_settings/protocol_handlers.js
@@ -0,0 +1,129 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview
+ * 'protocol-handlers' is the polymer element for showing the
+ * protocol handlers category under Site Settings.
+ */
+
+var MenuActions = {
+ SET_DEFAULT: 'SetDefault',
+ REMOVE: 'Remove',
+};
+
+/**
+ * @typedef {{host: string,
+ * protocol: string,
+ * spec: string}}
+ */
+var HandlerEntry;
+
+/**
+ * @typedef {{default_handler: number,
+ * handlers: !Array<!HandlerEntry>,
+ * has_policy_recommendations: boolean,
+ * is_default_handler_set_by_user: boolean,
+ * protocol: string}}
+ */
+var ProtocolEntry;
+
+Polymer({
+ is: 'protocol-handlers',
+
+ behaviors: [SiteSettingsBehavior, WebUIListenerBehavior],
+
+ properties: {
+ /**
+ * Represents the state of the main toggle shown for the category.
+ */
+ categoryEnabled: Boolean,
+
+ /**
+ * Array of protocols and their handlers.
+ * @type {!Array<!ProtocolEntry>}
+ */
+ protocols: Array,
+ },
+
+ ready: function() {
+ this.addWebUIListener('setHandlersEnabled',
+ this.setHandlersEnabled.bind(this));
+ this.addWebUIListener('setProtocolHandlers',
+ this.setProtocolHandlers.bind(this));
+ this.addWebUIListener('setIgnoredProtocolHandlers',
+ this.setIgnoredProtocolHandlers.bind(this));
+ this.browserProxy.initializeProtocolHandlerList();
+ this.MenuActions = MenuActions;
michaelpg 2016/07/08 20:56:00 this should be in properties to use inside <templa
Finnur 2016/07/10 00:40:16 Done... I think. :)
+ },
+
+ /**
+ * Obtains the description for the main toggle.
+ * @param {number} categoryEnabled Whether the main toggle is enabled.
+ * @return {string} The description to use.
+ * @private
+ */
+ computeHandlersDescription_: function(categoryEnabled) {
+ return this.computeCategoryDesc(
+ settings.ContentSettingsTypes.PROTOCOL_HANDLERS, categoryEnabled, true);
+ },
+
+ /**
+ * Returns whether the given index matches the default handler.
+ * @param {number} index The index to evaluate.
+ * @param {number} defaultHandler The default handler index.
+ * @return {boolean} Whether the item is default.
+ * @private
+ */
+ isDefault_: function(index, defaultHandler) {
+ return defaultHandler == index;
+ },
+
+ /**
+ * Updates the main toggle to set it enabled/disabled.
+ * @param {boolean} The state to set.
michaelpg 2016/07/08 20:56:00 these three are missing param names: @param {boole
Finnur 2016/07/10 00:40:16 Good catch. Done.
+ */
michaelpg 2016/07/08 20:56:00 looks like these three should be @private: setHand
Finnur 2016/07/10 00:40:16 Done.
+ setHandlersEnabled: function(enabled) {
+ this.categoryEnabled = enabled;
+ },
+
+ /**
+ * Updates the list of protocol handlers.
+ * @param {!Array<!ProtocolEntry>} The new protocol handler list.
+ */
+ setProtocolHandlers: function(protocols) {
+ this.protocols = protocols;
+ },
+
+ /**
+ * Updates the list of ignored protocol handlers.
+ * @param {!Array<!ProtocolEntry>} The new (ignored) protocol handler list.
+ */
+ setIgnoredProtocolHandlers: function(args) {
+ // TODO(finnur): Figure this out. Have yet to be able to trigger the C++
+ // side to send this.
+ },
+
+ /**
+ * A handler when the toggle is flipped.
+ * @private
+ */
+ onToggleChange_: function(event) {
+ this.browserProxy.setProtocolHandlerDefault(this.categoryEnabled);
+ },
+
+ /**
+ * A handler when an action 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);
+ }
+ },
+});

Powered by Google App Engine
This is Rietveld 408576698