Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 case ('global'): | 68 case ('global'): |
| 69 storageType = Common.SettingStorageType.Global; | 69 storageType = Common.SettingStorageType.Global; |
| 70 break; | 70 break; |
| 71 default: | 71 default: |
| 72 storageType = Common.SettingStorageType.Global; | 72 storageType = Common.SettingStorageType.Global; |
| 73 } | 73 } |
| 74 var setting = isRegex ? this.createRegExpSetting(settingName, defaultValue, undefined, storageType) : | 74 var setting = isRegex ? this.createRegExpSetting(settingName, defaultValue, undefined, storageType) : |
| 75 this.createSetting(settingName, defaultValue, storag eType); | 75 this.createSetting(settingName, defaultValue, storag eType); |
| 76 if (descriptor['title']) | 76 if (descriptor['title']) |
| 77 setting.setTitle(descriptor['title']); | 77 setting.setTitle(descriptor['title']); |
| 78 setting.setExtension(extension); | |
| 78 this._moduleSettings.set(settingName, setting); | 79 this._moduleSettings.set(settingName, setting); |
| 79 } | 80 } |
| 80 | 81 |
| 81 /** | 82 /** |
| 82 * @param {string} settingName | 83 * @param {string} settingName |
| 83 * @return {!Common.Setting} | 84 * @return {!Common.Setting} |
| 84 */ | 85 */ |
| 85 moduleSetting(settingName) { | 86 moduleSetting(settingName) { |
| 86 var setting = this._moduleSettings.get(settingName); | 87 var setting = this._moduleSettings.get(settingName); |
| 87 if (!setting) | 88 if (!setting) |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 * @param {!Common.SettingsStorage} storage | 257 * @param {!Common.SettingsStorage} storage |
| 257 */ | 258 */ |
| 258 constructor(settings, name, defaultValue, eventSupport, storage) { | 259 constructor(settings, name, defaultValue, eventSupport, storage) { |
| 259 this._settings = settings; | 260 this._settings = settings; |
| 260 this._name = name; | 261 this._name = name; |
| 261 this._defaultValue = defaultValue; | 262 this._defaultValue = defaultValue; |
| 262 this._eventSupport = eventSupport; | 263 this._eventSupport = eventSupport; |
| 263 this._storage = storage; | 264 this._storage = storage; |
| 264 /** @type {string} */ | 265 /** @type {string} */ |
| 265 this._title = ''; | 266 this._title = ''; |
| 267 this._extension = null; | |
| 266 } | 268 } |
| 267 | 269 |
| 268 /** | 270 /** |
| 269 * @param {function(!Common.Event)} listener | 271 * @param {function(!Common.Event)} listener |
| 270 * @param {!Object=} thisObject | 272 * @param {!Object=} thisObject |
| 271 */ | 273 */ |
| 272 addChangeListener(listener, thisObject) { | 274 addChangeListener(listener, thisObject) { |
| 273 this._eventSupport.addEventListener(this._name, listener, thisObject); | 275 this._eventSupport.addEventListener(this._name, listener, thisObject); |
| 274 } | 276 } |
| 275 | 277 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 335 this._eventSupport.dispatchEventToListeners(this._name, value); | 337 this._eventSupport.dispatchEventToListeners(this._name, value); |
| 336 } | 338 } |
| 337 | 339 |
| 338 remove() { | 340 remove() { |
| 339 this._settings._registry.delete(this._name); | 341 this._settings._registry.delete(this._name); |
| 340 this._settings._moduleSettings.delete(this._name); | 342 this._settings._moduleSettings.delete(this._name); |
| 341 this._storage.remove(this._name); | 343 this._storage.remove(this._name); |
| 342 } | 344 } |
| 343 | 345 |
| 344 /** | 346 /** |
| 347 * @return {?Runtime.Extension} | |
| 348 */ | |
| 349 extension() { | |
| 350 return this._extension; | |
| 351 } | |
| 352 | |
| 353 /** | |
| 354 * @param {!Runtime.Extension} extension | |
| 355 */ | |
| 356 setExtension(extension) { | |
|
dgozman
2017/05/16 18:47:25
Remove this setter, and assign directly above. We
luoe
2017/05/30 20:56:14
Done.
| |
| 357 this._extension = extension; | |
| 358 } | |
| 359 | |
| 360 /** | |
| 345 * @param {string} message | 361 * @param {string} message |
| 346 * @param {string} name | 362 * @param {string} name |
| 347 * @param {string} value | 363 * @param {string} value |
| 348 */ | 364 */ |
| 349 _printSettingsSavingError(message, name, value) { | 365 _printSettingsSavingError(message, name, value) { |
| 350 var errorMessage = | 366 var errorMessage = |
| 351 'Error saving setting with name: ' + this._name + ', value length: ' + v alue.length + '. Error: ' + message; | 367 'Error saving setting with name: ' + this._name + ', value length: ' + v alue.length + '. Error: ' + message; |
| 352 console.error(errorMessage); | 368 console.error(errorMessage); |
| 353 Common.console.error(errorMessage); | 369 Common.console.error(errorMessage); |
| 354 this._storage._dumpSizes(); | 370 this._storage._dumpSizes(); |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 822 return Common.settings.moduleSetting(settingName); | 838 return Common.settings.moduleSetting(settingName); |
| 823 }; | 839 }; |
| 824 | 840 |
| 825 /** | 841 /** |
| 826 * @param {string} settingName | 842 * @param {string} settingName |
| 827 * @return {!Common.Setting} | 843 * @return {!Common.Setting} |
| 828 */ | 844 */ |
| 829 Common.settingForTest = function(settingName) { | 845 Common.settingForTest = function(settingName) { |
| 830 return Common.settings.settingForTest(settingName); | 846 return Common.settings.settingForTest(settingName); |
| 831 }; | 847 }; |
| OLD | NEW |