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

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

Issue 2172753002: [DevTools] No longer store security origins in ResourceTreeModel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed the comments Created 4 years, 4 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) 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
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
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 if (!target[WebInspector.DOMStorageModel._symbol]) {
363 target[WebInspector.DOMStorageModel._symbol] = new WebInspector.DOMStora geModel(target); 365 target[WebInspector.DOMStorageModel._symbol] = new WebInspector.DOMStora geModel(target, WebInspector.SecurityOriginManager.fromTarget(target));
dgozman 2016/07/25 18:56:08 Let's use target.model().
eostroukhov-old 2016/07/25 19:47:48 Done.
366 }
364 367
365 return target[WebInspector.DOMStorageModel._symbol]; 368 return target[WebInspector.DOMStorageModel._symbol];
366 } 369 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698