| 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. |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 this._model._agent.removeDOMStorageItem(this.id, key); | 103 this._model._agent.removeDOMStorageItem(this.id, key); |
| 104 }, | 104 }, |
| 105 | 105 |
| 106 __proto__: WebInspector.Object.prototype | 106 __proto__: WebInspector.Object.prototype |
| 107 } | 107 } |
| 108 | 108 |
| 109 /** | 109 /** |
| 110 * @constructor | 110 * @constructor |
| 111 * @extends {WebInspector.SDKModel} | 111 * @extends {WebInspector.SDKModel} |
| 112 * @param {!WebInspector.Target} target | 112 * @param {!WebInspector.Target} target |
| 113 * @param {!WebInspector.SecurityOriginManager} securityOriginManager |
| 113 */ | 114 */ |
| 114 WebInspector.DOMStorageModel = function(target) | 115 WebInspector.DOMStorageModel = function(target, securityOriginManager) |
| 115 { | 116 { |
| 116 WebInspector.SDKModel.call(this, WebInspector.DOMStorageModel, target); | 117 WebInspector.SDKModel.call(this, WebInspector.DOMStorageModel, target); |
| 117 | 118 |
| 119 this._securityOriginManager = securityOriginManager; |
| 118 /** @type {!Object.<string, !WebInspector.DOMStorage>} */ | 120 /** @type {!Object.<string, !WebInspector.DOMStorage>} */ |
| 119 this._storages = {}; | 121 this._storages = {}; |
| 120 this._agent = target.domstorageAgent(); | 122 this._agent = target.domstorageAgent(); |
| 121 } | 123 } |
| 122 | 124 |
| 123 WebInspector.DOMStorageModel.Events = { | 125 WebInspector.DOMStorageModel.Events = { |
| 124 DOMStorageAdded: "DOMStorageAdded", | 126 DOMStorageAdded: "DOMStorageAdded", |
| 125 DOMStorageRemoved: "DOMStorageRemoved" | 127 DOMStorageRemoved: "DOMStorageRemoved" |
| 126 } | 128 } |
| 127 | 129 |
| 128 WebInspector.DOMStorageModel.prototype = { | 130 WebInspector.DOMStorageModel.prototype = { |
| 129 enable: function() | 131 enable: function() |
| 130 { | 132 { |
| 131 if (this._enabled) | 133 if (this._enabled) |
| 132 return; | 134 return; |
| 133 | 135 |
| 134 this.target().registerDOMStorageDispatcher(new WebInspector.DOMStorageDi
spatcher(this)); | 136 this.target().registerDOMStorageDispatcher(new WebInspector.DOMStorageDi
spatcher(this)); |
| 135 this.target().resourceTreeModel.addEventListener(WebInspector.ResourceTr
eeModel.EventTypes.SecurityOriginAdded, this._securityOriginAdded, this); | 137 this._securityOriginManager.addEventListener(WebInspector.SecurityOrigin
Manager.EventTypes.SecurityOriginAdded, this._securityOriginAdded, this); |
| 136 this.target().resourceTreeModel.addEventListener(WebInspector.ResourceTr
eeModel.EventTypes.SecurityOriginRemoved, this._securityOriginRemoved, this); | 138 this._securityOriginManager.addEventListener(WebInspector.SecurityOrigin
Manager.EventTypes.SecurityOriginRemoved, this._securityOriginRemoved, this); |
| 139 |
| 140 for (var securityOrigin of this._securityOriginManager.securityOrigins()
) |
| 141 this._addOrigin(securityOrigin); |
| 137 this._agent.enable(); | 142 this._agent.enable(); |
| 138 | 143 |
| 139 var securityOrigins = this.target().resourceTreeModel.securityOrigins(); | |
| 140 for (var i = 0; i < securityOrigins.length; ++i) | |
| 141 this._addOrigin(securityOrigins[i]); | |
| 142 | |
| 143 this._enabled = true; | 144 this._enabled = true; |
| 144 }, | 145 }, |
| 145 | 146 |
| 146 /** | 147 /** |
| 147 * @param {string} origin | 148 * @param {string} origin |
| 148 */ | 149 */ |
| 149 clearForOrigin: function(origin) | 150 clearForOrigin: function(origin) |
| 150 { | 151 { |
| 151 if (!this._enabled) | 152 if (!this._enabled) |
| 152 return; | 153 return; |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 * @param {string} oldValue | 347 * @param {string} oldValue |
| 347 * @param {string} value | 348 * @param {string} value |
| 348 */ | 349 */ |
| 349 domStorageItemUpdated: function(storageId, key, oldValue, value) | 350 domStorageItemUpdated: function(storageId, key, oldValue, value) |
| 350 { | 351 { |
| 351 this._model._domStorageItemUpdated(storageId, key, oldValue, value); | 352 this._model._domStorageItemUpdated(storageId, key, oldValue, value); |
| 352 }, | 353 }, |
| 353 } | 354 } |
| 354 | 355 |
| 355 WebInspector.DOMStorageModel._symbol = Symbol("DomStorage"); | 356 WebInspector.DOMStorageModel._symbol = Symbol("DomStorage"); |
| 357 |
| 356 /** | 358 /** |
| 357 * @param {!WebInspector.Target} target | 359 * @param {!WebInspector.Target} target |
| 358 * @return {!WebInspector.DOMStorageModel} | 360 * @return {!WebInspector.DOMStorageModel} |
| 359 */ | 361 */ |
| 360 WebInspector.DOMStorageModel.fromTarget = function(target) | 362 WebInspector.DOMStorageModel.fromTarget = function(target) |
| 361 { | 363 { |
| 362 if (!target[WebInspector.DOMStorageModel._symbol]) | 364 var model = /** @type {?WebInspector.DOMStorageModel} */ (target.model(WebIn
spector.DOMStorageModel)); |
| 363 target[WebInspector.DOMStorageModel._symbol] = new WebInspector.DOMStora
geModel(target); | 365 if (!model) { |
| 364 | 366 model = new WebInspector.DOMStorageModel(target, WebInspector.SecurityOr
iginManager.fromTarget(target)); |
| 365 return target[WebInspector.DOMStorageModel._symbol]; | 367 } |
| 368 return model; |
| 366 } | 369 } |
| OLD | NEW |