OLD | NEW |
1 /* Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 * 'cr-settings-prefs' is an element which serves as a model for | 7 * 'cr-settings-prefs' is an element which serves as a model for |
8 * interaction with settings which are stored in Chrome's | 8 * interaction with settings which are stored in Chrome's |
9 * Preferences. | 9 * Preferences. |
10 * | 10 * |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 enableTapDragging: false, | 68 enableTapDragging: false, |
69 }; | 69 }; |
70 | 70 |
71 // ChromeVox is enbaled/disabled via the 'settings.accessibility' boolean | 71 // ChromeVox is enbaled/disabled via the 'settings.accessibility' boolean |
72 // pref. | 72 // pref. |
73 this.settings.accessibility = false; | 73 this.settings.accessibility = false; |
74 | 74 |
75 // TODO(jlklein): Actually pull the data out of prefs and initialize. | 75 // TODO(jlklein): Actually pull the data out of prefs and initialize. |
76 }, | 76 }, |
77 | 77 |
| 78 /** |
| 79 * Converts a camel-case property name to the prefs underscore format. |
| 80 * @param {string} camelCaseName |
| 81 * @return {string} The name with underscores instead of dashes. |
| 82 * @private |
| 83 */ |
| 84 camelCaseToUnderscores_: function(camelCaseName) { |
| 85 return camelCaseName.replace(/([A-Z])/g, function($1) { |
| 86 return '_' + $1.toLowerCase(); |
| 87 }); |
| 88 }, |
| 89 |
78 /** | 90 /** |
79 * @param {string} propertyPath The path before the property names. | 91 * @param {string} propertyPath The path before the property names. |
80 * @param {!Array<string>} added An array of keys which were added. | 92 * @param {!Array<string>} added An array of keys which were added. |
81 * @param {!Array<string>} removed An array of keys which were removed. | 93 * @param {!Array<string>} removed An array of keys which were removed. |
82 * @param {!Array<string>} changed An array of keys of properties whose | 94 * @param {!Array<string>} changed An array of keys of properties whose |
83 * values changed. | 95 * values changed. |
84 * @param {function(string) : *} getOldValueFn A function which takes a | 96 * @param {function(string) : *} getOldValueFn A function which takes a |
85 * property name and returns the old value for that property. | 97 * property name and returns the old value for that property. |
86 * @private | 98 * @private |
87 */ | 99 */ |
88 propertyChangeCallback_: function( | 100 propertyChangeCallback_: function( |
89 propertyPath, added, removed, changed, getOldValueFn) { | 101 propertyPath, added, removed, changed, getOldValueFn) { |
90 Object.keys(changed).forEach(function(property) { | 102 Object.keys(changed).forEach(function(property) { |
| 103 var pref = this.camelCaseToUnderscores_(`${propertyPath}.${property}`); |
| 104 var value = changed[property]; |
91 console.log( | 105 console.log( |
92 `${propertyPath}.${property}`, | 106 pref, |
93 `old : ${getOldValueFn(property)}`, | 107 `old : ${getOldValueFn(property)}`, |
94 `newValue : ${changed[property]}`); | 108 `newValue : ${value}`); |
95 | 109 |
96 // TODO(jlklein): Actually set the changed property back to prefs. | 110 // TODO(jlklein): Actually set the changed property back to prefs. |
97 }); | 111 }.bind(this)); |
98 }, | 112 }, |
99 }); | 113 }); |
OLD | NEW |