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

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

Issue 2747123008: [DevTools] Separate old Application tab code (Closed)
Patch Set: [DevTools] Separate old Application tab code 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Joseph Pecoraro 3 * Copyright (C) 2009 Joseph Pecoraro
4 * Copyright (C) 2013 Samsung Electronics. All rights reserved. 4 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 13 matching lines...) Expand all
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 /** 30 /**
31 * @implements {SDK.TargetManager.Observer} 31 * @implements {SDK.TargetManager.Observer}
32 * @unrestricted 32 * @unrestricted
33 */ 33 */
34 Resources.ResourcesPanel = class extends UI.PanelWithSidebar { 34 Resources.ApplicationPanelSidebar = class extends Common.Object {
35 constructor() { 35 /**
36 super('resources'); 36 * @param {!Resources.ResourcesPanel} panel
37 this.registerRequiredCSS('resources/resourcesPanel.css'); 37 */
38 constructor(panel) {
39 super();
38 40
39 this._resourcesLastSelectedItemSetting = Common.settings.createSetting('reso urcesLastSelectedItem', {}); 41 this._panel = panel;
40 42
41 this._sidebarTree = new UI.TreeOutlineInShadow(); 43 this._sidebarTree = new UI.TreeOutlineInShadow();
42 this._sidebarTree.element.classList.add('resources-sidebar'); 44 this._sidebarTree.element.classList.add('resources-sidebar');
43 this._sidebarTree.registerRequiredCSS('resources/resourcesSidebar.css'); 45 this._sidebarTree.registerRequiredCSS('resources/resourcesSidebar.css');
44 this._sidebarTree.element.classList.add('filter-all'); 46 this._sidebarTree.element.classList.add('filter-all');
45 this.panelSidebarElement().appendChild(this._sidebarTree.element);
46 47
47 this._applicationTreeElement = this._addSidebarSection(Common.UIString('Appl ication')); 48 this._applicationTreeElement = this._addSidebarSection(Common.UIString('Appl ication'));
48 this._manifestTreeElement = new Resources.AppManifestTreeElement(this); 49 this._manifestTreeElement = new Resources.AppManifestTreeElement(this);
49 this._applicationTreeElement.appendChild(this._manifestTreeElement); 50 this._applicationTreeElement.appendChild(this._manifestTreeElement);
50 this.serviceWorkersTreeElement = new Resources.ServiceWorkersTreeElement(thi s); 51 this.serviceWorkersTreeElement = new Resources.ServiceWorkersTreeElement(thi s);
51 this._applicationTreeElement.appendChild(this.serviceWorkersTreeElement); 52 this._applicationTreeElement.appendChild(this.serviceWorkersTreeElement);
52 var clearStorageTreeElement = new Resources.ClearStorageTreeElement(this); 53 var clearStorageTreeElement = new Resources.ClearStorageTreeElement(this);
53 this._applicationTreeElement.appendChild(clearStorageTreeElement); 54 this._applicationTreeElement.appendChild(clearStorageTreeElement);
54 55
55 var storageTreeElement = this._addSidebarSection(Common.UIString('Storage')) ; 56 var storageTreeElement = this._addSidebarSection(Common.UIString('Storage')) ;
56 this.localStorageListTreeElement = 57 this.localStorageListTreeElement =
57 new Resources.StorageCategoryTreeElement(this, Common.UIString('Local St orage'), 'LocalStorage'); 58 new Resources.StorageCategoryTreeElement(panel, Common.UIString('Local S torage'), 'LocalStorage');
58 var localStorageIcon = UI.Icon.create('mediumicon-table', 'resource-tree-ite m'); 59 var localStorageIcon = UI.Icon.create('mediumicon-table', 'resource-tree-ite m');
59 this.localStorageListTreeElement.setLeadingIcons([localStorageIcon]); 60 this.localStorageListTreeElement.setLeadingIcons([localStorageIcon]);
60 61
61 storageTreeElement.appendChild(this.localStorageListTreeElement); 62 storageTreeElement.appendChild(this.localStorageListTreeElement);
62 this.sessionStorageListTreeElement = 63 this.sessionStorageListTreeElement =
63 new Resources.StorageCategoryTreeElement(this, Common.UIString('Session Storage'), 'SessionStorage'); 64 new Resources.StorageCategoryTreeElement(panel, Common.UIString('Session Storage'), 'SessionStorage');
64 var sessionStorageIcon = UI.Icon.create('mediumicon-table', 'resource-tree-i tem'); 65 var sessionStorageIcon = UI.Icon.create('mediumicon-table', 'resource-tree-i tem');
65 this.sessionStorageListTreeElement.setLeadingIcons([sessionStorageIcon]); 66 this.sessionStorageListTreeElement.setLeadingIcons([sessionStorageIcon]);
66 67
67 storageTreeElement.appendChild(this.sessionStorageListTreeElement); 68 storageTreeElement.appendChild(this.sessionStorageListTreeElement);
68 this.indexedDBListTreeElement = new Resources.IndexedDBTreeElement(this); 69 this.indexedDBListTreeElement = new Resources.IndexedDBTreeElement(panel);
69 storageTreeElement.appendChild(this.indexedDBListTreeElement); 70 storageTreeElement.appendChild(this.indexedDBListTreeElement);
70 this.databasesListTreeElement = 71 this.databasesListTreeElement =
71 new Resources.StorageCategoryTreeElement(this, Common.UIString('Web SQL' ), 'Databases'); 72 new Resources.StorageCategoryTreeElement(panel, Common.UIString('Web SQL '), 'Databases');
72 var databaseIcon = UI.Icon.create('mediumicon-database', 'resource-tree-item '); 73 var databaseIcon = UI.Icon.create('mediumicon-database', 'resource-tree-item ');
73 this.databasesListTreeElement.setLeadingIcons([databaseIcon]); 74 this.databasesListTreeElement.setLeadingIcons([databaseIcon]);
74 75
75 storageTreeElement.appendChild(this.databasesListTreeElement); 76 storageTreeElement.appendChild(this.databasesListTreeElement);
76 this.cookieListTreeElement = new Resources.StorageCategoryTreeElement(this, Common.UIString('Cookies'), 'Cookies'); 77 this.cookieListTreeElement = new Resources.StorageCategoryTreeElement(panel, Common.UIString('Cookies'), 'Cookies');
77 var cookieIcon = UI.Icon.create('mediumicon-cookie', 'resource-tree-item'); 78 var cookieIcon = UI.Icon.create('mediumicon-cookie', 'resource-tree-item');
78 this.cookieListTreeElement.setLeadingIcons([cookieIcon]); 79 this.cookieListTreeElement.setLeadingIcons([cookieIcon]);
79 storageTreeElement.appendChild(this.cookieListTreeElement); 80 storageTreeElement.appendChild(this.cookieListTreeElement);
80 81
81 var cacheTreeElement = this._addSidebarSection(Common.UIString('Cache')); 82 var cacheTreeElement = this._addSidebarSection(Common.UIString('Cache'));
82 this.cacheStorageListTreeElement = new Resources.ServiceWorkerCacheTreeEleme nt(this); 83 this.cacheStorageListTreeElement = new Resources.ServiceWorkerCacheTreeEleme nt(panel);
83 cacheTreeElement.appendChild(this.cacheStorageListTreeElement); 84 cacheTreeElement.appendChild(this.cacheStorageListTreeElement);
84 this.applicationCacheListTreeElement = 85 this.applicationCacheListTreeElement =
85 new Resources.StorageCategoryTreeElement(this, Common.UIString('Applicat ion Cache'), 'ApplicationCache'); 86 new Resources.StorageCategoryTreeElement(panel, Common.UIString('Applica tion Cache'), 'ApplicationCache');
86 var applicationCacheIcon = UI.Icon.create('mediumicon-table', 'resource-tree -item'); 87 var applicationCacheIcon = UI.Icon.create('mediumicon-table', 'resource-tree -item');
87 this.applicationCacheListTreeElement.setLeadingIcons([applicationCacheIcon]) ; 88 this.applicationCacheListTreeElement.setLeadingIcons([applicationCacheIcon]) ;
88 89
89 cacheTreeElement.appendChild(this.applicationCacheListTreeElement); 90 cacheTreeElement.appendChild(this.applicationCacheListTreeElement);
90 91
91 this._resourcesSection = new Resources.ResourcesSection(this, this._addSideb arSection(Common.UIString('Frames'))); 92 this._resourcesSection = new Resources.ResourcesSection(panel, this._addSide barSection(Common.UIString('Frames')));
92
93 var mainContainer = new UI.VBox();
94 this.storageViews = mainContainer.element.createChild('div', 'vbox flex-auto ');
95 this._storageViewToolbar = new UI.Toolbar('resources-toolbar', mainContainer .element);
96 this.splitWidget().setMainWidget(mainContainer);
97 93
98 /** @type {!Map.<!Resources.Database, !Object.<string, !Resources.DatabaseTa bleView>>} */ 94 /** @type {!Map.<!Resources.Database, !Object.<string, !Resources.DatabaseTa bleView>>} */
99 this._databaseTableViews = new Map(); 95 this._databaseTableViews = new Map();
100 /** @type {!Map.<!Resources.Database, !Resources.DatabaseQueryView>} */ 96 /** @type {!Map.<!Resources.Database, !Resources.DatabaseQueryView>} */
101 this._databaseQueryViews = new Map(); 97 this._databaseQueryViews = new Map();
102 /** @type {!Map.<!Resources.Database, !Resources.DatabaseTreeElement>} */ 98 /** @type {!Map.<!Resources.Database, !Resources.DatabaseTreeElement>} */
103 this._databaseTreeElements = new Map(); 99 this._databaseTreeElements = new Map();
104 /** @type {!Map.<!Resources.DOMStorage, !Resources.DOMStorageTreeElement>} * / 100 /** @type {!Map.<!Resources.DOMStorage, !Resources.DOMStorageTreeElement>} * /
105 this._domStorageTreeElements = new Map(); 101 this._domStorageTreeElements = new Map();
106 /** @type {!Object.<string, boolean>} */ 102 /** @type {!Object.<string, boolean>} */
107 this._domains = {}; 103 this._domains = {};
108 104
109 /** @type {?Resources.DOMStorageItemsView} */ 105 /** @type {?Resources.DOMStorageItemsView} */
110 this._domStorageView = null; 106 this._domStorageView = null;
111 /** @type {?Resources.CookieItemsView} */ 107 /** @type {?Resources.CookieItemsView} */
112 this._cookieView = null; 108 this._cookieView = null;
113 109
114 this.panelSidebarElement().addEventListener('mousemove', this._onmousemove.b ind(this), false); 110 this._sidebarTree.contentElement.addEventListener('mousemove', this._onmouse move.bind(this), false);
115 this.panelSidebarElement().addEventListener('mouseleave', this._onmouseleave .bind(this), false); 111 this._sidebarTree.contentElement.addEventListener('mouseleave', this._onmous eleave.bind(this), false);
116 112
117 SDK.targetManager.observeTargets(this); 113 SDK.targetManager.observeTargets(this);
118 SDK.targetManager.addModelListener( 114 SDK.targetManager.addModelListener(
119 SDK.ResourceTreeModel, SDK.ResourceTreeModel.Events.FrameNavigated, this ._frameNavigated, this); 115 SDK.ResourceTreeModel, SDK.ResourceTreeModel.Events.FrameNavigated, this ._frameNavigated, this);
120 } 116 }
121 117
122 /** 118 /**
123 * @return {!Resources.ResourcesPanel} 119 * @return {!UI.TreeOutline}
124 */ 120 */
125 static _instance() { 121 sidebarTree() {
126 return /** @type {!Resources.ResourcesPanel} */ (self.runtime.sharedInstance (Resources.ResourcesPanel)); 122 return this._sidebarTree;
127 } 123 }
128 124
129 /** 125 /**
130 * @param {string} title 126 * @param {string} title
131 * @return {!UI.TreeElement} 127 * @return {!UI.TreeElement}
132 */ 128 */
133 _addSidebarSection(title) { 129 _addSidebarSection(title) {
134 var treeElement = new UI.TreeElement(title, true); 130 var treeElement = new UI.TreeElement(title, true);
135 treeElement.listItemElement.classList.add('storage-group-list-item'); 131 treeElement.listItemElement.classList.add('storage-group-list-item');
136 treeElement.setCollapsible(false); 132 treeElement.setCollapsible(false);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 resourceTreeModel.removeEventListener(SDK.ResourceTreeModel.Events.CachedR esourcesLoaded, this._initialize, this); 174 resourceTreeModel.removeEventListener(SDK.ResourceTreeModel.Events.CachedR esourcesLoaded, this._initialize, this);
179 resourceTreeModel.removeEventListener( 175 resourceTreeModel.removeEventListener(
180 SDK.ResourceTreeModel.Events.WillLoadCachedResources, this._resetWithF rames, this); 176 SDK.ResourceTreeModel.Events.WillLoadCachedResources, this._resetWithF rames, this);
181 } 177 }
182 this._databaseModel.off(Resources.DatabaseModel.DatabaseAddedEvent, this._da tabaseAdded, this); 178 this._databaseModel.off(Resources.DatabaseModel.DatabaseAddedEvent, this._da tabaseAdded, this);
183 this._databaseModel.off(Resources.DatabaseModel.DatabasesRemovedEvent, this. _resetWebSQL, this); 179 this._databaseModel.off(Resources.DatabaseModel.DatabasesRemovedEvent, this. _resetWebSQL, this);
184 180
185 this._resetWithFrames(); 181 this._resetWithFrames();
186 } 182 }
187 183
188 /**
189 * @override
190 */
191 focus() {
192 this._sidebarTree.focus();
193 }
194
195 _initialize() { 184 _initialize() {
196 for (var frame of SDK.ResourceTreeModel.frames()) 185 for (var frame of SDK.ResourceTreeModel.frames())
197 this._addCookieDocument(frame); 186 this._addCookieDocument(frame);
198 this._databaseModel.enable(); 187 this._databaseModel.enable();
199 188
200 var indexedDBModel = Resources.IndexedDBModel.fromTarget(this._target); 189 var indexedDBModel = Resources.IndexedDBModel.fromTarget(this._target);
201 if (indexedDBModel) 190 if (indexedDBModel)
202 indexedDBModel.enable(); 191 indexedDBModel.enable();
203 192
204 var cacheStorageModel = SDK.ServiceWorkerCacheModel.fromTarget(this._target) ; 193 var cacheStorageModel = SDK.ServiceWorkerCacheModel.fromTarget(this._target) ;
205 if (cacheStorageModel) 194 if (cacheStorageModel)
206 cacheStorageModel.enable(); 195 cacheStorageModel.enable();
207 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(this._target); 196 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(this._target);
208 if (resourceTreeModel) 197 if (resourceTreeModel)
209 this._populateApplicationCacheTree(resourceTreeModel); 198 this._populateApplicationCacheTree(resourceTreeModel);
210 var domStorageModel = Resources.DOMStorageModel.fromTarget(this._target); 199 var domStorageModel = Resources.DOMStorageModel.fromTarget(this._target);
211 if (domStorageModel) 200 if (domStorageModel)
212 this._populateDOMStorageTree(domStorageModel); 201 this._populateDOMStorageTree(domStorageModel);
213 this.indexedDBListTreeElement._initialize(); 202 this.indexedDBListTreeElement._initialize();
214 this.cacheStorageListTreeElement._initialize(); 203 this.cacheStorageListTreeElement._initialize(this._target);
215 this._initDefaultSelection(); 204 this._initDefaultSelection();
216 } 205 }
217 206
218 _initDefaultSelection() { 207 _initDefaultSelection() {
219 var itemURL = this._resourcesLastSelectedItemSetting.get(); 208 var itemURL = this._panel.lastSelectedItemURL();
220 if (itemURL) { 209 if (itemURL) {
221 var rootElement = this._sidebarTree.rootElement(); 210 var rootElement = this._sidebarTree.rootElement();
222 for (var treeElement = rootElement.firstChild(); treeElement; 211 for (var treeElement = rootElement.firstChild(); treeElement;
223 treeElement = treeElement.traverseNextTreeElement(false, rootElement, true)) { 212 treeElement = treeElement.traverseNextTreeElement(false, rootElement, true)) {
224 if (treeElement.itemURL === itemURL) { 213 if (treeElement.itemURL === itemURL) {
225 treeElement.revealAndSelect(true); 214 treeElement.revealAndSelect(true);
226 return; 215 return;
227 } 216 }
228 } 217 }
229 } 218 }
230 this._manifestTreeElement.select(); 219 this._manifestTreeElement.select();
231 } 220 }
232 221
233 _resetWithFrames() { 222 _resetWithFrames() {
234 this._resourcesSection.reset(); 223 this._resourcesSection.reset();
235 this._reset(); 224 this._reset();
236 } 225 }
237 226
238 _resetWebSQL() { 227 _resetWebSQL() {
239 if (this.visibleView instanceof Resources.DatabaseQueryView ||
240 this.visibleView instanceof Resources.DatabaseTableView) {
241 this.visibleView.detach();
242 delete this.visibleView;
243 }
244
245 var queryViews = this._databaseQueryViews.valuesArray(); 228 var queryViews = this._databaseQueryViews.valuesArray();
246 for (var i = 0; i < queryViews.length; ++i) { 229 for (var i = 0; i < queryViews.length; ++i) {
247 queryViews[i].removeEventListener( 230 queryViews[i].removeEventListener(
248 Resources.DatabaseQueryView.Events.SchemaUpdated, this._updateDatabase Tables, this); 231 Resources.DatabaseQueryView.Events.SchemaUpdated, this._updateDatabase Tables, this);
249 } 232 }
250 this._databaseTableViews.clear(); 233 this._databaseTableViews.clear();
251 this._databaseQueryViews.clear(); 234 this._databaseQueryViews.clear();
252 this._databaseTreeElements.clear(); 235 this._databaseTreeElements.clear();
253 this.databasesListTreeElement.removeChildren(); 236 this.databasesListTreeElement.removeChildren();
254 this.databasesListTreeElement.setExpandable(false); 237 this.databasesListTreeElement.setExpandable(false);
255 } 238 }
256 239
257 _resetDOMStorage() { 240 _resetDOMStorage() {
258 if (this.visibleView === this._domStorageView) {
259 this.visibleView.detach();
260 delete this.visibleView;
261 }
262
263 this._domStorageTreeElements.clear(); 241 this._domStorageTreeElements.clear();
264 this.localStorageListTreeElement.removeChildren(); 242 this.localStorageListTreeElement.removeChildren();
265 this.sessionStorageListTreeElement.removeChildren(); 243 this.sessionStorageListTreeElement.removeChildren();
266 } 244 }
267 245
268 _resetCookies() { 246 _resetCookies() {
269 if (this.visibleView instanceof Resources.CookieItemsView) {
270 this.visibleView.detach();
271 delete this.visibleView;
272 }
273 this.cookieListTreeElement.removeChildren(); 247 this.cookieListTreeElement.removeChildren();
274 } 248 }
275 249
276 _resetCacheStorage() { 250 _resetCacheStorage() {
277 if (this.visibleView instanceof Resources.ServiceWorkerCacheView) {
278 this.visibleView.detach();
279 delete this.visibleView;
280 }
281 this.cacheStorageListTreeElement.removeChildren(); 251 this.cacheStorageListTreeElement.removeChildren();
282 this.cacheStorageListTreeElement.setExpandable(false); 252 this.cacheStorageListTreeElement.setExpandable(false);
283 } 253 }
284 254
285 _resetAppCache() { 255 _resetAppCache() {
286 for (var frameId of Object.keys(this._applicationCacheFrameElements)) 256 for (var frameId of Object.keys(this._applicationCacheFrameElements))
287 this._applicationCacheFrameManifestRemoved({data: frameId}); 257 this._applicationCacheFrameManifestRemoved({data: frameId});
288 this.applicationCacheListTreeElement.setExpandable(false); 258 this.applicationCacheListTreeElement.setExpandable(false);
289 } 259 }
290 260
291 _reset() { 261 _reset() {
292 this._domains = {}; 262 this._domains = {};
293 this._resetWebSQL(); 263 this._resetWebSQL();
294 this._resetDOMStorage(); 264 this._resetDOMStorage();
295 this._resetCookies(); 265 this._resetCookies();
296 this._resetCacheStorage(); 266 this._resetCacheStorage();
297 // No need to this._resetAppCache. 267 // No need to this._resetAppCache.
298 268
299 if ((this.visibleView instanceof SourceFrame.ResourceSourceFrame) || 269 this._panel.resetView();
300 (this.visibleView instanceof SourceFrame.ImageView) || (this.visibleView instanceof SourceFrame.FontView)) {
301 this.visibleView.detach();
302 delete this.visibleView;
303 }
304
305 this._storageViewToolbar.removeToolbarItems();
306 270
307 if (this._sidebarTree.selectedTreeElement) 271 if (this._sidebarTree.selectedTreeElement)
308 this._sidebarTree.selectedTreeElement.deselect(); 272 this._sidebarTree.selectedTreeElement.deselect();
309 } 273 }
310 274
311 _frameNavigated(event) { 275 _frameNavigated(event) {
312 var frame = event.data; 276 var frame = event.data;
313 277
314 if (!frame.parentFrame) 278 if (!frame.parentFrame)
315 this._reset(); 279 this._reset();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 this._showDatabase(database); 362 this._showDatabase(database);
399 this._databaseTreeElements.get(database).select(); 363 this._databaseTreeElements.get(database).select();
400 } 364 }
401 } 365 }
402 366
403 /** 367 /**
404 * @param {!Resources.DOMStorage} domStorage 368 * @param {!Resources.DOMStorage} domStorage
405 */ 369 */
406 selectDOMStorage(domStorage) { 370 selectDOMStorage(domStorage) {
407 if (domStorage) { 371 if (domStorage) {
408 this._showDOMStorage(domStorage); 372 this.showDOMStorage(domStorage);
409 this._domStorageTreeElements.get(domStorage).select(); 373 this._domStorageTreeElements.get(domStorage).select();
410 } 374 }
411 } 375 }
412 376
413 /** 377 /**
414 * @param {!SDK.Resource} resource 378 * @param {!SDK.Resource} resource
415 * @param {number=} line 379 * @param {number=} line
416 * @param {number=} column 380 * @param {number=} column
417 * @return {boolean} 381 * @return {boolean}
418 */ 382 */
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 view.addEventListener(Resources.DatabaseQueryView.Events.SchemaUpdated, this._updateDatabaseTables, this); 432 view.addEventListener(Resources.DatabaseQueryView.Events.SchemaUpdated, this._updateDatabaseTables, this);
469 } 433 }
470 } 434 }
471 435
472 this._innerShowView(view); 436 this._innerShowView(view);
473 } 437 }
474 438
475 /** 439 /**
476 * @param {!Resources.DOMStorage} domStorage 440 * @param {!Resources.DOMStorage} domStorage
477 */ 441 */
478 _showDOMStorage(domStorage) { 442 showDOMStorage(domStorage) {
479 if (!domStorage) 443 if (!domStorage)
480 return; 444 return;
481 445
482 if (!this._domStorageView) 446 if (!this._domStorageView)
483 this._domStorageView = new Resources.DOMStorageItemsView(domStorage); 447 this._domStorageView = new Resources.DOMStorageItemsView(domStorage);
484 else 448 else
485 this._domStorageView.setStorage(domStorage); 449 this._domStorageView.setStorage(domStorage);
486 this._innerShowView(this._domStorageView); 450 this._innerShowView(this._domStorageView);
487 } 451 }
488 452
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 this._innerShowView(this._applicationCacheViews[frameId]); 484 this._innerShowView(this._applicationCacheViews[frameId]);
521 } 485 }
522 486
523 /** 487 /**
524 * @param {!UI.Widget} view 488 * @param {!UI.Widget} view
525 */ 489 */
526 showFileSystem(view) { 490 showFileSystem(view) {
527 this._innerShowView(view); 491 this._innerShowView(view);
528 } 492 }
529 493
530 showCategoryView(categoryName) {
531 if (!this._categoryView)
532 this._categoryView = new Resources.StorageCategoryView();
533 this._categoryView.setText(categoryName);
534 this._innerShowView(this._categoryView);
535 }
536
537 _innerShowView(view) { 494 _innerShowView(view) {
538 if (this.visibleView === view) 495 this._panel.showView(view);
539 return;
540
541 if (this.visibleView)
542 this.visibleView.detach();
543
544 view.show(this.storageViews);
545 this.visibleView = view;
546
547 this._storageViewToolbar.removeToolbarItems();
548 var toolbarItems = (view instanceof UI.SimpleView && view.syncToolbarItems() ) || [];
549 for (var i = 0; i < toolbarItems.length; ++i)
550 this._storageViewToolbar.appendToolbarItem(toolbarItems[i]);
551 this._storageViewToolbar.element.classList.toggle('hidden', !toolbarItems.le ngth);
552 }
553
554 closeVisibleView() {
555 if (!this.visibleView)
556 return;
557 this.visibleView.detach();
558 delete this.visibleView;
559 } 496 }
560 497
561 _updateDatabaseTables(event) { 498 _updateDatabaseTables(event) {
562 var database = event.data; 499 var database = event.data;
563 500
564 if (!database) 501 if (!database)
565 return; 502 return;
566 503
567 var databasesTreeElement = this._databaseTreeElements.get(database); 504 var databasesTreeElement = this._databaseTreeElements.get(database);
568 if (!databasesTreeElement) 505 if (!databasesTreeElement)
569 return; 506 return;
570 507
571 databasesTreeElement.invalidateChildren(); 508 databasesTreeElement.invalidateChildren();
572 var tableViews = this._databaseTableViews.get(database); 509 var tableViews = this._databaseTableViews.get(database);
573 510
574 if (!tableViews) 511 if (!tableViews)
575 return; 512 return;
576 513
577 var tableNamesHash = {}; 514 var tableNamesHash = {};
578 var self = this; 515 var panel = this._panel;
579 function tableNamesCallback(tableNames) { 516 function tableNamesCallback(tableNames) {
580 var tableNamesLength = tableNames.length; 517 var tableNamesLength = tableNames.length;
581 for (var i = 0; i < tableNamesLength; ++i) 518 for (var i = 0; i < tableNamesLength; ++i)
582 tableNamesHash[tableNames[i]] = true; 519 tableNamesHash[tableNames[i]] = true;
583 520
584 for (var tableName in tableViews) { 521 for (var tableName in tableViews) {
585 if (!(tableName in tableNamesHash)) { 522 if (!(tableName in tableNamesHash)) {
586 if (self.visibleView === tableViews[tableName]) 523 if (panel.visibleView === tableViews[tableName])
587 self.closeVisibleView(); 524 panel.showView(null);
588 delete tableViews[tableName]; 525 delete tableViews[tableName];
589 } 526 }
590 } 527 }
591 } 528 }
592 database.getTableNames(tableNamesCallback); 529 database.getTableNames(tableNamesCallback);
593 } 530 }
594 531
595 /** 532 /**
596 * @param {!Resources.DOMStorageModel} domStorageModel 533 * @param {!Resources.DOMStorageModel} domStorageModel
597 */ 534 */
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 645
709 _onmouseleave(event) { 646 _onmouseleave(event) {
710 if (this._previousHoveredElement) { 647 if (this._previousHoveredElement) {
711 this._previousHoveredElement.hovered = false; 648 this._previousHoveredElement.hovered = false;
712 delete this._previousHoveredElement; 649 delete this._previousHoveredElement;
713 } 650 }
714 } 651 }
715 }; 652 };
716 653
717 /** 654 /**
718 * @implements {Common.Revealer}
719 * @unrestricted
720 */
721 Resources.ResourcesPanel.ResourceRevealer = class {
722 /**
723 * @override
724 * @param {!Object} resource
725 * @return {!Promise}
726 */
727 reveal(resource) {
728 if (!(resource instanceof SDK.Resource))
729 return Promise.reject(new Error('Internal error: not a resource'));
730 var panel = Resources.ResourcesPanel._instance();
731 return UI.viewManager.showView('resources').then(panel.showResource.bind(pan el, resource));
732 }
733 };
734
735 /**
736 * @unrestricted 655 * @unrestricted
737 */ 656 */
738 Resources.BaseStorageTreeElement = class extends UI.TreeElement { 657 Resources.BaseStorageTreeElement = class extends Resources.SidebarTreeElement {
739 /** 658 /**
740 * @param {!Resources.ResourcesPanel} storagePanel 659 * @param {!Resources.ApplicationPanelSidebar} storagePanel
741 * @param {string} title 660 * @param {string} title
742 * @param {boolean} expandable 661 * @param {boolean} expandable
743 */ 662 */
744 constructor(storagePanel, title, expandable) { 663 constructor(storagePanel, title, expandable) {
745 super(title, expandable); 664 super(storagePanel._panel, title, expandable);
746 this._storagePanel = storagePanel; 665 this._storagePanel = storagePanel;
747 } 666 }
748
749 /**
750 * @override
751 * @return {boolean}
752 */
753 onselect(selectedByUser) {
754 if (!selectedByUser)
755 return false;
756 var itemURL = this.itemURL;
757 if (itemURL)
758 this._storagePanel._resourcesLastSelectedItemSetting.set(itemURL);
759 return false;
760 }
761
762 /**
763 * @protected
764 * @param {?UI.Widget} view
765 */
766 showView(view) {
767 if (!view) {
768 this._storagePanel.visibleView.detach();
769 return;
770 }
771 this._storagePanel._innerShowView(view);
772 }
773 }; 667 };
774 668
775 /** 669 /**
776 * @unrestricted
777 */
778 Resources.StorageCategoryTreeElement = class extends Resources.BaseStorageTreeEl ement {
779 /**
780 * @param {!Resources.ResourcesPanel} storagePanel
781 * @param {string} categoryName
782 * @param {string} settingsKey
783 */
784 constructor(storagePanel, categoryName, settingsKey) {
785 super(storagePanel, categoryName, false);
786 this._expandedSetting =
787 Common.settings.createSetting('resources' + settingsKey + 'Expanded', se ttingsKey === 'Frames');
788 this._categoryName = categoryName;
789 }
790
791 /**
792 * @return {!SDK.Target}
793 */
794 target() {
795 return this._storagePanel._target;
796 }
797
798 get itemURL() {
799 return 'category://' + this._categoryName;
800 }
801
802 /**
803 * @override
804 * @return {boolean}
805 */
806 onselect(selectedByUser) {
807 super.onselect(selectedByUser);
808 this._storagePanel.showCategoryView(this._categoryName);
809 return false;
810 }
811
812 /**
813 * @override
814 */
815 onattach() {
816 super.onattach();
817 if (this._expandedSetting.get())
818 this.expand();
819 }
820
821 /**
822 * @override
823 */
824 onexpand() {
825 this._expandedSetting.set(true);
826 }
827
828 /**
829 * @override
830 */
831 oncollapse() {
832 this._expandedSetting.set(false);
833 }
834 };
835
836 /**
837 * @unrestricted 670 * @unrestricted
838 */ 671 */
839 Resources.DatabaseTreeElement = class extends Resources.BaseStorageTreeElement { 672 Resources.DatabaseTreeElement = class extends Resources.BaseStorageTreeElement {
840 /** 673 /**
841 * @param {!Resources.ResourcesPanel} storagePanel 674 * @param {!Resources.ApplicationPanelSidebar} storagePanel
842 * @param {!Resources.Database} database 675 * @param {!Resources.Database} database
843 */ 676 */
844 constructor(storagePanel, database) { 677 constructor(storagePanel, database) {
845 super(storagePanel, database.name, true); 678 super(storagePanel, database.name, true);
846 this._database = database; 679 this._database = database;
847 680
848 var icon = UI.Icon.create('mediumicon-database', 'resource-tree-item'); 681 var icon = UI.Icon.create('mediumicon-database', 'resource-tree-item');
849 this.setLeadingIcons([icon]); 682 this.setLeadingIcons([icon]);
850 } 683 }
851 684
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 * @unrestricted 750 * @unrestricted
918 */ 751 */
919 Resources.ServiceWorkerCacheTreeElement = class extends Resources.StorageCategor yTreeElement { 752 Resources.ServiceWorkerCacheTreeElement = class extends Resources.StorageCategor yTreeElement {
920 /** 753 /**
921 * @param {!Resources.ResourcesPanel} storagePanel 754 * @param {!Resources.ResourcesPanel} storagePanel
922 */ 755 */
923 constructor(storagePanel) { 756 constructor(storagePanel) {
924 super(storagePanel, Common.UIString('Cache Storage'), 'CacheStorage'); 757 super(storagePanel, Common.UIString('Cache Storage'), 'CacheStorage');
925 var icon = UI.Icon.create('mediumicon-database', 'resource-tree-item'); 758 var icon = UI.Icon.create('mediumicon-database', 'resource-tree-item');
926 this.setLeadingIcons([icon]); 759 this.setLeadingIcons([icon]);
760 /** @type {?SDK.Target} */
761 this._target = null;
caseq 2017/03/20 18:04:26 Can we rather explicitly keep the model that we ne
eostroukhov 2017/03/20 19:28:01 Done.
927 } 762 }
928 763
929 _initialize() { 764 /**
765 * @param {?SDK.Target} target
766 */
767 _initialize(target) {
768 this._target = target;
930 /** @type {!Array.<!Resources.SWCacheTreeElement>} */ 769 /** @type {!Array.<!Resources.SWCacheTreeElement>} */
931 this._swCacheTreeElements = []; 770 this._swCacheTreeElements = [];
932 var target = this._storagePanel._target;
933 var model = target && SDK.ServiceWorkerCacheModel.fromTarget(target); 771 var model = target && SDK.ServiceWorkerCacheModel.fromTarget(target);
934 if (model) { 772 if (model) {
935 for (var cache of model.caches()) 773 for (var cache of model.caches())
936 this._addCache(model, cache); 774 this._addCache(model, cache);
937 } 775 }
938 SDK.targetManager.addModelListener( 776 SDK.targetManager.addModelListener(
939 SDK.ServiceWorkerCacheModel, SDK.ServiceWorkerCacheModel.Events.CacheAdd ed, this._cacheAdded, this); 777 SDK.ServiceWorkerCacheModel, SDK.ServiceWorkerCacheModel.Events.CacheAdd ed, this._cacheAdded, this);
940 SDK.targetManager.addModelListener( 778 SDK.targetManager.addModelListener(
941 SDK.ServiceWorkerCacheModel, SDK.ServiceWorkerCacheModel.Events.CacheRem oved, this._cacheRemoved, this); 779 SDK.ServiceWorkerCacheModel, SDK.ServiceWorkerCacheModel.Events.CacheRem oved, this._cacheRemoved, this);
942 } 780 }
943 781
944 /** 782 /**
945 * @override 783 * @override
946 */ 784 */
947 onattach() { 785 onattach() {
948 super.onattach(); 786 super.onattach();
949 this.listItemElement.addEventListener('contextmenu', this._handleContextMenu Event.bind(this), true); 787 this.listItemElement.addEventListener('contextmenu', this._handleContextMenu Event.bind(this), true);
950 } 788 }
951 789
952 _handleContextMenuEvent(event) { 790 _handleContextMenuEvent(event) {
953 var contextMenu = new UI.ContextMenu(event); 791 var contextMenu = new UI.ContextMenu(event);
954 contextMenu.appendItem(Common.UIString('Refresh Caches'), this._refreshCache s.bind(this)); 792 contextMenu.appendItem(Common.UIString('Refresh Caches'), this._refreshCache s.bind(this));
955 contextMenu.show(); 793 contextMenu.show();
956 } 794 }
957 795
958 _refreshCaches() { 796 _refreshCaches() {
959 var target = this._storagePanel._target; 797 if (this._target) {
960 if (target) { 798 var model = SDK.ServiceWorkerCacheModel.fromTarget(this._target);
961 var model = SDK.ServiceWorkerCacheModel.fromTarget(target);
962 if (!model) 799 if (!model)
963 return; 800 return;
964 model.refreshCacheNames(); 801 model.refreshCacheNames();
965 } 802 }
966 } 803 }
967 804
968 /** 805 /**
969 * @param {!Common.Event} event 806 * @param {!Common.Event} event
970 */ 807 */
971 _cacheAdded(event) { 808 _cacheAdded(event) {
972 var cache = /** @type {!SDK.ServiceWorkerCacheModel.Cache} */ (event.data.ca che); 809 var cache = /** @type {!SDK.ServiceWorkerCacheModel.Cache} */ (event.data.ca che);
973 var model = /** @type {!SDK.ServiceWorkerCacheModel} */ (event.data.model); 810 var model = /** @type {!SDK.ServiceWorkerCacheModel} */ (event.data.model);
974 this._addCache(model, cache); 811 this._addCache(model, cache);
975 } 812 }
976 813
977 /** 814 /**
978 * @param {!SDK.ServiceWorkerCacheModel} model 815 * @param {!SDK.ServiceWorkerCacheModel} model
979 * @param {!SDK.ServiceWorkerCacheModel.Cache} cache 816 * @param {!SDK.ServiceWorkerCacheModel.Cache} cache
980 */ 817 */
981 _addCache(model, cache) { 818 _addCache(model, cache) {
982 var swCacheTreeElement = new Resources.SWCacheTreeElement(this._storagePanel , model, cache); 819 var swCacheTreeElement = new Resources.SWCacheTreeElement(this.resourcesPane l, model, cache);
983 this._swCacheTreeElements.push(swCacheTreeElement); 820 this._swCacheTreeElements.push(swCacheTreeElement);
984 this.appendChild(swCacheTreeElement); 821 this.appendChild(swCacheTreeElement);
985 } 822 }
986 823
987 /** 824 /**
988 * @param {!Common.Event} event 825 * @param {!Common.Event} event
989 */ 826 */
990 _cacheRemoved(event) { 827 _cacheRemoved(event) {
991 var cache = /** @type {!SDK.ServiceWorkerCacheModel.Cache} */ (event.data.ca che); 828 var cache = /** @type {!SDK.ServiceWorkerCacheModel.Cache} */ (event.data.ca che);
992 var model = /** @type {!SDK.ServiceWorkerCacheModel} */ (event.data.model); 829 var model = /** @type {!SDK.ServiceWorkerCacheModel} */ (event.data.model);
(...skipping 22 matching lines...) Expand all
1015 } 852 }
1016 if (index !== -1) 853 if (index !== -1)
1017 return this._swCacheTreeElements[i]; 854 return this._swCacheTreeElements[i];
1018 return null; 855 return null;
1019 } 856 }
1020 }; 857 };
1021 858
1022 /** 859 /**
1023 * @unrestricted 860 * @unrestricted
1024 */ 861 */
1025 Resources.SWCacheTreeElement = class extends Resources.BaseStorageTreeElement { 862 Resources.SWCacheTreeElement = class extends Resources.SidebarTreeElement {
1026 /** 863 /**
1027 * @param {!Resources.ResourcesPanel} storagePanel 864 * @param {!Resources.ResourcesPanel} storagePanel
1028 * @param {!SDK.ServiceWorkerCacheModel} model 865 * @param {!SDK.ServiceWorkerCacheModel} model
1029 * @param {!SDK.ServiceWorkerCacheModel.Cache} cache 866 * @param {!SDK.ServiceWorkerCacheModel.Cache} cache
1030 */ 867 */
1031 constructor(storagePanel, model, cache) { 868 constructor(storagePanel, model, cache) {
1032 super(storagePanel, cache.cacheName + ' - ' + cache.securityOrigin, false); 869 super(storagePanel, cache.cacheName + ' - ' + cache.securityOrigin, false);
1033 this._model = model; 870 this._model = model;
1034 this._cache = cache; 871 this._cache = cache;
1035 var icon = UI.Icon.create('mediumicon-table', 'resource-tree-item'); 872 var icon = UI.Icon.create('mediumicon-table', 'resource-tree-item');
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 if (this._view) 922 if (this._view)
1086 this._view.clear(); 923 this._view.clear();
1087 } 924 }
1088 }; 925 };
1089 926
1090 /** 927 /**
1091 * @unrestricted 928 * @unrestricted
1092 */ 929 */
1093 Resources.ServiceWorkersTreeElement = class extends Resources.BaseStorageTreeEle ment { 930 Resources.ServiceWorkersTreeElement = class extends Resources.BaseStorageTreeEle ment {
1094 /** 931 /**
1095 * @param {!Resources.ResourcesPanel} storagePanel 932 * @param {!Resources.ApplicationPanelSidebar} storagePanel
1096 */ 933 */
1097 constructor(storagePanel) { 934 constructor(storagePanel) {
1098 super(storagePanel, Common.UIString('Service Workers'), false); 935 super(storagePanel, Common.UIString('Service Workers'), false);
1099 var icon = UI.Icon.create('mediumicon-service-worker', 'resource-tree-item') ; 936 var icon = UI.Icon.create('mediumicon-service-worker', 'resource-tree-item') ;
1100 this.setLeadingIcons([icon]); 937 this.setLeadingIcons([icon]);
1101 } 938 }
1102 939
1103 /** 940 /**
1104 * @return {string} 941 * @return {string}
1105 */ 942 */
(...skipping 12 matching lines...) Expand all
1118 this.showView(this._view); 955 this.showView(this._view);
1119 return false; 956 return false;
1120 } 957 }
1121 }; 958 };
1122 959
1123 /** 960 /**
1124 * @unrestricted 961 * @unrestricted
1125 */ 962 */
1126 Resources.AppManifestTreeElement = class extends Resources.BaseStorageTreeElemen t { 963 Resources.AppManifestTreeElement = class extends Resources.BaseStorageTreeElemen t {
1127 /** 964 /**
1128 * @param {!Resources.ResourcesPanel} storagePanel 965 * @param {!Resources.ApplicationPanelSidebar} storagePanel
1129 */ 966 */
1130 constructor(storagePanel) { 967 constructor(storagePanel) {
1131 super(storagePanel, Common.UIString('Manifest'), false); 968 super(storagePanel, Common.UIString('Manifest'), false);
1132 var icon = UI.Icon.create('mediumicon-manifest', 'resource-tree-item'); 969 var icon = UI.Icon.create('mediumicon-manifest', 'resource-tree-item');
1133 this.setLeadingIcons([icon]); 970 this.setLeadingIcons([icon]);
1134 } 971 }
1135 972
1136 /** 973 /**
1137 * @return {string} 974 * @return {string}
1138 */ 975 */
(...skipping 12 matching lines...) Expand all
1151 this.showView(this._view); 988 this.showView(this._view);
1152 return false; 989 return false;
1153 } 990 }
1154 }; 991 };
1155 992
1156 /** 993 /**
1157 * @unrestricted 994 * @unrestricted
1158 */ 995 */
1159 Resources.ClearStorageTreeElement = class extends Resources.BaseStorageTreeEleme nt { 996 Resources.ClearStorageTreeElement = class extends Resources.BaseStorageTreeEleme nt {
1160 /** 997 /**
1161 * @param {!Resources.ResourcesPanel} storagePanel 998 * @param {!Resources.ApplicationPanelSidebar} storagePanel
1162 */ 999 */
1163 constructor(storagePanel) { 1000 constructor(storagePanel) {
1164 super(storagePanel, Common.UIString('Clear storage'), false); 1001 super(storagePanel, Common.UIString('Clear storage'), false);
1165 var icon = UI.Icon.create('mediumicon-clear-storage', 'resource-tree-item'); 1002 var icon = UI.Icon.create('mediumicon-clear-storage', 'resource-tree-item');
1166 this.setLeadingIcons([icon]); 1003 this.setLeadingIcons([icon]);
1167 } 1004 }
1168 1005
1169 /** 1006 /**
1170 * @return {string} 1007 * @return {string}
1171 */ 1008 */
1172 get itemURL() { 1009 get itemURL() {
1173 return 'clear-storage://'; 1010 return 'clear-storage://';
1174 } 1011 }
1175 1012
1176 /** 1013 /**
1177 * @override 1014 * @override
1178 * @return {boolean} 1015 * @return {boolean}
1179 */ 1016 */
1180 onselect(selectedByUser) { 1017 onselect(selectedByUser) {
1181 super.onselect(selectedByUser); 1018 super.onselect(selectedByUser);
1182 if (!this._view) 1019 if (!this._view)
1183 this._view = new Resources.ClearStorageView(this._storagePanel); 1020 this._view = new Resources.ClearStorageView();
1184 this.showView(this._view); 1021 this.showView(this._view);
1185 return false; 1022 return false;
1186 } 1023 }
1187 }; 1024 };
1188 1025
1189 /** 1026 /**
1190 * @unrestricted 1027 * @unrestricted
1191 */ 1028 */
1192 Resources.IndexedDBTreeElement = class extends Resources.StorageCategoryTreeElem ent { 1029 Resources.IndexedDBTreeElement = class extends Resources.StorageCategoryTreeElem ent {
1193 /** 1030 /**
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 var databaseId = /** @type {!Resources.IndexedDBModel.DatabaseId} */ (event. data.databaseId); 1082 var databaseId = /** @type {!Resources.IndexedDBModel.DatabaseId} */ (event. data.databaseId);
1246 var model = /** @type {!Resources.IndexedDBModel} */ (event.data.model); 1083 var model = /** @type {!Resources.IndexedDBModel} */ (event.data.model);
1247 this._addIndexedDB(model, databaseId); 1084 this._addIndexedDB(model, databaseId);
1248 } 1085 }
1249 1086
1250 /** 1087 /**
1251 * @param {!Resources.IndexedDBModel} model 1088 * @param {!Resources.IndexedDBModel} model
1252 * @param {!Resources.IndexedDBModel.DatabaseId} databaseId 1089 * @param {!Resources.IndexedDBModel.DatabaseId} databaseId
1253 */ 1090 */
1254 _addIndexedDB(model, databaseId) { 1091 _addIndexedDB(model, databaseId) {
1255 var idbDatabaseTreeElement = new Resources.IDBDatabaseTreeElement(this._stor agePanel, model, databaseId); 1092 var idbDatabaseTreeElement = new Resources.IDBDatabaseTreeElement(this.resou rcesPanel, model, databaseId);
1256 this._idbDatabaseTreeElements.push(idbDatabaseTreeElement); 1093 this._idbDatabaseTreeElements.push(idbDatabaseTreeElement);
1257 this.appendChild(idbDatabaseTreeElement); 1094 this.appendChild(idbDatabaseTreeElement);
1258 model.refreshDatabase(databaseId); 1095 model.refreshDatabase(databaseId);
1259 } 1096 }
1260 1097
1261 /** 1098 /**
1262 * @param {!Common.Event} event 1099 * @param {!Common.Event} event
1263 */ 1100 */
1264 _indexedDBRemoved(event) { 1101 _indexedDBRemoved(event) {
1265 var databaseId = /** @type {!Resources.IndexedDBModel.DatabaseId} */ (event. data.databaseId); 1102 var databaseId = /** @type {!Resources.IndexedDBModel.DatabaseId} */ (event. data.databaseId);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 } 1141 }
1305 if (index !== -1) 1142 if (index !== -1)
1306 return this._idbDatabaseTreeElements[i]; 1143 return this._idbDatabaseTreeElements[i];
1307 return null; 1144 return null;
1308 } 1145 }
1309 }; 1146 };
1310 1147
1311 /** 1148 /**
1312 * @unrestricted 1149 * @unrestricted
1313 */ 1150 */
1314 Resources.IDBDatabaseTreeElement = class extends Resources.BaseStorageTreeElemen t { 1151 Resources.IDBDatabaseTreeElement = class extends Resources.SidebarTreeElement {
1315 /** 1152 /**
1316 * @param {!Resources.ResourcesPanel} storagePanel 1153 * @param {!Resources.ResourcesPanel} storagePanel
1317 * @param {!Resources.IndexedDBModel} model 1154 * @param {!Resources.IndexedDBModel} model
1318 * @param {!Resources.IndexedDBModel.DatabaseId} databaseId 1155 * @param {!Resources.IndexedDBModel.DatabaseId} databaseId
1319 */ 1156 */
1320 constructor(storagePanel, model, databaseId) { 1157 constructor(storagePanel, model, databaseId) {
1321 super(storagePanel, databaseId.name + ' - ' + databaseId.securityOrigin, fal se); 1158 super(storagePanel, databaseId.name + ' - ' + databaseId.securityOrigin, fal se);
1322 this._model = model; 1159 this._model = model;
1323 this._databaseId = databaseId; 1160 this._databaseId = databaseId;
1324 this._idbObjectStoreTreeElements = {}; 1161 this._idbObjectStoreTreeElements = {};
(...skipping 27 matching lines...) Expand all
1352 * @param {!Resources.IndexedDBModel.Database} database 1189 * @param {!Resources.IndexedDBModel.Database} database
1353 */ 1190 */
1354 update(database) { 1191 update(database) {
1355 this._database = database; 1192 this._database = database;
1356 var objectStoreNames = {}; 1193 var objectStoreNames = {};
1357 for (var objectStoreName in this._database.objectStores) { 1194 for (var objectStoreName in this._database.objectStores) {
1358 var objectStore = this._database.objectStores[objectStoreName]; 1195 var objectStore = this._database.objectStores[objectStoreName];
1359 objectStoreNames[objectStore.name] = true; 1196 objectStoreNames[objectStore.name] = true;
1360 if (!this._idbObjectStoreTreeElements[objectStore.name]) { 1197 if (!this._idbObjectStoreTreeElements[objectStore.name]) {
1361 var idbObjectStoreTreeElement = 1198 var idbObjectStoreTreeElement =
1362 new Resources.IDBObjectStoreTreeElement(this._storagePanel, this._mo del, this._databaseId, objectStore); 1199 new Resources.IDBObjectStoreTreeElement(this.resourcesPanel, this._m odel, this._databaseId, objectStore);
1363 this._idbObjectStoreTreeElements[objectStore.name] = idbObjectStoreTreeE lement; 1200 this._idbObjectStoreTreeElements[objectStore.name] = idbObjectStoreTreeE lement;
1364 this.appendChild(idbObjectStoreTreeElement); 1201 this.appendChild(idbObjectStoreTreeElement);
1365 } 1202 }
1366 this._idbObjectStoreTreeElements[objectStore.name].update(objectStore); 1203 this._idbObjectStoreTreeElements[objectStore.name].update(objectStore);
1367 } 1204 }
1368 for (var objectStoreName in this._idbObjectStoreTreeElements) { 1205 for (var objectStoreName in this._idbObjectStoreTreeElements) {
1369 if (!objectStoreNames[objectStoreName]) 1206 if (!objectStoreNames[objectStoreName])
1370 this._objectStoreRemoved(objectStoreName); 1207 this._objectStoreRemoved(objectStoreName);
1371 } 1208 }
1372 1209
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 1242
1406 clear() { 1243 clear() {
1407 for (var objectStoreName in this._idbObjectStoreTreeElements) 1244 for (var objectStoreName in this._idbObjectStoreTreeElements)
1408 this._objectStoreRemoved(objectStoreName); 1245 this._objectStoreRemoved(objectStoreName);
1409 } 1246 }
1410 }; 1247 };
1411 1248
1412 /** 1249 /**
1413 * @unrestricted 1250 * @unrestricted
1414 */ 1251 */
1415 Resources.IDBObjectStoreTreeElement = class extends Resources.BaseStorageTreeEle ment { 1252 Resources.IDBObjectStoreTreeElement = class extends Resources.SidebarTreeElement {
1416 /** 1253 /**
1417 * @param {!Resources.ResourcesPanel} storagePanel 1254 * @param {!Resources.ResourcesPanel} storagePanel
1418 * @param {!Resources.IndexedDBModel} model 1255 * @param {!Resources.IndexedDBModel} model
1419 * @param {!Resources.IndexedDBModel.DatabaseId} databaseId 1256 * @param {!Resources.IndexedDBModel.DatabaseId} databaseId
1420 * @param {!Resources.IndexedDBModel.ObjectStore} objectStore 1257 * @param {!Resources.IndexedDBModel.ObjectStore} objectStore
1421 */ 1258 */
1422 constructor(storagePanel, model, databaseId, objectStore) { 1259 constructor(storagePanel, model, databaseId, objectStore) {
1423 super(storagePanel, objectStore.name, false); 1260 super(storagePanel, objectStore.name, false);
1424 this._model = model; 1261 this._model = model;
1425 this._databaseId = databaseId; 1262 this._databaseId = databaseId;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 */ 1299 */
1463 update(objectStore) { 1300 update(objectStore) {
1464 this._objectStore = objectStore; 1301 this._objectStore = objectStore;
1465 1302
1466 var indexNames = {}; 1303 var indexNames = {};
1467 for (var indexName in this._objectStore.indexes) { 1304 for (var indexName in this._objectStore.indexes) {
1468 var index = this._objectStore.indexes[indexName]; 1305 var index = this._objectStore.indexes[indexName];
1469 indexNames[index.name] = true; 1306 indexNames[index.name] = true;
1470 if (!this._idbIndexTreeElements[index.name]) { 1307 if (!this._idbIndexTreeElements[index.name]) {
1471 var idbIndexTreeElement = new Resources.IDBIndexTreeElement( 1308 var idbIndexTreeElement = new Resources.IDBIndexTreeElement(
1472 this._storagePanel, this._model, this._databaseId, this._objectStore , index); 1309 this.resourcesPanel, this._model, this._databaseId, this._objectStor e, index);
1473 this._idbIndexTreeElements[index.name] = idbIndexTreeElement; 1310 this._idbIndexTreeElements[index.name] = idbIndexTreeElement;
1474 this.appendChild(idbIndexTreeElement); 1311 this.appendChild(idbIndexTreeElement);
1475 } 1312 }
1476 this._idbIndexTreeElements[index.name].update(index); 1313 this._idbIndexTreeElements[index.name].update(index);
1477 } 1314 }
1478 for (var indexName in this._idbIndexTreeElements) { 1315 for (var indexName in this._idbIndexTreeElements) {
1479 if (!indexNames[indexName]) 1316 if (!indexNames[indexName])
1480 this._indexRemoved(indexName); 1317 this._indexRemoved(indexName);
1481 } 1318 }
1482 for (var indexName in this._idbIndexTreeElements) { 1319 for (var indexName in this._idbIndexTreeElements) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 for (var indexName in this._idbIndexTreeElements) 1367 for (var indexName in this._idbIndexTreeElements)
1531 this._indexRemoved(indexName); 1368 this._indexRemoved(indexName);
1532 if (this._view) 1369 if (this._view)
1533 this._view.clear(); 1370 this._view.clear();
1534 } 1371 }
1535 }; 1372 };
1536 1373
1537 /** 1374 /**
1538 * @unrestricted 1375 * @unrestricted
1539 */ 1376 */
1540 Resources.IDBIndexTreeElement = class extends Resources.BaseStorageTreeElement { 1377 Resources.IDBIndexTreeElement = class extends Resources.SidebarTreeElement {
1541 /** 1378 /**
1542 * @param {!Resources.ResourcesPanel} storagePanel 1379 * @param {!Resources.ResourcesPanel} storagePanel
1543 * @param {!Resources.IndexedDBModel} model 1380 * @param {!Resources.IndexedDBModel} model
1544 * @param {!Resources.IndexedDBModel.DatabaseId} databaseId 1381 * @param {!Resources.IndexedDBModel.DatabaseId} databaseId
1545 * @param {!Resources.IndexedDBModel.ObjectStore} objectStore 1382 * @param {!Resources.IndexedDBModel.ObjectStore} objectStore
1546 * @param {!Resources.IndexedDBModel.Index} index 1383 * @param {!Resources.IndexedDBModel.Index} index
1547 */ 1384 */
1548 constructor(storagePanel, model, databaseId, objectStore, index) { 1385 constructor(storagePanel, model, databaseId, objectStore, index) {
1549 super(storagePanel, index.name, false); 1386 super(storagePanel, index.name, false);
1550 this._model = model; 1387 this._model = model;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1615 return 'storage://' + this._domStorage.securityOrigin + '/' + 1452 return 'storage://' + this._domStorage.securityOrigin + '/' +
1616 (this._domStorage.isLocalStorage ? 'local' : 'session'); 1453 (this._domStorage.isLocalStorage ? 'local' : 'session');
1617 } 1454 }
1618 1455
1619 /** 1456 /**
1620 * @override 1457 * @override
1621 * @return {boolean} 1458 * @return {boolean}
1622 */ 1459 */
1623 onselect(selectedByUser) { 1460 onselect(selectedByUser) {
1624 super.onselect(selectedByUser); 1461 super.onselect(selectedByUser);
1625 this._storagePanel._showDOMStorage(this._domStorage); 1462 this._storagePanel.showDOMStorage(this._domStorage);
1626 return false; 1463 return false;
1627 } 1464 }
1628 1465
1629 /** 1466 /**
1630 * @override 1467 * @override
1631 */ 1468 */
1632 onattach() { 1469 onattach() {
1633 super.onattach(); 1470 super.onattach();
1634 this.listItemElement.addEventListener('contextmenu', this._handleContextMenu Event.bind(this), true); 1471 this.listItemElement.addEventListener('contextmenu', this._handleContextMenu Event.bind(this), true);
1635 } 1472 }
1636 1473
1637 _handleContextMenuEvent(event) { 1474 _handleContextMenuEvent(event) {
1638 var contextMenu = new UI.ContextMenu(event); 1475 var contextMenu = new UI.ContextMenu(event);
1639 contextMenu.appendItem(Common.UIString('Clear'), () => this._domStorage.clea r()); 1476 contextMenu.appendItem(Common.UIString('Clear'), () => this._domStorage.clea r());
1640 contextMenu.show(); 1477 contextMenu.show();
1641 } 1478 }
1642 }; 1479 };
1643 1480
1644 Resources.CookieTreeElement = class extends Resources.BaseStorageTreeElement { 1481 Resources.CookieTreeElement = class extends Resources.BaseStorageTreeElement {
1645 /** 1482 /**
1646 * @param {!Resources.ResourcesPanel} storagePanel 1483 * @param {!Resources.ApplicationPanelSidebar} storagePanel
1647 * @param {!SDK.ResourceTreeFrame} frame 1484 * @param {!SDK.ResourceTreeFrame} frame
1648 * @param {string} cookieDomain 1485 * @param {string} cookieDomain
1649 */ 1486 */
1650 constructor(storagePanel, frame, cookieDomain) { 1487 constructor(storagePanel, frame, cookieDomain) {
1651 super(storagePanel, cookieDomain ? cookieDomain : Common.UIString('Local Fil es'), false); 1488 super(storagePanel, cookieDomain ? cookieDomain : Common.UIString('Local Fil es'), false);
1652 this._target = frame.target(); 1489 this._target = frame.target();
1653 this._cookieDomain = cookieDomain; 1490 this._cookieDomain = cookieDomain;
1654 var icon = UI.Icon.create('mediumicon-cookie', 'resource-tree-item'); 1491 var icon = UI.Icon.create('mediumicon-cookie', 'resource-tree-item');
1655 this.setLeadingIcons([icon]); 1492 this.setLeadingIcons([icon]);
1656 } 1493 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 get manifestURL() { 1543 get manifestURL() {
1707 return this._manifestURL; 1544 return this._manifestURL;
1708 } 1545 }
1709 1546
1710 /** 1547 /**
1711 * @override 1548 * @override
1712 * @return {boolean} 1549 * @return {boolean}
1713 */ 1550 */
1714 onselect(selectedByUser) { 1551 onselect(selectedByUser) {
1715 super.onselect(selectedByUser); 1552 super.onselect(selectedByUser);
1716 this._storagePanel.showCategoryView(this._manifestURL); 1553 this.resourcesPanel.showCategoryView(this._manifestURL);
1717 return false; 1554 return false;
1718 } 1555 }
1719 }; 1556 };
1720 1557
1721 /** 1558 /**
1722 * @unrestricted 1559 * @unrestricted
1723 */ 1560 */
1724 Resources.ApplicationCacheFrameTreeElement = class extends Resources.BaseStorage TreeElement { 1561 Resources.ApplicationCacheFrameTreeElement = class extends Resources.BaseStorage TreeElement {
1725 /** 1562 /**
1726 * @param {!Resources.ResourcesPanel} storagePanel 1563 * @param {!Resources.ApplicationPanelSidebar} storagePanel
1727 * @param {!Protocol.Page.FrameId} frameId 1564 * @param {!Protocol.Page.FrameId} frameId
1728 * @param {string} manifestURL 1565 * @param {string} manifestURL
1729 */ 1566 */
1730 constructor(storagePanel, frameId, manifestURL) { 1567 constructor(storagePanel, frameId, manifestURL) {
1731 super(storagePanel, '', false); 1568 super(storagePanel, '', false);
1732 this._frameId = frameId; 1569 this._frameId = frameId;
1733 this._manifestURL = manifestURL; 1570 this._manifestURL = manifestURL;
1734 this._refreshTitles(); 1571 this._refreshTitles();
1735 1572
1736 var icon = UI.Icon.create('largeicon-navigator-folder', 'navigator-tree-item '); 1573 var icon = UI.Icon.create('largeicon-navigator-folder', 'navigator-tree-item ');
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 1617
1781 this.element.classList.add('storage-view'); 1618 this.element.classList.add('storage-view');
1782 this._emptyWidget = new UI.EmptyWidget(''); 1619 this._emptyWidget = new UI.EmptyWidget('');
1783 this._emptyWidget.show(this.element); 1620 this._emptyWidget.show(this.element);
1784 } 1621 }
1785 1622
1786 setText(text) { 1623 setText(text) {
1787 this._emptyWidget.text = text; 1624 this._emptyWidget.text = text;
1788 } 1625 }
1789 }; 1626 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698