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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/common/Settings.js

Issue 2678623002: DevTools: pass title when creating settings (Closed)
Patch Set: ac Created 3 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 * @param {!Runtime.Extension} extension 52 * @param {!Runtime.Extension} extension
53 */ 53 */
54 _registerModuleSetting(extension) { 54 _registerModuleSetting(extension) {
55 var descriptor = extension.descriptor(); 55 var descriptor = extension.descriptor();
56 var settingName = descriptor['settingName']; 56 var settingName = descriptor['settingName'];
57 var settingType = descriptor['settingType']; 57 var settingType = descriptor['settingType'];
58 var defaultValue = descriptor['defaultValue']; 58 var defaultValue = descriptor['defaultValue'];
59 var isLocal = !!descriptor['local']; 59 var isLocal = !!descriptor['local'];
60 var setting = settingType === 'regex' ? this.createRegExpSetting(settingName , defaultValue, undefined, isLocal) : 60 var setting = settingType === 'regex' ? this.createRegExpSetting(settingName , defaultValue, undefined, isLocal) :
61 this.createSetting(settingName, defa ultValue, isLocal); 61 this.createSetting(settingName, defa ultValue, isLocal);
62 if (descriptor['title'])
63 setting.setTitle(descriptor['title']);
62 this._moduleSettings.set(settingName, setting); 64 this._moduleSettings.set(settingName, setting);
63 } 65 }
64 66
65 /** 67 /**
66 * @param {string} settingName 68 * @param {string} settingName
67 * @return {!Common.Setting} 69 * @return {!Common.Setting}
68 */ 70 */
69 moduleSetting(settingName) { 71 moduleSetting(settingName) {
70 var setting = this._moduleSettings.get(settingName); 72 var setting = this._moduleSettings.get(settingName);
71 if (!setting) 73 if (!setting)
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 * @param {V} defaultValue 226 * @param {V} defaultValue
225 * @param {!Common.Object} eventSupport 227 * @param {!Common.Object} eventSupport
226 * @param {!Common.SettingsStorage} storage 228 * @param {!Common.SettingsStorage} storage
227 */ 229 */
228 constructor(settings, name, defaultValue, eventSupport, storage) { 230 constructor(settings, name, defaultValue, eventSupport, storage) {
229 this._settings = settings; 231 this._settings = settings;
230 this._name = name; 232 this._name = name;
231 this._defaultValue = defaultValue; 233 this._defaultValue = defaultValue;
232 this._eventSupport = eventSupport; 234 this._eventSupport = eventSupport;
233 this._storage = storage; 235 this._storage = storage;
236 /** @type {string} */
237 this._title = '';
234 } 238 }
235 239
236 /** 240 /**
237 * @param {function(!Common.Event)} listener 241 * @param {function(!Common.Event)} listener
238 * @param {!Object=} thisObject 242 * @param {!Object=} thisObject
239 */ 243 */
240 addChangeListener(listener, thisObject) { 244 addChangeListener(listener, thisObject) {
241 this._eventSupport.addEventListener(this._name, listener, thisObject); 245 this._eventSupport.addEventListener(this._name, listener, thisObject);
242 } 246 }
243 247
244 /** 248 /**
245 * @param {function(!Common.Event)} listener 249 * @param {function(!Common.Event)} listener
246 * @param {!Object=} thisObject 250 * @param {!Object=} thisObject
247 */ 251 */
248 removeChangeListener(listener, thisObject) { 252 removeChangeListener(listener, thisObject) {
249 this._eventSupport.removeEventListener(this._name, listener, thisObject); 253 this._eventSupport.removeEventListener(this._name, listener, thisObject);
250 } 254 }
251 255
252 get name() { 256 get name() {
253 return this._name; 257 return this._name;
254 } 258 }
255 259
256 /** 260 /**
261 * @return {string}
262 */
263 title() {
264 return this._title;
265 }
266
267 /**
268 * @param {string} title
269 */
270 setTitle(title) {
271 this._title = title;
272 }
273
274 /**
257 * @return {V} 275 * @return {V}
258 */ 276 */
259 get() { 277 get() {
260 if (typeof this._value !== 'undefined') 278 if (typeof this._value !== 'undefined')
261 return this._value; 279 return this._value;
262 280
263 this._value = this._defaultValue; 281 this._value = this._defaultValue;
264 if (this._storage.has(this._name)) { 282 if (this._storage.has(this._name)) {
265 try { 283 try {
266 this._value = JSON.parse(this._storage.get(this._name)); 284 this._value = JSON.parse(this._storage.get(this._name));
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 return Common.settings.moduleSetting(settingName); 778 return Common.settings.moduleSetting(settingName);
761 }; 779 };
762 780
763 /** 781 /**
764 * @param {string} settingName 782 * @param {string} settingName
765 * @return {!Common.Setting} 783 * @return {!Common.Setting}
766 */ 784 */
767 Common.settingForTest = function(settingName) { 785 Common.settingForTest = function(settingName) {
768 return Common.settings.settingForTest(settingName); 786 return Common.settings.settingForTest(settingName);
769 }; 787 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698