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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/resources/DOMStorageModel.js

Issue 2748693003: [DevTools] Clear session storage (Closed)
Patch Set: [DevTools] Clear session storage Created 3 years, 9 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
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/resources/ClearStorageView.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 this._enabled = true; 144 this._enabled = true;
145 } 145 }
146 146
147 /** 147 /**
148 * @param {string} origin 148 * @param {string} origin
149 */ 149 */
150 clearForOrigin(origin) { 150 clearForOrigin(origin) {
151 if (!this._enabled) 151 if (!this._enabled)
152 return; 152 return;
153 for (var isLocal of [true, false]) {
154 var key = this._storageKey(origin, isLocal);
155 var storage = this._storages[key];
156 storage.clear();
157 }
153 this._removeOrigin(origin); 158 this._removeOrigin(origin);
154 this._addOrigin(origin); 159 this._addOrigin(origin);
155 } 160 }
156 161
157 /** 162 /**
158 * @param {!Common.Event} event 163 * @param {!Common.Event} event
159 */ 164 */
160 _securityOriginAdded(event) { 165 _securityOriginAdded(event) {
161 this._addOrigin(/** @type {string} */ (event.data)); 166 this._addOrigin(/** @type {string} */ (event.data));
162 } 167 }
163 168
164 /** 169 /**
165 * @param {string} securityOrigin 170 * @param {string} securityOrigin
166 */ 171 */
167 _addOrigin(securityOrigin) { 172 _addOrigin(securityOrigin) {
168 var localStorageKey = this._storageKey(securityOrigin, true); 173 for (var isLocal of [true, false]) {
169 console.assert(!this._storages[localStorageKey]); 174 var key = this._storageKey(securityOrigin, isLocal);
170 var localStorage = new Resources.DOMStorage(this, securityOrigin, true); 175 console.assert(!this._storages[key]);
171 this._storages[localStorageKey] = localStorage; 176 var storage = new Resources.DOMStorage(this, securityOrigin, isLocal);
172 this.dispatchEventToListeners(Resources.DOMStorageModel.Events.DOMStorageAdd ed, localStorage); 177 this._storages[key] = storage;
173 178 this.dispatchEventToListeners(Resources.DOMStorageModel.Events.DOMStorageA dded, storage);
174 var sessionStorageKey = this._storageKey(securityOrigin, false); 179 }
175 console.assert(!this._storages[sessionStorageKey]);
176 var sessionStorage = new Resources.DOMStorage(this, securityOrigin, false);
177 this._storages[sessionStorageKey] = sessionStorage;
178 this.dispatchEventToListeners(Resources.DOMStorageModel.Events.DOMStorageAdd ed, sessionStorage);
179 } 180 }
180 181
181 /** 182 /**
182 * @param {!Common.Event} event 183 * @param {!Common.Event} event
183 */ 184 */
184 _securityOriginRemoved(event) { 185 _securityOriginRemoved(event) {
185 this._removeOrigin(/** @type {string} */ (event.data)); 186 this._removeOrigin(/** @type {string} */ (event.data));
186 } 187 }
187 188
188 /** 189 /**
189 * @param {string} securityOrigin 190 * @param {string} securityOrigin
190 */ 191 */
191 _removeOrigin(securityOrigin) { 192 _removeOrigin(securityOrigin) {
192 var localStorageKey = this._storageKey(securityOrigin, true); 193 for (var isLocal of [true, false]) {
193 var localStorage = this._storages[localStorageKey]; 194 var key = this._storageKey(securityOrigin, isLocal);
194 console.assert(localStorage); 195 var storage = this._storages[key];
195 delete this._storages[localStorageKey]; 196 console.assert(storage);
196 this.dispatchEventToListeners(Resources.DOMStorageModel.Events.DOMStorageRem oved, localStorage); 197 delete this._storages[key];
197 198 this.dispatchEventToListeners(Resources.DOMStorageModel.Events.DOMStorageR emoved, storage);
198 var sessionStorageKey = this._storageKey(securityOrigin, false); 199 }
199 var sessionStorage = this._storages[sessionStorageKey];
200 console.assert(sessionStorage);
201 delete this._storages[sessionStorageKey];
202 this.dispatchEventToListeners(Resources.DOMStorageModel.Events.DOMStorageRem oved, sessionStorage);
203 } 200 }
204 201
205 /** 202 /**
206 * @param {string} securityOrigin 203 * @param {string} securityOrigin
207 * @param {boolean} isLocalStorage 204 * @param {boolean} isLocalStorage
208 * @return {string} 205 * @return {string}
209 */ 206 */
210 _storageKey(securityOrigin, isLocalStorage) { 207 _storageKey(securityOrigin, isLocalStorage) {
211 return JSON.stringify(Resources.DOMStorage.storageId(securityOrigin, isLocal Storage)); 208 return JSON.stringify(Resources.DOMStorage.storageId(securityOrigin, isLocal Storage));
212 } 209 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 * @param {string} key 334 * @param {string} key
338 * @param {string} oldValue 335 * @param {string} oldValue
339 * @param {string} value 336 * @param {string} value
340 */ 337 */
341 domStorageItemUpdated(storageId, key, oldValue, value) { 338 domStorageItemUpdated(storageId, key, oldValue, value) {
342 this._model._domStorageItemUpdated(storageId, key, oldValue, value); 339 this._model._domStorageItemUpdated(storageId, key, oldValue, value);
343 } 340 }
344 }; 341 };
345 342
346 Resources.DOMStorageModel._symbol = Symbol('DomStorage'); 343 Resources.DOMStorageModel._symbol = Symbol('DomStorage');
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/resources/ClearStorageView.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698