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

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

Issue 1907263002: DevTools: Fix all outstanding JavaScript style issues. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 */ 258 */
259 get: function() 259 get: function()
260 { 260 {
261 if (typeof this._value !== "undefined") 261 if (typeof this._value !== "undefined")
262 return this._value; 262 return this._value;
263 263
264 this._value = this._defaultValue; 264 this._value = this._defaultValue;
265 if (this._storage.has(this._name)) { 265 if (this._storage.has(this._name)) {
266 try { 266 try {
267 this._value = JSON.parse(this._storage.get(this._name)); 267 this._value = JSON.parse(this._storage.get(this._name));
268 } catch(e) { 268 } catch (e) {
269 this._storage.remove(this._name); 269 this._storage.remove(this._name);
270 } 270 }
271 } 271 }
272 return this._value; 272 return this._value;
273 }, 273 },
274 274
275 /** 275 /**
276 * @param {V} value 276 * @param {V} value
277 */ 277 */
278 set: function(value) 278 set: function(value)
279 { 279 {
280 this._value = value; 280 this._value = value;
281 try { 281 try {
282 var settingString = JSON.stringify(value); 282 var settingString = JSON.stringify(value);
283 try { 283 try {
284 this._storage.set(this._name, settingString); 284 this._storage.set(this._name, settingString);
285 } catch(e) { 285 } catch (e) {
286 this._printSettingsSavingError(e.message, this._name, settingStr ing); 286 this._printSettingsSavingError(e.message, this._name, settingStr ing);
287 } 287 }
288 } catch(e) { 288 } catch (e) {
289 WebInspector.console.error("Cannot stringify setting with name: " + this._name + ", error: " + e.message); 289 WebInspector.console.error("Cannot stringify setting with name: " + this._name + ", error: " + e.message);
290 } 290 }
291 this._eventSupport.dispatchEventToListeners(this._name, value); 291 this._eventSupport.dispatchEventToListeners(this._name, value);
292 }, 292 },
293 293
294 remove: function() 294 remove: function()
295 { 295 {
296 this._settings._registry.delete(this._name); 296 this._settings._registry.delete(this._name);
297 this._settings._moduleSettings.delete(this._name); 297 this._settings._moduleSettings.delete(this._name);
298 this._storage.remove(this._name); 298 this._storage.remove(this._name);
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 }; 512 };
513 513
514 for (var oldName in settingNames) { 514 for (var oldName in settingNames) {
515 var oldSetting = WebInspector.settings.createSetting(oldName, null); 515 var oldSetting = WebInspector.settings.createSetting(oldName, null);
516 if (oldSetting.get() === null) { 516 if (oldSetting.get() === null) {
517 oldSetting.remove(); 517 oldSetting.remove();
518 continue; 518 continue;
519 } 519 }
520 520
521 var newName = settingNames[oldName]; 521 var newName = settingNames[oldName];
522 var invert = "WebInspector.Drawer.showOnLoad" === oldName; 522 var invert = oldName === "WebInspector.Drawer.showOnLoad";
523 var hidden = oldSetting.get() !== invert; 523 var hidden = oldSetting.get() !== invert;
524 oldSetting.remove(); 524 oldSetting.remove();
525 var showMode = hidden ? "OnlyMain" : "Both"; 525 var showMode = hidden ? "OnlyMain" : "Both";
526 526
527 var newSetting = WebInspector.settings.createSetting(newName, {}); 527 var newSetting = WebInspector.settings.createSetting(newName, {});
528 var newValue = newSetting.get() || {}; 528 var newValue = newSetting.get() || {};
529 newValue.vertical = newValue.vertical || {}; 529 newValue.vertical = newValue.vertical || {};
530 newValue.vertical.showMode = showMode; 530 newValue.vertical.showMode = showMode;
531 newValue.horizontal = newValue.horizontal || {}; 531 newValue.horizontal = newValue.horizontal || {};
532 newValue.horizontal.showMode = showMode; 532 newValue.horizontal.showMode = showMode;
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 } 746 }
747 747
748 /** 748 /**
749 * @param {string} settingName 749 * @param {string} settingName
750 * @return {!WebInspector.Setting} 750 * @return {!WebInspector.Setting}
751 */ 751 */
752 WebInspector.settingForTest = function(settingName) 752 WebInspector.settingForTest = function(settingName)
753 { 753 {
754 return WebInspector.settings.settingForTest(settingName); 754 return WebInspector.settings.settingForTest(settingName);
755 } 755 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698