| Index: chrome/browser/resources/settings/controls/controlled_button.js
|
| diff --git a/chrome/browser/resources/settings/controls/controlled_button.js b/chrome/browser/resources/settings/controls/controlled_button.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..326f50bde675811ccb6109f376e0ce85581e622e
|
| --- /dev/null
|
| +++ b/chrome/browser/resources/settings/controls/controlled_button.js
|
| @@ -0,0 +1,39 @@
|
| +// 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.
|
| +
|
| +Polymer({
|
| + is: 'controlled-button',
|
| +
|
| + behaviors: [CrPolicyPrefBehavior, PrefControlBehavior],
|
| +
|
| + properties: {
|
| + disabled: {
|
| + type: Boolean,
|
| + computed: 'computeDisabled_(pref)',
|
| + reflectToAttribute: true,
|
| + },
|
| + },
|
| +
|
| + /**
|
| + * @param {!chrome.settingsPrivate.PrefObject} pref
|
| + * @return {boolean} Whether the button is controlled.
|
| + * @private
|
| + */
|
| + computeDisabled_: function(pref) {
|
| + return this.isPrefPolicyControlled(pref);
|
| + },
|
| +
|
| + /**
|
| + * @param {!Event} e
|
| + * @private
|
| + */
|
| + onIndicatorTap_: function(e) {
|
| + // :host([disabled]) applies pointer-events: none;, but we want mouse hover
|
| + // on indicators to work. So we selectively re-enable pointer-events on just
|
| + // the indicator, but disallow taps and clicks from triggering any on-tap on
|
| + // the host itself (i.e. <controlled-button on-tap="...">).
|
| + e.preventDefault();
|
| + e.stopPropagation();
|
| + },
|
| +});
|
|
|