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 * @private | |
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 * @private | |
30 */ | |
31 setPrefValue_: function(prefPath, value) { | |
Dan Beam
2015/10/29 21:10:39
these should be @protected or public
Finnur
2015/10/30 12:13:46
Sure. Protected kind of makes sense in this contex
| |
32 this.getPref_(prefPath); // Ensures we throw if the pref is not found. | |
33 this.set('prefs.' + prefPath + '.value', value); | |
34 }, | |
35 }; | |
OLD | NEW |