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

Unified Diff: chrome/browser/resources/settings/prefs/prefs.js

Issue 985533002: Set up serving infrastructure for c/b/r/settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean some things up Created 5 years, 10 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/prefs/prefs.js
diff --git a/chrome/browser/resources/settings/prefs/prefs.js b/chrome/browser/resources/settings/prefs/prefs.js
index a50dd7f9852e8b54892725b0cae13f7d54a66405..10abcdba9ba170d0519becb00d4e7dbb60ec2b5d 100644
--- a/chrome/browser/resources/settings/prefs/prefs.js
+++ b/chrome/browser/resources/settings/prefs/prefs.js
@@ -75,6 +75,18 @@ Polymer('cr-settings-prefs', {
// TODO(jlklein): Actually pull the data out of prefs and initialize.
},
+ /**
+ * Converts a camel-case property name to the prefs underscore format.
+ * @param {string} camelCaseName
+ * @return {string} The name with underscores instead of dashes.
+ * @private
+ */
+ camelCaseToUnderscores_: function(camelCaseName) {
+ return camelCaseName.replace(/([A-Z])/g, function($1) {
+ return '_' + $1.toLowerCase();
+ });
+ },
+
/**
* @param {string} propertyPath The path before the property names.
* @param {!Array<string>} added An array of keys which were added.
@@ -88,12 +100,14 @@ Polymer('cr-settings-prefs', {
propertyChangeCallback_: function(
propertyPath, added, removed, changed, getOldValueFn) {
Object.keys(changed).forEach(function(property) {
+ var pref = this.camelCaseToUnderscores_(`${propertyPath}.${property}`);
+ var value = changed[property];
console.log(
- `${propertyPath}.${property}`,
+ pref,
`old : ${getOldValueFn(property)}`,
- `newValue : ${changed[property]}`);
+ `newValue : ${value}`);
// TODO(jlklein): Actually set the changed property back to prefs.
- });
+ }.bind(this));
},
});

Powered by Google App Engine
This is Rietveld 408576698