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-pref-tracker` is a utility element used to track the | 7 * `cr-settings-pref-tracker` is a utility element used to track the |
8 * initialization of a specified preference and throw an error if the pref | 8 * initialization of a specified preference and throw an error if the pref |
9 * is not defined after prefs have all been fetched. | 9 * is not defined after prefs have all been fetched. |
10 * | 10 * |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 * found. | 61 * found. |
62 * @private | 62 * @private |
63 */ | 63 */ |
64 validate_: function() { | 64 validate_: function() { |
65 this.async(function() { | 65 this.async(function() { |
66 // Note that null == undefined. | 66 // Note that null == undefined. |
67 if (CrSettingsPrefs.isInitialized && this.pref == null) { | 67 if (CrSettingsPrefs.isInitialized && this.pref == null) { |
68 // HACK ALERT: This is the best clue we have as to the pref key for | 68 // HACK ALERT: This is the best clue we have as to the pref key for |
69 // this tracker. This value should not be relied upon anywhere or | 69 // this tracker. This value should not be relied upon anywhere or |
70 // actually used besides for this error message. | 70 // actually used besides for this error message. |
71 var keyHint = ''; | 71 var parentControlHTML = this.parentNode && this.parentNode.host && |
72 var parentPrefString = this.parentNode && this.parentNode.host && | 72 this.parentNode.host.outerHTML; |
73 this.parentNode.host.getAttribute('pref'); | |
74 if (parentPrefString) { | |
75 keyHint = parentPrefString.match(/{{([a-z0-9._]+)}}/)[1]; | |
76 } | |
77 | 73 |
78 throw new Error('Pref not found. Key Hint: ' + keyHint); | 74 throw new Error('Pref not found. Parent control:' + |
| 75 (parentControlHTML || 'Unknown'); |
79 } | 76 } |
80 }); | 77 }); |
81 }, | 78 }, |
82 }); | 79 }); |
83 })(); | 80 })(); |
OLD | NEW |