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

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

Issue 1372053002: Flesh out the location-page class to make it more general. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 5 years, 2 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_behavior.js
diff --git a/chrome/browser/resources/settings/prefs/prefs_behavior.js b/chrome/browser/resources/settings/prefs/prefs_behavior.js
new file mode 100644
index 0000000000000000000000000000000000000000..7f339d0120202a50917bbab677742bb3b1d42c35
--- /dev/null
+++ b/chrome/browser/resources/settings/prefs/prefs_behavior.js
@@ -0,0 +1,33 @@
+// Copyright 2015 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.
+
+/**
+ * @fileoverview Common prefs behavior.
+ */
+
+/** @polymerBehavior */
+var PrefsBehavior = {
+ /**
+ * Gets the pref at the given prefPath. Throws if the pref is not found.
+ * @param {string} prefPath
+ * @return {!chrome.settingsPrivate.PrefObject}
+ * @private
+ */
+ getPref_: function(prefPath) {
+ var pref = /** @type {!chrome.settingsPrivate.PrefObject} */(
+ this.get(prefPath, this.prefs));
+ assert(typeof pref != 'undefined', 'Pref is missing: ' + prefPath);
+ return pref;
+ },
+
+ /**
+ * Sets the value of the pref at the given prefPath.
+ * @param {string} prefPath
+ * @param {*} value
+ * @private
+ */
+ setPrefValue_: function(prefPath, value) {
+ this.set('prefs.' + prefPath + '.value', value);
michaelpg 2015/10/26 22:15:22 call this.getPref_ so the assert runs: setPref
Finnur 2015/10/27 11:30:48 Done.
+ },
+};

Powered by Google App Engine
This is Rietveld 408576698