| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Nokia Inc. All rights reserved. | 2 * Copyright (C) 2008 Nokia Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Samsung Electronics. All rights reserved. | 3 * Copyright (C) 2013 Samsung Electronics. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| 11 * 2. Redistributions in binary form must reproduce the above copyright | 11 * 2. Redistributions in binary form must reproduce the above copyright |
| 12 * notice, this list of conditions and the following disclaimer in the | 12 * notice, this list of conditions and the following disclaimer in the |
| 13 * documentation and/or other materials provided with the distribution. | 13 * documentation and/or other materials provided with the distribution. |
| 14 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of | 14 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of |
| 15 * its contributors may be used to endorse or promote products derived | 15 * its contributors may be used to endorse or promote products derived |
| 16 * from this software without specific prior written permission. | 16 * from this software without specific prior written permission. |
| 17 * | 17 * |
| 18 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY | 18 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY |
| 19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | 21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 */ | 28 */ |
| 29 | |
| 30 /** | 29 /** |
| 31 * @constructor | 30 * @unrestricted |
| 32 * @extends {WebInspector.Object} | |
| 33 * @param {!WebInspector.DOMStorageModel} model | |
| 34 * @param {string} securityOrigin | |
| 35 * @param {boolean} isLocalStorage | |
| 36 */ | 31 */ |
| 37 WebInspector.DOMStorage = function(model, securityOrigin, isLocalStorage) | 32 WebInspector.DOMStorage = class extends WebInspector.Object { |
| 38 { | 33 /** |
| 34 * @param {!WebInspector.DOMStorageModel} model |
| 35 * @param {string} securityOrigin |
| 36 * @param {boolean} isLocalStorage |
| 37 */ |
| 38 constructor(model, securityOrigin, isLocalStorage) { |
| 39 super(); |
| 39 this._model = model; | 40 this._model = model; |
| 40 this._securityOrigin = securityOrigin; | 41 this._securityOrigin = securityOrigin; |
| 41 this._isLocalStorage = isLocalStorage; | 42 this._isLocalStorage = isLocalStorage; |
| 42 }; | 43 } |
| 43 | 44 |
| 44 /** | 45 /** |
| 45 * @param {string} securityOrigin | 46 * @param {string} securityOrigin |
| 46 * @param {boolean} isLocalStorage | 47 * @param {boolean} isLocalStorage |
| 47 * @return {!DOMStorageAgent.StorageId} | 48 * @return {!DOMStorageAgent.StorageId} |
| 48 */ | 49 */ |
| 49 WebInspector.DOMStorage.storageId = function(securityOrigin, isLocalStorage) | 50 static storageId(securityOrigin, isLocalStorage) { |
| 50 { | 51 return {securityOrigin: securityOrigin, isLocalStorage: isLocalStorage}; |
| 51 return { securityOrigin: securityOrigin, isLocalStorage: isLocalStorage }; | 52 } |
| 52 }; | 53 |
| 54 /** @return {!DOMStorageAgent.StorageId} */ |
| 55 get id() { |
| 56 return WebInspector.DOMStorage.storageId(this._securityOrigin, this._isLocal
Storage); |
| 57 } |
| 58 |
| 59 /** @return {string} */ |
| 60 get securityOrigin() { |
| 61 return this._securityOrigin; |
| 62 } |
| 63 |
| 64 /** @return {boolean} */ |
| 65 get isLocalStorage() { |
| 66 return this._isLocalStorage; |
| 67 } |
| 68 |
| 69 /** |
| 70 * @param {function(?Protocol.Error, !Array.<!DOMStorageAgent.Item>):void=} ca
llback |
| 71 */ |
| 72 getItems(callback) { |
| 73 this._model._agent.getDOMStorageItems(this.id, callback); |
| 74 } |
| 75 |
| 76 /** |
| 77 * @param {string} key |
| 78 * @param {string} value |
| 79 */ |
| 80 setItem(key, value) { |
| 81 this._model._agent.setDOMStorageItem(this.id, key, value); |
| 82 } |
| 83 |
| 84 /** |
| 85 * @param {string} key |
| 86 */ |
| 87 removeItem(key) { |
| 88 this._model._agent.removeDOMStorageItem(this.id, key); |
| 89 } |
| 90 }; |
| 91 |
| 53 | 92 |
| 54 /** @enum {symbol} */ | 93 /** @enum {symbol} */ |
| 55 WebInspector.DOMStorage.Events = { | 94 WebInspector.DOMStorage.Events = { |
| 56 DOMStorageItemsCleared: Symbol("DOMStorageItemsCleared"), | 95 DOMStorageItemsCleared: Symbol('DOMStorageItemsCleared'), |
| 57 DOMStorageItemRemoved: Symbol("DOMStorageItemRemoved"), | 96 DOMStorageItemRemoved: Symbol('DOMStorageItemRemoved'), |
| 58 DOMStorageItemAdded: Symbol("DOMStorageItemAdded"), | 97 DOMStorageItemAdded: Symbol('DOMStorageItemAdded'), |
| 59 DOMStorageItemUpdated: Symbol("DOMStorageItemUpdated") | 98 DOMStorageItemUpdated: Symbol('DOMStorageItemUpdated') |
| 60 }; | |
| 61 | |
| 62 WebInspector.DOMStorage.prototype = { | |
| 63 | |
| 64 /** @return {!DOMStorageAgent.StorageId} */ | |
| 65 get id() | |
| 66 { | |
| 67 return WebInspector.DOMStorage.storageId(this._securityOrigin, this._isL
ocalStorage); | |
| 68 }, | |
| 69 | |
| 70 /** @return {string} */ | |
| 71 get securityOrigin() | |
| 72 { | |
| 73 return this._securityOrigin; | |
| 74 }, | |
| 75 | |
| 76 /** @return {boolean} */ | |
| 77 get isLocalStorage() | |
| 78 { | |
| 79 return this._isLocalStorage; | |
| 80 }, | |
| 81 | |
| 82 /** | |
| 83 * @param {function(?Protocol.Error, !Array.<!DOMStorageAgent.Item>):void=}
callback | |
| 84 */ | |
| 85 getItems: function(callback) | |
| 86 { | |
| 87 this._model._agent.getDOMStorageItems(this.id, callback); | |
| 88 }, | |
| 89 | |
| 90 /** | |
| 91 * @param {string} key | |
| 92 * @param {string} value | |
| 93 */ | |
| 94 setItem: function(key, value) | |
| 95 { | |
| 96 this._model._agent.setDOMStorageItem(this.id, key, value); | |
| 97 }, | |
| 98 | |
| 99 /** | |
| 100 * @param {string} key | |
| 101 */ | |
| 102 removeItem: function(key) | |
| 103 { | |
| 104 this._model._agent.removeDOMStorageItem(this.id, key); | |
| 105 }, | |
| 106 | |
| 107 __proto__: WebInspector.Object.prototype | |
| 108 }; | 99 }; |
| 109 | 100 |
| 110 /** | 101 /** |
| 111 * @constructor | 102 * @unrestricted |
| 112 * @extends {WebInspector.SDKModel} | |
| 113 * @param {!WebInspector.Target} target | |
| 114 * @param {!WebInspector.SecurityOriginManager} securityOriginManager | |
| 115 */ | 103 */ |
| 116 WebInspector.DOMStorageModel = function(target, securityOriginManager) | 104 WebInspector.DOMStorageModel = class extends WebInspector.SDKModel { |
| 117 { | 105 /** |
| 118 WebInspector.SDKModel.call(this, WebInspector.DOMStorageModel, target); | 106 * @param {!WebInspector.Target} target |
| 107 * @param {!WebInspector.SecurityOriginManager} securityOriginManager |
| 108 */ |
| 109 constructor(target, securityOriginManager) { |
| 110 super(WebInspector.DOMStorageModel, target); |
| 119 | 111 |
| 120 this._securityOriginManager = securityOriginManager; | 112 this._securityOriginManager = securityOriginManager; |
| 121 /** @type {!Object.<string, !WebInspector.DOMStorage>} */ | 113 /** @type {!Object.<string, !WebInspector.DOMStorage>} */ |
| 122 this._storages = {}; | 114 this._storages = {}; |
| 123 this._agent = target.domstorageAgent(); | 115 this._agent = target.domstorageAgent(); |
| 116 } |
| 117 |
| 118 /** |
| 119 * @param {!WebInspector.Target} target |
| 120 * @return {!WebInspector.DOMStorageModel} |
| 121 */ |
| 122 static fromTarget(target) { |
| 123 var model = /** @type {?WebInspector.DOMStorageModel} */ (target.model(WebIn
spector.DOMStorageModel)); |
| 124 if (!model) { |
| 125 model = new WebInspector.DOMStorageModel(target, WebInspector.SecurityOrig
inManager.fromTarget(target)); |
| 126 } |
| 127 return model; |
| 128 } |
| 129 |
| 130 enable() { |
| 131 if (this._enabled) |
| 132 return; |
| 133 |
| 134 this.target().registerDOMStorageDispatcher(new WebInspector.DOMStorageDispat
cher(this)); |
| 135 this._securityOriginManager.addEventListener( |
| 136 WebInspector.SecurityOriginManager.Events.SecurityOriginAdded, this._sec
urityOriginAdded, this); |
| 137 this._securityOriginManager.addEventListener( |
| 138 WebInspector.SecurityOriginManager.Events.SecurityOriginRemoved, this._s
ecurityOriginRemoved, this); |
| 139 |
| 140 for (var securityOrigin of this._securityOriginManager.securityOrigins()) |
| 141 this._addOrigin(securityOrigin); |
| 142 this._agent.enable(); |
| 143 |
| 144 this._enabled = true; |
| 145 } |
| 146 |
| 147 /** |
| 148 * @param {string} origin |
| 149 */ |
| 150 clearForOrigin(origin) { |
| 151 if (!this._enabled) |
| 152 return; |
| 153 this._removeOrigin(origin); |
| 154 this._addOrigin(origin); |
| 155 } |
| 156 |
| 157 /** |
| 158 * @param {!WebInspector.Event} event |
| 159 */ |
| 160 _securityOriginAdded(event) { |
| 161 this._addOrigin(/** @type {string} */ (event.data)); |
| 162 } |
| 163 |
| 164 /** |
| 165 * @param {string} securityOrigin |
| 166 */ |
| 167 _addOrigin(securityOrigin) { |
| 168 var localStorageKey = this._storageKey(securityOrigin, true); |
| 169 console.assert(!this._storages[localStorageKey]); |
| 170 var localStorage = new WebInspector.DOMStorage(this, securityOrigin, true); |
| 171 this._storages[localStorageKey] = localStorage; |
| 172 this.dispatchEventToListeners(WebInspector.DOMStorageModel.Events.DOMStorage
Added, localStorage); |
| 173 |
| 174 var sessionStorageKey = this._storageKey(securityOrigin, false); |
| 175 console.assert(!this._storages[sessionStorageKey]); |
| 176 var sessionStorage = new WebInspector.DOMStorage(this, securityOrigin, false
); |
| 177 this._storages[sessionStorageKey] = sessionStorage; |
| 178 this.dispatchEventToListeners(WebInspector.DOMStorageModel.Events.DOMStorage
Added, sessionStorage); |
| 179 } |
| 180 |
| 181 /** |
| 182 * @param {!WebInspector.Event} event |
| 183 */ |
| 184 _securityOriginRemoved(event) { |
| 185 this._removeOrigin(/** @type {string} */ (event.data)); |
| 186 } |
| 187 |
| 188 /** |
| 189 * @param {string} securityOrigin |
| 190 */ |
| 191 _removeOrigin(securityOrigin) { |
| 192 var localStorageKey = this._storageKey(securityOrigin, true); |
| 193 var localStorage = this._storages[localStorageKey]; |
| 194 console.assert(localStorage); |
| 195 delete this._storages[localStorageKey]; |
| 196 this.dispatchEventToListeners(WebInspector.DOMStorageModel.Events.DOMStorage
Removed, localStorage); |
| 197 |
| 198 var sessionStorageKey = this._storageKey(securityOrigin, false); |
| 199 var sessionStorage = this._storages[sessionStorageKey]; |
| 200 console.assert(sessionStorage); |
| 201 delete this._storages[sessionStorageKey]; |
| 202 this.dispatchEventToListeners(WebInspector.DOMStorageModel.Events.DOMStorage
Removed, sessionStorage); |
| 203 } |
| 204 |
| 205 /** |
| 206 * @param {string} securityOrigin |
| 207 * @param {boolean} isLocalStorage |
| 208 * @return {string} |
| 209 */ |
| 210 _storageKey(securityOrigin, isLocalStorage) { |
| 211 return JSON.stringify(WebInspector.DOMStorage.storageId(securityOrigin, isLo
calStorage)); |
| 212 } |
| 213 |
| 214 /** |
| 215 * @param {!DOMStorageAgent.StorageId} storageId |
| 216 */ |
| 217 _domStorageItemsCleared(storageId) { |
| 218 var domStorage = this.storageForId(storageId); |
| 219 if (!domStorage) |
| 220 return; |
| 221 |
| 222 var eventData = {}; |
| 223 domStorage.dispatchEventToListeners(WebInspector.DOMStorage.Events.DOMStorag
eItemsCleared, eventData); |
| 224 } |
| 225 |
| 226 /** |
| 227 * @param {!DOMStorageAgent.StorageId} storageId |
| 228 * @param {string} key |
| 229 */ |
| 230 _domStorageItemRemoved(storageId, key) { |
| 231 var domStorage = this.storageForId(storageId); |
| 232 if (!domStorage) |
| 233 return; |
| 234 |
| 235 var eventData = {key: key}; |
| 236 domStorage.dispatchEventToListeners(WebInspector.DOMStorage.Events.DOMStorag
eItemRemoved, eventData); |
| 237 } |
| 238 |
| 239 /** |
| 240 * @param {!DOMStorageAgent.StorageId} storageId |
| 241 * @param {string} key |
| 242 * @param {string} value |
| 243 */ |
| 244 _domStorageItemAdded(storageId, key, value) { |
| 245 var domStorage = this.storageForId(storageId); |
| 246 if (!domStorage) |
| 247 return; |
| 248 |
| 249 var eventData = {key: key, value: value}; |
| 250 domStorage.dispatchEventToListeners(WebInspector.DOMStorage.Events.DOMStorag
eItemAdded, eventData); |
| 251 } |
| 252 |
| 253 /** |
| 254 * @param {!DOMStorageAgent.StorageId} storageId |
| 255 * @param {string} key |
| 256 * @param {string} oldValue |
| 257 * @param {string} value |
| 258 */ |
| 259 _domStorageItemUpdated(storageId, key, oldValue, value) { |
| 260 var domStorage = this.storageForId(storageId); |
| 261 if (!domStorage) |
| 262 return; |
| 263 |
| 264 var eventData = {key: key, oldValue: oldValue, value: value}; |
| 265 domStorage.dispatchEventToListeners(WebInspector.DOMStorage.Events.DOMStorag
eItemUpdated, eventData); |
| 266 } |
| 267 |
| 268 /** |
| 269 * @param {!DOMStorageAgent.StorageId} storageId |
| 270 * @return {!WebInspector.DOMStorage} |
| 271 */ |
| 272 storageForId(storageId) { |
| 273 return this._storages[JSON.stringify(storageId)]; |
| 274 } |
| 275 |
| 276 /** |
| 277 * @return {!Array.<!WebInspector.DOMStorage>} |
| 278 */ |
| 279 storages() { |
| 280 var result = []; |
| 281 for (var id in this._storages) |
| 282 result.push(this._storages[id]); |
| 283 return result; |
| 284 } |
| 124 }; | 285 }; |
| 125 | 286 |
| 126 /** @enum {symbol} */ | 287 /** @enum {symbol} */ |
| 127 WebInspector.DOMStorageModel.Events = { | 288 WebInspector.DOMStorageModel.Events = { |
| 128 DOMStorageAdded: Symbol("DOMStorageAdded"), | 289 DOMStorageAdded: Symbol('DOMStorageAdded'), |
| 129 DOMStorageRemoved: Symbol("DOMStorageRemoved") | 290 DOMStorageRemoved: Symbol('DOMStorageRemoved') |
| 130 }; | |
| 131 | |
| 132 WebInspector.DOMStorageModel.prototype = { | |
| 133 enable: function() | |
| 134 { | |
| 135 if (this._enabled) | |
| 136 return; | |
| 137 | |
| 138 this.target().registerDOMStorageDispatcher(new WebInspector.DOMStorageDi
spatcher(this)); | |
| 139 this._securityOriginManager.addEventListener(WebInspector.SecurityOrigin
Manager.Events.SecurityOriginAdded, this._securityOriginAdded, this); | |
| 140 this._securityOriginManager.addEventListener(WebInspector.SecurityOrigin
Manager.Events.SecurityOriginRemoved, this._securityOriginRemoved, this); | |
| 141 | |
| 142 for (var securityOrigin of this._securityOriginManager.securityOrigins()
) | |
| 143 this._addOrigin(securityOrigin); | |
| 144 this._agent.enable(); | |
| 145 | |
| 146 this._enabled = true; | |
| 147 }, | |
| 148 | |
| 149 /** | |
| 150 * @param {string} origin | |
| 151 */ | |
| 152 clearForOrigin: function(origin) | |
| 153 { | |
| 154 if (!this._enabled) | |
| 155 return; | |
| 156 this._removeOrigin(origin); | |
| 157 this._addOrigin(origin); | |
| 158 }, | |
| 159 | |
| 160 /** | |
| 161 * @param {!WebInspector.Event} event | |
| 162 */ | |
| 163 _securityOriginAdded: function(event) | |
| 164 { | |
| 165 this._addOrigin(/** @type {string} */ (event.data)); | |
| 166 }, | |
| 167 | |
| 168 /** | |
| 169 * @param {string} securityOrigin | |
| 170 */ | |
| 171 _addOrigin: function(securityOrigin) | |
| 172 { | |
| 173 var localStorageKey = this._storageKey(securityOrigin, true); | |
| 174 console.assert(!this._storages[localStorageKey]); | |
| 175 var localStorage = new WebInspector.DOMStorage(this, securityOrigin, tru
e); | |
| 176 this._storages[localStorageKey] = localStorage; | |
| 177 this.dispatchEventToListeners(WebInspector.DOMStorageModel.Events.DOMSto
rageAdded, localStorage); | |
| 178 | |
| 179 var sessionStorageKey = this._storageKey(securityOrigin, false); | |
| 180 console.assert(!this._storages[sessionStorageKey]); | |
| 181 var sessionStorage = new WebInspector.DOMStorage(this, securityOrigin, f
alse); | |
| 182 this._storages[sessionStorageKey] = sessionStorage; | |
| 183 this.dispatchEventToListeners(WebInspector.DOMStorageModel.Events.DOMSto
rageAdded, sessionStorage); | |
| 184 }, | |
| 185 | |
| 186 /** | |
| 187 * @param {!WebInspector.Event} event | |
| 188 */ | |
| 189 _securityOriginRemoved: function(event) | |
| 190 { | |
| 191 this._removeOrigin(/** @type {string} */ (event.data)); | |
| 192 }, | |
| 193 | |
| 194 /** | |
| 195 * @param {string} securityOrigin | |
| 196 */ | |
| 197 _removeOrigin: function(securityOrigin) | |
| 198 { | |
| 199 var localStorageKey = this._storageKey(securityOrigin, true); | |
| 200 var localStorage = this._storages[localStorageKey]; | |
| 201 console.assert(localStorage); | |
| 202 delete this._storages[localStorageKey]; | |
| 203 this.dispatchEventToListeners(WebInspector.DOMStorageModel.Events.DOMSto
rageRemoved, localStorage); | |
| 204 | |
| 205 var sessionStorageKey = this._storageKey(securityOrigin, false); | |
| 206 var sessionStorage = this._storages[sessionStorageKey]; | |
| 207 console.assert(sessionStorage); | |
| 208 delete this._storages[sessionStorageKey]; | |
| 209 this.dispatchEventToListeners(WebInspector.DOMStorageModel.Events.DOMSto
rageRemoved, sessionStorage); | |
| 210 }, | |
| 211 | |
| 212 /** | |
| 213 * @param {string} securityOrigin | |
| 214 * @param {boolean} isLocalStorage | |
| 215 * @return {string} | |
| 216 */ | |
| 217 _storageKey: function(securityOrigin, isLocalStorage) | |
| 218 { | |
| 219 return JSON.stringify(WebInspector.DOMStorage.storageId(securityOrigin,
isLocalStorage)); | |
| 220 }, | |
| 221 | |
| 222 /** | |
| 223 * @param {!DOMStorageAgent.StorageId} storageId | |
| 224 */ | |
| 225 _domStorageItemsCleared: function(storageId) | |
| 226 { | |
| 227 var domStorage = this.storageForId(storageId); | |
| 228 if (!domStorage) | |
| 229 return; | |
| 230 | |
| 231 var eventData = {}; | |
| 232 domStorage.dispatchEventToListeners(WebInspector.DOMStorage.Events.DOMSt
orageItemsCleared, eventData); | |
| 233 }, | |
| 234 | |
| 235 /** | |
| 236 * @param {!DOMStorageAgent.StorageId} storageId | |
| 237 * @param {string} key | |
| 238 */ | |
| 239 _domStorageItemRemoved: function(storageId, key) | |
| 240 { | |
| 241 var domStorage = this.storageForId(storageId); | |
| 242 if (!domStorage) | |
| 243 return; | |
| 244 | |
| 245 var eventData = { key: key }; | |
| 246 domStorage.dispatchEventToListeners(WebInspector.DOMStorage.Events.DOMSt
orageItemRemoved, eventData); | |
| 247 }, | |
| 248 | |
| 249 /** | |
| 250 * @param {!DOMStorageAgent.StorageId} storageId | |
| 251 * @param {string} key | |
| 252 * @param {string} value | |
| 253 */ | |
| 254 _domStorageItemAdded: function(storageId, key, value) | |
| 255 { | |
| 256 var domStorage = this.storageForId(storageId); | |
| 257 if (!domStorage) | |
| 258 return; | |
| 259 | |
| 260 var eventData = { key: key, value: value }; | |
| 261 domStorage.dispatchEventToListeners(WebInspector.DOMStorage.Events.DOMSt
orageItemAdded, eventData); | |
| 262 }, | |
| 263 | |
| 264 /** | |
| 265 * @param {!DOMStorageAgent.StorageId} storageId | |
| 266 * @param {string} key | |
| 267 * @param {string} oldValue | |
| 268 * @param {string} value | |
| 269 */ | |
| 270 _domStorageItemUpdated: function(storageId, key, oldValue, value) | |
| 271 { | |
| 272 var domStorage = this.storageForId(storageId); | |
| 273 if (!domStorage) | |
| 274 return; | |
| 275 | |
| 276 var eventData = { key: key, oldValue: oldValue, value: value }; | |
| 277 domStorage.dispatchEventToListeners(WebInspector.DOMStorage.Events.DOMSt
orageItemUpdated, eventData); | |
| 278 }, | |
| 279 | |
| 280 /** | |
| 281 * @param {!DOMStorageAgent.StorageId} storageId | |
| 282 * @return {!WebInspector.DOMStorage} | |
| 283 */ | |
| 284 storageForId: function(storageId) | |
| 285 { | |
| 286 return this._storages[JSON.stringify(storageId)]; | |
| 287 }, | |
| 288 | |
| 289 /** | |
| 290 * @return {!Array.<!WebInspector.DOMStorage>} | |
| 291 */ | |
| 292 storages: function() | |
| 293 { | |
| 294 var result = []; | |
| 295 for (var id in this._storages) | |
| 296 result.push(this._storages[id]); | |
| 297 return result; | |
| 298 }, | |
| 299 | |
| 300 __proto__: WebInspector.SDKModel.prototype | |
| 301 }; | 291 }; |
| 302 | 292 |
| 303 /** | 293 /** |
| 304 * @constructor | |
| 305 * @implements {DOMStorageAgent.Dispatcher} | 294 * @implements {DOMStorageAgent.Dispatcher} |
| 306 * @param {!WebInspector.DOMStorageModel} model | 295 * @unrestricted |
| 307 */ | 296 */ |
| 308 WebInspector.DOMStorageDispatcher = function(model) | 297 WebInspector.DOMStorageDispatcher = class { |
| 309 { | 298 /** |
| 299 * @param {!WebInspector.DOMStorageModel} model |
| 300 */ |
| 301 constructor(model) { |
| 310 this._model = model; | 302 this._model = model; |
| 311 }; | 303 } |
| 312 | 304 |
| 313 WebInspector.DOMStorageDispatcher.prototype = { | 305 /** |
| 314 | 306 * @override |
| 315 /** | 307 * @param {!DOMStorageAgent.StorageId} storageId |
| 316 * @override | 308 */ |
| 317 * @param {!DOMStorageAgent.StorageId} storageId | 309 domStorageItemsCleared(storageId) { |
| 318 */ | 310 this._model._domStorageItemsCleared(storageId); |
| 319 domStorageItemsCleared: function(storageId) | 311 } |
| 320 { | 312 |
| 321 this._model._domStorageItemsCleared(storageId); | 313 /** |
| 322 }, | 314 * @override |
| 323 | 315 * @param {!DOMStorageAgent.StorageId} storageId |
| 324 /** | 316 * @param {string} key |
| 325 * @override | 317 */ |
| 326 * @param {!DOMStorageAgent.StorageId} storageId | 318 domStorageItemRemoved(storageId, key) { |
| 327 * @param {string} key | 319 this._model._domStorageItemRemoved(storageId, key); |
| 328 */ | 320 } |
| 329 domStorageItemRemoved: function(storageId, key) | 321 |
| 330 { | 322 /** |
| 331 this._model._domStorageItemRemoved(storageId, key); | 323 * @override |
| 332 }, | 324 * @param {!DOMStorageAgent.StorageId} storageId |
| 333 | 325 * @param {string} key |
| 334 /** | 326 * @param {string} value |
| 335 * @override | 327 */ |
| 336 * @param {!DOMStorageAgent.StorageId} storageId | 328 domStorageItemAdded(storageId, key, value) { |
| 337 * @param {string} key | 329 this._model._domStorageItemAdded(storageId, key, value); |
| 338 * @param {string} value | 330 } |
| 339 */ | 331 |
| 340 domStorageItemAdded: function(storageId, key, value) | 332 /** |
| 341 { | 333 * @override |
| 342 this._model._domStorageItemAdded(storageId, key, value); | 334 * @param {!DOMStorageAgent.StorageId} storageId |
| 343 }, | 335 * @param {string} key |
| 344 | 336 * @param {string} oldValue |
| 345 /** | 337 * @param {string} value |
| 346 * @override | 338 */ |
| 347 * @param {!DOMStorageAgent.StorageId} storageId | 339 domStorageItemUpdated(storageId, key, oldValue, value) { |
| 348 * @param {string} key | 340 this._model._domStorageItemUpdated(storageId, key, oldValue, value); |
| 349 * @param {string} oldValue | 341 } |
| 350 * @param {string} value | 342 }; |
| 351 */ | 343 |
| 352 domStorageItemUpdated: function(storageId, key, oldValue, value) | 344 WebInspector.DOMStorageModel._symbol = Symbol('DomStorage'); |
| 353 { | 345 |
| 354 this._model._domStorageItemUpdated(storageId, key, oldValue, value); | 346 |
| 355 }, | |
| 356 }; | |
| 357 | |
| 358 WebInspector.DOMStorageModel._symbol = Symbol("DomStorage"); | |
| 359 | |
| 360 /** | |
| 361 * @param {!WebInspector.Target} target | |
| 362 * @return {!WebInspector.DOMStorageModel} | |
| 363 */ | |
| 364 WebInspector.DOMStorageModel.fromTarget = function(target) | |
| 365 { | |
| 366 var model = /** @type {?WebInspector.DOMStorageModel} */ (target.model(WebIn
spector.DOMStorageModel)); | |
| 367 if (!model) { | |
| 368 model = new WebInspector.DOMStorageModel(target, WebInspector.SecurityOr
iginManager.fromTarget(target)); | |
| 369 } | |
| 370 return model; | |
| 371 }; | |
| OLD | NEW |