Index: third_party/WebKit/Source/devtools/front_end/common/Settings.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/common/Settings.js b/third_party/WebKit/Source/devtools/front_end/common/Settings.js |
index 0c5f8d87a4aaacc4f917107aaf4aacd25450ef01..1c08d57919290624aa783a18aac575d9dd2f1ddc 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/common/Settings.js |
+++ b/third_party/WebKit/Source/devtools/front_end/common/Settings.js |
@@ -35,10 +35,12 @@ Common.Settings = class { |
/** |
* @param {!Common.SettingsStorage} globalStorage |
* @param {!Common.SettingsStorage} localStorage |
+ * @param {!Common.SettingsStorage} sessionStorage |
*/ |
- constructor(globalStorage, localStorage) { |
+ constructor(globalStorage, localStorage, sessionStorage) { |
this._settingsStorage = globalStorage; |
this._localStorage = localStorage; |
+ this._sessionStorage = sessionStorage; |
this._eventSupport = new Common.Object(); |
/** @type {!Map<string, !Common.Setting>} */ |
@@ -54,11 +56,12 @@ Common.Settings = class { |
_registerModuleSetting(extension) { |
var descriptor = extension.descriptor(); |
var settingName = descriptor['settingName']; |
- var settingType = descriptor['settingType']; |
+ var isRegex = descriptor['settingType'] === 'regex'; |
var defaultValue = descriptor['defaultValue']; |
- var isLocal = !!descriptor['local']; |
- var setting = settingType === 'regex' ? this.createRegExpSetting(settingName, defaultValue, undefined, isLocal) : |
- this.createSetting(settingName, defaultValue, isLocal); |
+ var localType = !!descriptor['local'] ? Common.SettingStorageType.Local : Common.SettingStorageType.Global; |
+ var storageType = !!descriptor['session'] ? Common.SettingStorageType.Session : localType; |
+ var setting = isRegex ? this.createRegExpSetting(settingName, defaultValue, undefined, storageType) : |
+ this.createSetting(settingName, defaultValue, storageType); |
if (descriptor['title']) |
setting.setTitle(descriptor['title']); |
this._moduleSettings.set(settingName, setting); |
@@ -89,15 +92,13 @@ Common.Settings = class { |
/** |
* @param {string} key |
* @param {*} defaultValue |
- * @param {boolean=} isLocal |
+ * @param {!Common.SettingStorageType=} storageType |
* @return {!Common.Setting} |
*/ |
- createSetting(key, defaultValue, isLocal) { |
- if (!this._registry.get(key)) { |
- this._registry.set( |
- key, new Common.Setting( |
- this, key, defaultValue, this._eventSupport, isLocal ? this._localStorage : this._settingsStorage)); |
- } |
+ createSetting(key, defaultValue, storageType) { |
+ var storage = this._storageFromType(storageType); |
+ if (!this._registry.get(key)) |
+ this._registry.set(key, new Common.Setting(this, key, defaultValue, this._eventSupport, storage)); |
return /** @type {!Common.Setting} */ (this._registry.get(key)); |
} |
@@ -107,22 +108,21 @@ Common.Settings = class { |
* @return {!Common.Setting} |
*/ |
createLocalSetting(key, defaultValue) { |
- return this.createSetting(key, defaultValue, true); |
+ return this.createSetting(key, defaultValue, Common.SettingStorageType.Local); |
} |
/** |
* @param {string} key |
* @param {string} defaultValue |
* @param {string=} regexFlags |
- * @param {boolean=} isLocal |
+ * @param {!Common.SettingStorageType=} storageType |
* @return {!Common.RegExpSetting} |
*/ |
- createRegExpSetting(key, defaultValue, regexFlags, isLocal) { |
+ createRegExpSetting(key, defaultValue, regexFlags, storageType) { |
if (!this._registry.get(key)) { |
this._registry.set( |
key, new Common.RegExpSetting( |
- this, key, defaultValue, this._eventSupport, isLocal ? this._localStorage : this._settingsStorage, |
- regexFlags)); |
+ this, key, defaultValue, this._eventSupport, this._storageFromType(storageType), regexFlags)); |
} |
return /** @type {!Common.RegExpSetting} */ (this._registry.get(key)); |
} |
@@ -133,6 +133,22 @@ Common.Settings = class { |
var versionSetting = Common.settings.createSetting(Common.VersionController._currentVersionName, 0); |
versionSetting.set(Common.VersionController.currentVersion); |
} |
+ |
+ /** |
+ * @param {!Common.SettingStorageType=} storageType |
+ * @return {!Common.SettingsStorage} |
+ */ |
+ _storageFromType(storageType) { |
+ switch (storageType) { |
+ case (Common.SettingStorageType.Local): |
+ return this._localStorage; |
+ case (Common.SettingStorageType.Session): |
+ return this._sessionStorage; |
+ case (Common.SettingStorageType.Global): |
+ default: |
+ return this._settingsStorage; |
+ } |
+ } |
}; |
/** |
@@ -771,6 +787,15 @@ Common.VersionController.currentVersion = 23; |
Common.settings; |
/** |
+ * @enum {symbol} |
+ */ |
+Common.SettingStorageType = { |
+ Global: Symbol('Global'), |
+ Local: Symbol('Local'), |
+ Session: Symbol('Session') |
+}; |
+ |
+/** |
* @param {string} settingName |
* @return {!Common.Setting} |
*/ |