| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 cr.define('options', function() { | 5 cr.define('options', function() { |
| 6 | 6 |
| 7 ///////////////////////////////////////////////////////////////////////////// | 7 ///////////////////////////////////////////////////////////////////////////// |
| 8 // Preferences class: | 8 // Preferences class: |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 * @param {string} name Preference name. | 81 * @param {string} name Preference name. |
| 82 * @param {string} value New preference value. | 82 * @param {string} value New preference value. |
| 83 * @param {string} metric User metrics identifier. | 83 * @param {string} metric User metrics identifier. |
| 84 */ | 84 */ |
| 85 Preferences.setObjectPref = function(name, value, metric) { | 85 Preferences.setObjectPref = function(name, value, metric) { |
| 86 var arguments = [name, JSON.stringify(value)]; | 86 var arguments = [name, JSON.stringify(value)]; |
| 87 if (metric != undefined) arguments.push(metric); | 87 if (metric != undefined) arguments.push(metric); |
| 88 chrome.send('setObjectPref', arguments); | 88 chrome.send('setObjectPref', arguments); |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 /** |
| 92 * Clears value of a JSON preference. |
| 93 * @param {string} name Preference name. |
| 94 * @param {string} metric User metrics identifier. |
| 95 */ |
| 96 Preferences.clearPref = function(name, metric) { |
| 97 var arguments = [name]; |
| 98 if (metric != undefined) arguments.push(metric); |
| 99 chrome.send('clearPref', arguments); |
| 100 }; |
| 101 |
| 91 Preferences.prototype = { | 102 Preferences.prototype = { |
| 92 __proto__: cr.EventTarget.prototype, | 103 __proto__: cr.EventTarget.prototype, |
| 93 | 104 |
| 94 // Map of registered preferences. | 105 // Map of registered preferences. |
| 95 registeredPreferences_: {}, | 106 registeredPreferences_: {}, |
| 96 | 107 |
| 97 /** | 108 /** |
| 98 * Adds an event listener to the target. | 109 * Adds an event listener to the target. |
| 99 * @param {string} type The name of the event. | 110 * @param {string} type The name of the event. |
| 100 * @param {!Function|{handleEvent:Function}} handler The handler for the | 111 * @param {!Function|{handleEvent:Function}} handler The handler for the |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 Preferences.getInstance().dispatchEvent(event); | 171 Preferences.getInstance().dispatchEvent(event); |
| 161 }; | 172 }; |
| 162 | 173 |
| 163 // Export | 174 // Export |
| 164 return { | 175 return { |
| 165 Preferences: Preferences | 176 Preferences: Preferences |
| 166 }; | 177 }; |
| 167 | 178 |
| 168 }); | 179 }); |
| 169 | 180 |
| OLD | NEW |