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

Side by Side Diff: chrome/browser/resources/options/preferences.js

Issue 2935011: Initial accounts options page. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: use ListItem directly for now per arv Created 10 years, 5 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 unified diff | Download patch
OLDNEW
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 /////////////////////////////////////////////////////////////////////////////// 5 ///////////////////////////////////////////////////////////////////////////////
6 // Preferences class: 6 // Preferences class:
7 7
8 /** 8 /**
9 * Preferences class manages access to Chrome profile preferences. 9 * Preferences class manages access to Chrome profile preferences.
10 * @constructor 10 * @constructor
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 /** 66 /**
67 * Sets value of a string preference. 67 * Sets value of a string preference.
68 * and signals its changed value. 68 * and signals its changed value.
69 * @param {string} name Preference name. 69 * @param {string} name Preference name.
70 * @param {string} value New preference value. 70 * @param {string} value New preference value.
71 */ 71 */
72 Preferences.setStringPref = function(name, value) { 72 Preferences.setStringPref = function(name, value) {
73 chrome.send('setStringPref', [name, value]); 73 chrome.send('setStringPref', [name, value]);
74 }; 74 };
75 75
76 /**
77 * Sets value of a JSON preference.
78 * and signals its changed value.
79 * @param {string} name Preference name.
80 * @param {string} value New preference value.
81 */
82 Preferences.setObjectPref = function(name, value) {
83 chrome.send('setObjectPref', [name, JSON.stringify(value)]);
84 };
85
76 Preferences.prototype = { 86 Preferences.prototype = {
77 __proto__: cr.EventTarget.prototype, 87 __proto__: cr.EventTarget.prototype,
78 88
79 // Map of registered preferences. 89 // Map of registered preferences.
80 registeredPreferences_: {}, 90 registeredPreferences_: {},
81 91
82 /** 92 /**
83 * Adds an event listener to the target. 93 * Adds an event listener to the target.
84 * @param {string} type The name of the event. 94 * @param {string} type The name of the event.
85 * @param {!Function|{handleEvent:Function}} handler The handler for the 95 * @param {!Function|{handleEvent:Function}} handler The handler for the
(...skipping 19 matching lines...) Expand all
105 }, 115 },
106 116
107 /** 117 /**
108 * Helper function for flattening of dictionary passed via fetchPrefs 118 * Helper function for flattening of dictionary passed via fetchPrefs
109 * callback. 119 * callback.
110 * @param {string} prefix Preference name prefix. 120 * @param {string} prefix Preference name prefix.
111 * @param {object} dict Map with preference values. 121 * @param {object} dict Map with preference values.
112 */ 122 */
113 flattenMapAndDispatchEvent_: function(prefix, dict) { 123 flattenMapAndDispatchEvent_: function(prefix, dict) {
114 for (var prefName in dict) { 124 for (var prefName in dict) {
115 if (typeof dict[prefName] == 'object') { 125 if (typeof dict[prefName] == 'object' &&
126 !this.registeredPreferences_[prefix + prefName]) {
116 this.flattenMapAndDispatchEvent_(prefix + prefName + '.', 127 this.flattenMapAndDispatchEvent_(prefix + prefName + '.',
117 dict[prefName]); 128 dict[prefName]);
118 } else { 129 } else {
119 var event = new cr.Event(prefix + prefName); 130 var event = new cr.Event(prefix + prefName);
120 event.value = dict[prefName]; 131 event.value = dict[prefName];
121 this.dispatchEvent(event); 132 this.dispatchEvent(event);
122 } 133 }
123 } 134 }
124 } 135 }
125 }; 136 };
(...skipping 12 matching lines...) Expand all
138 * notification[0] contains name of the change preference while its new value 149 * notification[0] contains name of the change preference while its new value
139 * is stored in notification[1]. 150 * is stored in notification[1].
140 */ 151 */
141 Preferences.prefsChangedCallback = function(notification) { 152 Preferences.prefsChangedCallback = function(notification) {
142 var event = new cr.Event(notification[0]); 153 var event = new cr.Event(notification[0]);
143 event.value = notification[1]; 154 event.value = notification[1];
144 Preferences.getInstance().dispatchEvent(event); 155 Preferences.getInstance().dispatchEvent(event);
145 }; 156 };
146 157
147 158
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/options_page.js ('k') | chrome/browser/resources/shared/js/cr/ui/array_data_model.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698