OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @fileoverview Common prefs behavior. |
| 7 */ |
| 8 |
| 9 /** @polymerBehavior */ |
| 10 var PrefsBehavior = { |
| 11 /** |
| 12 * Gets the pref at the given prefPath. Throws if the pref is not found. |
| 13 * @param {string} prefPath |
| 14 * @return {!chrome.settingsPrivate.PrefObject} |
| 15 * @protected |
| 16 */ |
| 17 getPref: function(prefPath) { |
| 18 var pref = /** @type {!chrome.settingsPrivate.PrefObject} */( |
| 19 this.get(prefPath, this.prefs)); |
| 20 assert(typeof pref != 'undefined', 'Pref is missing: ' + prefPath); |
| 21 return pref; |
| 22 }, |
| 23 |
| 24 /** |
| 25 * Sets the value of the pref at the given prefPath. Throws if the pref is not |
| 26 * found. |
| 27 * @param {string} prefPath |
| 28 * @param {*} value |
| 29 * @protected |
| 30 */ |
| 31 setPrefValue: function(prefPath, value) { |
| 32 this.getPref(prefPath); // Ensures we throw if the pref is not found. |
| 33 this.set('prefs.' + prefPath + '.value', value); |
| 34 }, |
| 35 }; |
OLD | NEW |