Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / tools / test / reference_build / chrome_linux / resources / inspector / resources / ResourcesPanel.js
1 WebInspector.ApplicationCacheItemsView=function(model,frameId)
2 {WebInspector.VBox.call(this);this._model=model;this.element.classList.add("storage-view");this.element.classList.add("table");this.deleteButton=new WebInspector.StatusBarButton(WebInspector.UIString("Delete"),"delete-storage-status-bar-item");this.deleteButton.visible=false;this.deleteButton.addEventListener("click",this._deleteButtonClicked,this);this.connectivityIcon=document.createElement("div");this.connectivityMessage=document.createElement("span");this.connectivityMessage.className="storage-application-cache-connectivity";this.connectivityMessage.textContent="";this.divider=document.createElement("span");this.divider.className="status-bar-item status-bar-divider";this.statusIcon=document.createElement("div");this.statusMessage=document.createElement("span");this.statusMessage.className="storage-application-cache-status";this.statusMessage.textContent="";this._frameId=frameId;this._emptyView=new WebInspector.EmptyView(WebInspector.UIString("No Application Cache information available."));this._emptyView.show(this.element);this._markDirty();var status=this._model.frameManifestStatus(frameId);this.updateStatus(status);this.updateNetworkState(this._model.onLine);this.deleteButton.element.style.display="none";}
3 WebInspector.ApplicationCacheItemsView.prototype={get statusBarItems()
4 {return[this.deleteButton.element,this.connectivityIcon,this.connectivityMessage,this.divider,this.statusIcon,this.statusMessage];},wasShown:function()
5 {this._maybeUpdate();},willHide:function()
6 {this.deleteButton.visible=false;},_maybeUpdate:function()
7 {if(!this.isShowing()||!this._viewDirty)
8 return;this._update();this._viewDirty=false;},_markDirty:function()
9 {this._viewDirty=true;},updateStatus:function(status)
10 {var oldStatus=this._status;this._status=status;var statusInformation={};statusInformation[applicationCache.UNCACHED]={className:"red-ball",text:"UNCACHED"};statusInformation[applicationCache.IDLE]={className:"green-ball",text:"IDLE"};statusInformation[applicationCache.CHECKING]={className:"orange-ball",text:"CHECKING"};statusInformation[applicationCache.DOWNLOADING]={className:"orange-ball",text:"DOWNLOADING"};statusInformation[applicationCache.UPDATEREADY]={className:"green-ball",text:"UPDATEREADY"};statusInformation[applicationCache.OBSOLETE]={className:"red-ball",text:"OBSOLETE"};var info=statusInformation[status]||statusInformation[applicationCache.UNCACHED];this.statusIcon.className="storage-application-cache-status-icon "+info.className;this.statusMessage.textContent=info.text;if(this.isShowing()&&this._status===applicationCache.IDLE&&(oldStatus===applicationCache.UPDATEREADY||!this._resources))
11 this._markDirty();this._maybeUpdate();},updateNetworkState:function(isNowOnline)
12 {if(isNowOnline){this.connectivityIcon.className="storage-application-cache-connectivity-icon green-ball";this.connectivityMessage.textContent=WebInspector.UIString("Online");}else{this.connectivityIcon.className="storage-application-cache-connectivity-icon red-ball";this.connectivityMessage.textContent=WebInspector.UIString("Offline");}},_update:function()
13 {this._model.requestApplicationCache(this._frameId,this._updateCallback.bind(this));},_updateCallback:function(applicationCache)
14 {if(!applicationCache||!applicationCache.manifestURL){delete this._manifest;delete this._creationTime;delete this._updateTime;delete this._size;delete this._resources;this._emptyView.show(this.element);this.deleteButton.visible=false;if(this._dataGrid)
15 this._dataGrid.element.classList.add("hidden");return;}
16 this._manifest=applicationCache.manifestURL;this._creationTime=applicationCache.creationTime;this._updateTime=applicationCache.updateTime;this._size=applicationCache.size;this._resources=applicationCache.resources;if(!this._dataGrid)
17 this._createDataGrid();this._populateDataGrid();this._dataGrid.autoSizeColumns(20,80);this._dataGrid.element.classList.remove("hidden");this._emptyView.detach();this.deleteButton.visible=true;},_createDataGrid:function()
18 {var columns=[{title:WebInspector.UIString("Resource"),sort:WebInspector.DataGrid.Order.Ascending,sortable:true},{title:WebInspector.UIString("Type"),sortable:true},{title:WebInspector.UIString("Size"),align:WebInspector.DataGrid.Align.Right,sortable:true}];this._dataGrid=new WebInspector.DataGrid(columns);this._dataGrid.show(this.element);this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged,this._populateDataGrid,this);},_populateDataGrid:function()
19 {var selectedResource=this._dataGrid.selectedNode?this._dataGrid.selectedNode.resource:null;var sortDirection=this._dataGrid.isSortOrderAscending()?1:-1;function numberCompare(field,resource1,resource2)
20 {return sortDirection*(resource1[field]-resource2[field]);}
21 function localeCompare(field,resource1,resource2)
22 {return sortDirection*(resource1[field]+"").localeCompare(resource2[field]+"")}
23 var comparator;switch(parseInt(this._dataGrid.sortColumnIdentifier(),10)){case 0:comparator=localeCompare.bind(null,"name");break;case 1:comparator=localeCompare.bind(null,"type");break;case 2:comparator=numberCompare.bind(null,"size");break;default:localeCompare.bind(null,"resource");}
24 this._resources.sort(comparator);this._dataGrid.rootNode().removeChildren();var nodeToSelect;for(var i=0;i<this._resources.length;++i){var data={};var resource=this._resources[i];data[0]=resource.url;data[1]=resource.type;data[2]=Number.bytesToString(resource.size);var node=new WebInspector.DataGridNode(data);node.resource=resource;node.selectable=true;this._dataGrid.rootNode().appendChild(node);if(resource===selectedResource){nodeToSelect=node;nodeToSelect.selected=true;}}
25 if(!nodeToSelect&&this._dataGrid.rootNode().children.length)
26 this._dataGrid.rootNode().children[0].selected=true;},_deleteButtonClicked:function(event)
27 {if(!this._dataGrid||!this._dataGrid.selectedNode)
28 return;this._deleteCallback(this._dataGrid.selectedNode);},_deleteCallback:function(node)
29 {},__proto__:WebInspector.VBox.prototype};WebInspector.CookieItemsView=function(treeElement,cookieDomain)
30 {WebInspector.VBox.call(this);this.element.classList.add("storage-view");this._deleteButton=new WebInspector.StatusBarButton(WebInspector.UIString("Delete"),"delete-storage-status-bar-item");this._deleteButton.visible=false;this._deleteButton.addEventListener("click",this._deleteButtonClicked,this);this._clearButton=new WebInspector.StatusBarButton(WebInspector.UIString("Clear"),"clear-storage-status-bar-item");this._clearButton.visible=false;this._clearButton.addEventListener("click",this._clearButtonClicked,this);this._refreshButton=new WebInspector.StatusBarButton(WebInspector.UIString("Refresh"),"refresh-storage-status-bar-item");this._refreshButton.addEventListener("click",this._refreshButtonClicked,this);this._treeElement=treeElement;this._cookieDomain=cookieDomain;this._emptyView=new WebInspector.EmptyView(WebInspector.UIString("This site has no cookies."));this._emptyView.show(this.element);this.element.addEventListener("contextmenu",this._contextMenu.bind(this),true);}
31 WebInspector.CookieItemsView.prototype={get statusBarItems()
32 {return[this._refreshButton.element,this._clearButton.element,this._deleteButton.element];},wasShown:function()
33 {this._update();},willHide:function()
34 {this._deleteButton.visible=false;},_update:function()
35 {WebInspector.Cookies.getCookiesAsync(this._updateWithCookies.bind(this));},_updateWithCookies:function(allCookies)
36 {this._cookies=this._filterCookiesForDomain(allCookies);if(!this._cookies.length){this._emptyView.show(this.element);this._clearButton.visible=false;this._deleteButton.visible=false;if(this._cookiesTable)
37 this._cookiesTable.detach();return;}
38 if(!this._cookiesTable)
39 this._cookiesTable=new WebInspector.CookiesTable(false,this._update.bind(this),this._showDeleteButton.bind(this));this._cookiesTable.setCookies(this._cookies);this._emptyView.detach();this._cookiesTable.show(this.element);this._treeElement.subtitle=String.sprintf(WebInspector.UIString("%d cookies (%s)"),this._cookies.length,Number.bytesToString(this._totalSize));this._clearButton.visible=true;this._deleteButton.visible=!!this._cookiesTable.selectedCookie();},_filterCookiesForDomain:function(allCookies)
40 {var cookies=[];var resourceURLsForDocumentURL=[];this._totalSize=0;function populateResourcesForDocuments(resource)
41 {var url=resource.documentURL.asParsedURL();if(url&&url.host==this._cookieDomain)
42 resourceURLsForDocumentURL.push(resource.url);}
43 WebInspector.forAllResources(populateResourcesForDocuments.bind(this));for(var i=0;i<allCookies.length;++i){var pushed=false;var size=allCookies[i].size();for(var j=0;j<resourceURLsForDocumentURL.length;++j){var resourceURL=resourceURLsForDocumentURL[j];if(WebInspector.Cookies.cookieMatchesResourceURL(allCookies[i],resourceURL)){this._totalSize+=size;if(!pushed){pushed=true;cookies.push(allCookies[i]);}}}}
44 return cookies;},clear:function()
45 {this._cookiesTable.clear();this._update();},_clearButtonClicked:function()
46 {this.clear();},_showDeleteButton:function()
47 {this._deleteButton.visible=true;},_deleteButtonClicked:function()
48 {var selectedCookie=this._cookiesTable.selectedCookie();if(selectedCookie){selectedCookie.remove();this._update();}},_refreshButtonClicked:function(event)
49 {this._update();},_contextMenu:function(event)
50 {if(!this._cookies.length){var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendItem(WebInspector.UIString("Refresh"),this._update.bind(this));contextMenu.show();}},__proto__:WebInspector.VBox.prototype};WebInspector.DOMStorageItemsView=function(domStorage)
51 {WebInspector.VBox.call(this);this.domStorage=domStorage;this.element.classList.add("storage-view");this.element.classList.add("table");this.deleteButton=new WebInspector.StatusBarButton(WebInspector.UIString("Delete"),"delete-storage-status-bar-item");this.deleteButton.visible=false;this.deleteButton.addEventListener("click",this._deleteButtonClicked,this);this.refreshButton=new WebInspector.StatusBarButton(WebInspector.UIString("Refresh"),"refresh-storage-status-bar-item");this.refreshButton.addEventListener("click",this._refreshButtonClicked,this);this.domStorage.addEventListener(WebInspector.DOMStorage.Events.DOMStorageItemsCleared,this._domStorageItemsCleared,this);this.domStorage.addEventListener(WebInspector.DOMStorage.Events.DOMStorageItemRemoved,this._domStorageItemRemoved,this);this.domStorage.addEventListener(WebInspector.DOMStorage.Events.DOMStorageItemAdded,this._domStorageItemAdded,this);this.domStorage.addEventListener(WebInspector.DOMStorage.Events.DOMStorageItemUpdated,this._domStorageItemUpdated,this);}
52 WebInspector.DOMStorageItemsView.prototype={get statusBarItems()
53 {return[this.refreshButton.element,this.deleteButton.element];},wasShown:function()
54 {this._update();},willHide:function()
55 {this.deleteButton.visible=false;},_domStorageItemsCleared:function(event)
56 {if(!this.isShowing()||!this._dataGrid)
57 return;this._dataGrid.rootNode().removeChildren();this._dataGrid.addCreationNode(false);this.deleteButton.visible=false;event.consume(true);},_domStorageItemRemoved:function(event)
58 {if(!this.isShowing()||!this._dataGrid)
59 return;var storageData=event.data;var rootNode=this._dataGrid.rootNode();var children=rootNode.children;event.consume(true);for(var i=0;i<children.length;++i){var childNode=children[i];if(childNode.data.key===storageData.key){rootNode.removeChild(childNode);this.deleteButton.visible=(children.length>1);return;}}},_domStorageItemAdded:function(event)
60 {if(!this.isShowing()||!this._dataGrid)
61 return;var storageData=event.data;var rootNode=this._dataGrid.rootNode();var children=rootNode.children;event.consume(true);this.deleteButton.visible=true;for(var i=0;i<children.length;++i)
62 if(children[i].data.key===storageData.key)
63 return;var childNode=new WebInspector.DataGridNode({key:storageData.key,value:storageData.value},false);rootNode.insertChild(childNode,children.length-1);},_domStorageItemUpdated:function(event)
64 {if(!this.isShowing()||!this._dataGrid)
65 return;var storageData=event.data;var rootNode=this._dataGrid.rootNode();var children=rootNode.children;event.consume(true);var keyFound=false;for(var i=0;i<children.length;++i){var childNode=children[i];if(childNode.data.key===storageData.key){if(keyFound){rootNode.removeChild(childNode);return;}
66 keyFound=true;if(childNode.data.value!==storageData.value){childNode.data.value=storageData.value;childNode.refresh();childNode.select();childNode.reveal();}
67 this.deleteButton.visible=true;}}},_update:function()
68 {this.detachChildViews();this.domStorage.getItems(this._showDOMStorageItems.bind(this));},_showDOMStorageItems:function(error,items)
69 {if(error)
70 return;this._dataGrid=this._dataGridForDOMStorageItems(items);this._dataGrid.show(this.element);this.deleteButton.visible=(this._dataGrid.rootNode().children.length>1);},_dataGridForDOMStorageItems:function(items)
71 {var columns=[{id:"key",title:WebInspector.UIString("Key"),editable:true,weight:50},{id:"value",title:WebInspector.UIString("Value"),editable:true,weight:50}];var nodes=[];var keys=[];var length=items.length;for(var i=0;i<items.length;i++){var key=items[i][0];var value=items[i][1];var node=new WebInspector.DataGridNode({key:key,value:value},false);node.selectable=true;nodes.push(node);keys.push(key);}
72 var dataGrid=new WebInspector.DataGrid(columns,this._editingCallback.bind(this),this._deleteCallback.bind(this));dataGrid.setName("DOMStorageItemsView");length=nodes.length;for(var i=0;i<length;++i)
73 dataGrid.rootNode().appendChild(nodes[i]);dataGrid.addCreationNode(false);if(length>0)
74 nodes[0].selected=true;return dataGrid;},_deleteButtonClicked:function(event)
75 {if(!this._dataGrid||!this._dataGrid.selectedNode)
76 return;this._deleteCallback(this._dataGrid.selectedNode);this._dataGrid.changeNodeAfterDeletion();},_refreshButtonClicked:function(event)
77 {this._update();},_editingCallback:function(editingNode,columnIdentifier,oldText,newText)
78 {var domStorage=this.domStorage;if("key"===columnIdentifier){if(typeof oldText==="string")
79 domStorage.removeItem(oldText);domStorage.setItem(newText,editingNode.data.value||'');this._removeDupes(editingNode);}else
80 domStorage.setItem(editingNode.data.key||'',newText);},_removeDupes:function(masterNode)
81 {var rootNode=this._dataGrid.rootNode();var children=rootNode.children;for(var i=children.length-1;i>=0;--i){var childNode=children[i];if((childNode.data.key===masterNode.data.key)&&(masterNode!==childNode))
82 rootNode.removeChild(childNode);}},_deleteCallback:function(node)
83 {if(!node||node.isCreationNode)
84 return;if(this.domStorage)
85 this.domStorage.removeItem(node.data.key);},__proto__:WebInspector.VBox.prototype};WebInspector.DatabaseQueryView=function(database)
86 {WebInspector.VBox.call(this);this.database=database;this.element.classList.add("storage-view");this.element.classList.add("query");this.element.classList.add("monospace");this.element.addEventListener("selectstart",this._selectStart.bind(this),false);this._promptElement=document.createElement("div");this._promptElement.className="database-query-prompt";this._promptElement.appendChild(document.createElement("br"));this._promptElement.addEventListener("keydown",this._promptKeyDown.bind(this),true);this.element.appendChild(this._promptElement);this._prompt=new WebInspector.TextPromptWithHistory(this.completions.bind(this)," ");this._prompt.attach(this._promptElement);this.element.addEventListener("click",this._messagesClicked.bind(this),true);}
87 WebInspector.DatabaseQueryView.Events={SchemaUpdated:"SchemaUpdated"}
88 WebInspector.DatabaseQueryView.prototype={_messagesClicked:function()
89 {if(!this._prompt.isCaretInsidePrompt()&&window.getSelection().isCollapsed)
90 this._prompt.moveCaretToEndOfPrompt();},completions:function(proxyElement,wordRange,force,completionsReadyCallback)
91 {var prefix=wordRange.toString().toLowerCase();if(!prefix)
92 return;var results=[];function accumulateMatches(textArray)
93 {for(var i=0;i<textArray.length;++i){var text=textArray[i].toLowerCase();if(text.length<prefix.length)
94 continue;if(!text.startsWith(prefix))
95 continue;results.push(textArray[i]);}}
96 function tableNamesCallback(tableNames)
97 {accumulateMatches(tableNames.map(function(name){return name+" "}));accumulateMatches(["SELECT ","FROM ","WHERE ","LIMIT ","DELETE FROM ","CREATE ","DROP ","TABLE ","INDEX ","UPDATE ","INSERT INTO ","VALUES ("]);completionsReadyCallback(results);}
98 this.database.getTableNames(tableNamesCallback);},_selectStart:function(event)
99 {if(this._selectionTimeout)
100 clearTimeout(this._selectionTimeout);this._prompt.clearAutoComplete();function moveBackIfOutside()
101 {delete this._selectionTimeout;if(!this._prompt.isCaretInsidePrompt()&&window.getSelection().isCollapsed)
102 this._prompt.moveCaretToEndOfPrompt();this._prompt.autoCompleteSoon();}
103 this._selectionTimeout=setTimeout(moveBackIfOutside.bind(this),100);},_promptKeyDown:function(event)
104 {if(isEnterKey(event)){this._enterKeyPressed(event);return;}},_enterKeyPressed:function(event)
105 {event.consume(true);this._prompt.clearAutoComplete(true);var query=this._prompt.text;if(!query.length)
106 return;this._prompt.pushHistoryItem(query);this._prompt.text="";this.database.executeSql(query,this._queryFinished.bind(this,query),this._queryError.bind(this,query));},_queryFinished:function(query,columnNames,values)
107 {var dataGrid=WebInspector.DataGrid.createSortableDataGrid(columnNames,values);var trimmedQuery=query.trim();if(dataGrid){dataGrid.renderInline();this._appendViewQueryResult(trimmedQuery,dataGrid);dataGrid.autoSizeColumns(5);}
108 if(trimmedQuery.match(/^create /i)||trimmedQuery.match(/^drop table /i))
109 this.dispatchEventToListeners(WebInspector.DatabaseQueryView.Events.SchemaUpdated,this.database);},_queryError:function(query,errorMessage)
110 {this._appendErrorQueryResult(query,errorMessage);},_appendViewQueryResult:function(query,view)
111 {var resultElement=this._appendQueryResult(query);view.show(resultElement);this._promptElement.scrollIntoView(false);},_appendErrorQueryResult:function(query,errorText)
112 {var resultElement=this._appendQueryResult(query);resultElement.classList.add("error")
113 resultElement.textContent=errorText;this._promptElement.scrollIntoView(false);},_appendQueryResult:function(query)
114 {var element=document.createElement("div");element.className="database-user-query";this.element.insertBefore(element,this._prompt.proxyElement);var commandTextElement=document.createElement("span");commandTextElement.className="database-query-text";commandTextElement.textContent=query;element.appendChild(commandTextElement);var resultElement=document.createElement("div");resultElement.className="database-query-result";element.appendChild(resultElement);return resultElement;},__proto__:WebInspector.VBox.prototype};WebInspector.DatabaseTableView=function(database,tableName)
115 {WebInspector.VBox.call(this);this.database=database;this.tableName=tableName;this.element.classList.add("storage-view");this.element.classList.add("table");this.refreshButton=new WebInspector.StatusBarButton(WebInspector.UIString("Refresh"),"refresh-storage-status-bar-item");this.refreshButton.addEventListener("click",this._refreshButtonClicked,this);}
116 WebInspector.DatabaseTableView.prototype={wasShown:function()
117 {this.update();},get statusBarItems()
118 {return[this.refreshButton.element];},_escapeTableName:function(tableName)
119 {return tableName.replace(/\"/g,"\"\"");},update:function()
120 {this.database.executeSql("SELECT * FROM \""+this._escapeTableName(this.tableName)+"\"",this._queryFinished.bind(this),this._queryError.bind(this));},_queryFinished:function(columnNames,values)
121 {this.detachChildViews();this.element.removeChildren();var dataGrid=WebInspector.DataGrid.createSortableDataGrid(columnNames,values);if(!dataGrid){this._emptyView=new WebInspector.EmptyView(WebInspector.UIString("The “%s”\ntable is empty.",this.tableName));this._emptyView.show(this.element);return;}
122 dataGrid.show(this.element);dataGrid.autoSizeColumns(5);},_queryError:function(error)
123 {this.detachChildViews();this.element.removeChildren();var errorMsgElement=document.createElement("div");errorMsgElement.className="storage-table-error";errorMsgElement.textContent=WebInspector.UIString("An error occurred trying to\nread the “%s” table.",this.tableName);this.element.appendChild(errorMsgElement);},_refreshButtonClicked:function(event)
124 {this.update();},__proto__:WebInspector.VBox.prototype};WebInspector.DirectoryContentView=function()
125 {const indexes=WebInspector.DirectoryContentView.columnIndexes;var columns=[{id:indexes.Name,title:WebInspector.UIString("Name"),sortable:true,sort:WebInspector.DataGrid.Order.Ascending,width:"20%"},{id:indexes.URL,title:WebInspector.UIString("URL"),sortable:true,width:"20%"},{id:indexes.Type,title:WebInspector.UIString("Type"),sortable:true,width:"15%"},{id:indexes.Size,title:WebInspector.UIString("Size"),sortable:true,width:"10%"},{id:indexes.ModificationTime,title:WebInspector.UIString("Modification Time"),sortable:true,width:"25%"}];WebInspector.DataGrid.call(this,columns);this.addEventListener(WebInspector.DataGrid.Events.SortingChanged,this._sort,this);}
126 WebInspector.DirectoryContentView.columnIndexes={Name:"0",URL:"1",Type:"2",Size:"3",ModificationTime:"4"}
127 WebInspector.DirectoryContentView.prototype={showEntries:function(entries)
128 {const indexes=WebInspector.DirectoryContentView.columnIndexes;this.rootNode().removeChildren();for(var i=0;i<entries.length;++i)
129 this.rootNode().appendChild(new WebInspector.DirectoryContentView.Node(entries[i]));},_sort:function()
130 {var column=(this.sortColumnIdentifier());this.sortNodes(WebInspector.DirectoryContentView.Node.comparator(column,!this.isSortOrderAscending()),false);},__proto__:WebInspector.DataGrid.prototype}
131 WebInspector.DirectoryContentView.Node=function(entry)
132 {const indexes=WebInspector.DirectoryContentView.columnIndexes;var data={};data[indexes.Name]=entry.name;data[indexes.URL]=entry.url;data[indexes.Type]=entry.isDirectory?WebInspector.UIString("Directory"):entry.mimeType;data[indexes.Size]="";data[indexes.ModificationTime]="";WebInspector.DataGridNode.call(this,data);this._entry=entry;this._metadata=null;this._entry.requestMetadata(this._metadataReceived.bind(this));}
133 WebInspector.DirectoryContentView.Node.comparator=function(column,reverse)
134 {var reverseFactor=reverse?-1:1;const indexes=WebInspector.DirectoryContentView.columnIndexes;switch(column){case indexes.Name:case indexes.URL:return function(x,y)
135 {return isDirectoryCompare(x,y)||nameCompare(x,y);};case indexes.Type:return function(x,y)
136 {return isDirectoryCompare(x,y)||typeCompare(x,y)||nameCompare(x,y);};case indexes.Size:return function(x,y)
137 {return isDirectoryCompare(x,y)||sizeCompare(x,y)||nameCompare(x,y);};case indexes.ModificationTime:return function(x,y)
138 {return isDirectoryCompare(x,y)||modificationTimeCompare(x,y)||nameCompare(x,y);};}
139 function isDirectoryCompare(x,y)
140 {if(x._entry.isDirectory!=y._entry.isDirectory)
141 return y._entry.isDirectory?1:-1;return 0;}
142 function nameCompare(x,y)
143 {return reverseFactor*x._entry.name.compareTo(y._entry.name);}
144 function typeCompare(x,y)
145 {return reverseFactor*(x._entry.mimeType||"").compareTo(y._entry.mimeType||"");}
146 function sizeCompare(x,y)
147 {return reverseFactor*((x._metadata?x._metadata.size:0)-(y._metadata?y._metadata.size:0));}
148 function modificationTimeCompare(x,y)
149 {return reverseFactor*((x._metadata?x._metadata.modificationTime:0)-(y._metadata?y._metadata.modificationTime:0));}}
150 WebInspector.DirectoryContentView.Node.prototype={_metadataReceived:function(errorCode,metadata)
151 {const indexes=WebInspector.DirectoryContentView.columnIndexes;if(errorCode!==0)
152 return;this._metadata=metadata;var data=this.data;if(this._entry.isDirectory)
153 data[indexes.Size]=WebInspector.UIString("-");else
154 data[indexes.Size]=Number.bytesToString(metadata.size);data[indexes.ModificationTime]=new Date(metadata.modificationTime).toISOString();this.data=data;},__proto__:WebInspector.DataGridNode.prototype};WebInspector.IDBDatabaseView=function(database)
155 {WebInspector.VBox.call(this);this.registerRequiredCSS("indexedDBViews.css");this.element.classList.add("indexed-db-database-view");this._headersListElement=this.element.createChild("ol","outline-disclosure");this._headersTreeOutline=new TreeOutline(this._headersListElement);this._headersTreeOutline.expandTreeElementsWhenArrowing=true;this._securityOriginTreeElement=new TreeElement("",null,false);this._securityOriginTreeElement.selectable=false;this._headersTreeOutline.appendChild(this._securityOriginTreeElement);this._nameTreeElement=new TreeElement("",null,false);this._nameTreeElement.selectable=false;this._headersTreeOutline.appendChild(this._nameTreeElement);this._intVersionTreeElement=new TreeElement("",null,false);this._intVersionTreeElement.selectable=false;this._headersTreeOutline.appendChild(this._intVersionTreeElement);this._stringVersionTreeElement=new TreeElement("",null,false);this._stringVersionTreeElement.selectable=false;this._headersTreeOutline.appendChild(this._stringVersionTreeElement);this.update(database);}
156 WebInspector.IDBDatabaseView.prototype={_formatHeader:function(name,value)
157 {var fragment=document.createDocumentFragment();fragment.createChild("div","attribute-name").textContent=name+":";fragment.createChild("div","attribute-value source-code").textContent=value;return fragment;},_refreshDatabase:function()
158 {this._securityOriginTreeElement.title=this._formatHeader(WebInspector.UIString("Security origin"),this._database.databaseId.securityOrigin);this._nameTreeElement.title=this._formatHeader(WebInspector.UIString("Name"),this._database.databaseId.name);this._stringVersionTreeElement.title=this._formatHeader(WebInspector.UIString("String Version"),this._database.version);this._intVersionTreeElement.title=this._formatHeader(WebInspector.UIString("Integer Version"),this._database.intVersion);},update:function(database)
159 {this._database=database;this._refreshDatabase();},__proto__:WebInspector.VBox.prototype}
160 WebInspector.IDBDataView=function(model,databaseId,objectStore,index)
161 {WebInspector.VBox.call(this);this.registerRequiredCSS("indexedDBViews.css");this._model=model;this._databaseId=databaseId;this._isIndex=!!index;this.element.classList.add("indexed-db-data-view");var editorToolbar=this._createEditorToolbar();this.element.appendChild(editorToolbar);this._dataGridContainer=this.element.createChild("div","fill");this._dataGridContainer.classList.add("data-grid-container");this._refreshButton=new WebInspector.StatusBarButton(WebInspector.UIString("Refresh"),"refresh-storage-status-bar-item");this._refreshButton.addEventListener("click",this._refreshButtonClicked,this);this._clearButton=new WebInspector.StatusBarButton(WebInspector.UIString("Clear object store"),"clear-storage-status-bar-item");this._clearButton.addEventListener("click",this._clearButtonClicked,this);this._pageSize=50;this._skipCount=0;this.update(objectStore,index);this._entries=[];}
162 WebInspector.IDBDataView.prototype={_createDataGrid:function()
163 {var keyPath=this._isIndex?this._index.keyPath:this._objectStore.keyPath;var columns=[];columns.push({id:"number",title:WebInspector.UIString("#"),width:"50px"});columns.push({id:"key",titleDOMFragment:this._keyColumnHeaderFragment(WebInspector.UIString("Key"),keyPath)});if(this._isIndex)
164 columns.push({id:"primaryKey",titleDOMFragment:this._keyColumnHeaderFragment(WebInspector.UIString("Primary key"),this._objectStore.keyPath)});columns.push({id:"value",title:WebInspector.UIString("Value")});var dataGrid=new WebInspector.DataGrid(columns);return dataGrid;},_keyColumnHeaderFragment:function(prefix,keyPath)
165 {var keyColumnHeaderFragment=document.createDocumentFragment();keyColumnHeaderFragment.appendChild(document.createTextNode(prefix));if(keyPath===null)
166 return keyColumnHeaderFragment;keyColumnHeaderFragment.appendChild(document.createTextNode(" ("+WebInspector.UIString("Key path: ")));if(keyPath instanceof Array){keyColumnHeaderFragment.appendChild(document.createTextNode("["));for(var i=0;i<keyPath.length;++i){if(i!=0)
167 keyColumnHeaderFragment.appendChild(document.createTextNode(", "));keyColumnHeaderFragment.appendChild(this._keyPathStringFragment(keyPath[i]));}
168 keyColumnHeaderFragment.appendChild(document.createTextNode("]"));}else{var keyPathString=(keyPath);keyColumnHeaderFragment.appendChild(this._keyPathStringFragment(keyPathString));}
169 keyColumnHeaderFragment.appendChild(document.createTextNode(")"));return keyColumnHeaderFragment;},_keyPathStringFragment:function(keyPathString)
170 {var keyPathStringFragment=document.createDocumentFragment();keyPathStringFragment.appendChild(document.createTextNode("\""));var keyPathSpan=keyPathStringFragment.createChild("span","source-code console-formatted-string");keyPathSpan.textContent=keyPathString;keyPathStringFragment.appendChild(document.createTextNode("\""));return keyPathStringFragment;},_createEditorToolbar:function()
171 {var editorToolbar=document.createElement("div");editorToolbar.classList.add("status-bar");editorToolbar.classList.add("data-view-toolbar");this._pageBackButton=editorToolbar.createChild("button","back-button");this._pageBackButton.classList.add("status-bar-item");this._pageBackButton.title=WebInspector.UIString("Show previous page.");this._pageBackButton.disabled=true;this._pageBackButton.appendChild(document.createElement("img"));this._pageBackButton.addEventListener("click",this._pageBackButtonClicked.bind(this),false);editorToolbar.appendChild(this._pageBackButton);this._pageForwardButton=editorToolbar.createChild("button","forward-button");this._pageForwardButton.classList.add("status-bar-item");this._pageForwardButton.title=WebInspector.UIString("Show next page.");this._pageForwardButton.disabled=true;this._pageForwardButton.appendChild(document.createElement("img"));this._pageForwardButton.addEventListener("click",this._pageForwardButtonClicked.bind(this),false);editorToolbar.appendChild(this._pageForwardButton);this._keyInputElement=editorToolbar.createChild("input","key-input");this._keyInputElement.placeholder=WebInspector.UIString("Start from key");this._keyInputElement.addEventListener("paste",this._keyInputChanged.bind(this),false);this._keyInputElement.addEventListener("cut",this._keyInputChanged.bind(this),false);this._keyInputElement.addEventListener("keypress",this._keyInputChanged.bind(this),false);this._keyInputElement.addEventListener("keydown",this._keyInputChanged.bind(this),false);return editorToolbar;},_pageBackButtonClicked:function()
172 {this._skipCount=Math.max(0,this._skipCount-this._pageSize);this._updateData(false);},_pageForwardButtonClicked:function()
173 {this._skipCount=this._skipCount+this._pageSize;this._updateData(false);},_keyInputChanged:function()
174 {window.setTimeout(this._updateData.bind(this,false),0);},update:function(objectStore,index)
175 {this._objectStore=objectStore;this._index=index;if(this._dataGrid)
176 this._dataGrid.detach();this._dataGrid=this._createDataGrid();this._dataGrid.show(this._dataGridContainer);this._skipCount=0;this._updateData(true);},_parseKey:function(keyString)
177 {var result;try{result=JSON.parse(keyString);}catch(e){result=keyString;}
178 return result;},_updateData:function(force)
179 {var key=this._parseKey(this._keyInputElement.value);var pageSize=this._pageSize;var skipCount=this._skipCount;this._refreshButton.setEnabled(false);this._clearButton.setEnabled(!this._isIndex);if(!force&&this._lastKey===key&&this._lastPageSize===pageSize&&this._lastSkipCount===skipCount)
180 return;if(this._lastKey!==key||this._lastPageSize!==pageSize){skipCount=0;this._skipCount=0;}
181 this._lastKey=key;this._lastPageSize=pageSize;this._lastSkipCount=skipCount;function callback(entries,hasMore)
182 {this._refreshButton.setEnabled(true);this.clear();this._entries=entries;for(var i=0;i<entries.length;++i){var data={};data["number"]=i+skipCount;data["key"]=entries[i].key;data["primaryKey"]=entries[i].primaryKey;data["value"]=entries[i].value;var primaryKey=JSON.stringify(this._isIndex?entries[i].primaryKey:entries[i].key);var node=new WebInspector.IDBDataGridNode(data);this._dataGrid.rootNode().appendChild(node);}
183 this._pageBackButton.disabled=skipCount===0;this._pageForwardButton.disabled=!hasMore;}
184 var idbKeyRange=key?window.webkitIDBKeyRange.lowerBound(key):null;if(this._isIndex)
185 this._model.loadIndexData(this._databaseId,this._objectStore.name,this._index.name,idbKeyRange,skipCount,pageSize,callback.bind(this));else
186 this._model.loadObjectStoreData(this._databaseId,this._objectStore.name,idbKeyRange,skipCount,pageSize,callback.bind(this));},_refreshButtonClicked:function(event)
187 {this._updateData(true);},_clearButtonClicked:function(event)
188 {function cleared(){this._clearButton.setEnabled(true);this._updateData(true);}
189 this._clearButton.setEnabled(false);this._model.clearObjectStore(this._databaseId,this._objectStore.name,cleared.bind(this));},get statusBarItems()
190 {return[this._refreshButton.element,this._clearButton.element];},clear:function()
191 {this._dataGrid.rootNode().removeChildren();this._entries=[];},__proto__:WebInspector.VBox.prototype}
192 WebInspector.IDBDataGridNode=function(data)
193 {WebInspector.DataGridNode.call(this,data,false);this.selectable=false;}
194 WebInspector.IDBDataGridNode.prototype={createCell:function(columnIdentifier)
195 {var cell=WebInspector.DataGridNode.prototype.createCell.call(this,columnIdentifier);var value=this.data[columnIdentifier];switch(columnIdentifier){case"value":case"key":case"primaryKey":cell.removeChildren();this._formatValue(cell,value);break;default:}
196 return cell;},_formatValue:function(cell,value)
197 {var type=value.subtype||value.type;var contents=cell.createChild("div","source-code console-formatted-"+type);switch(type){case"object":case"array":var section=new WebInspector.ObjectPropertiesSection(value,value.description)
198 section.editable=false;section.skipProto=true;contents.appendChild(section.element);break;case"string":contents.classList.add("primitive-value");contents.appendChild(document.createTextNode("\""+value.description+"\""));break;default:contents.classList.add("primitive-value");contents.appendChild(document.createTextNode(value.description));}},__proto__:WebInspector.DataGridNode.prototype};WebInspector.FileContentView=function(file)
199 {WebInspector.VBox.call(this);this._innerView=(null);this._file=file;this._content=null;}
200 WebInspector.FileContentView.prototype={wasShown:function()
201 {if(!this._innerView){if(this._file.isTextFile)
202 this._innerView=new WebInspector.EmptyView("");else
203 this._innerView=new WebInspector.EmptyView(WebInspector.UIString("Binary File"));this.refresh();}
204 this._innerView.show(this.element);},_metadataReceived:function(errorCode,metadata)
205 {if(errorCode||!metadata)
206 return;if(this._content){if(!this._content.updateMetadata(metadata))
207 return;var sourceFrame=(this._innerView);this._content.requestContent(sourceFrame.setContent.bind(sourceFrame));}else{this._innerView.detach();this._content=new WebInspector.FileContentView.FileContentProvider(this._file,metadata);var sourceFrame=new WebInspector.SourceFrame(this._content);sourceFrame.setHighlighterType(this._file.resourceType.canonicalMimeType());this._innerView=sourceFrame;this._innerView.show(this.element);}},refresh:function()
208 {if(!this._innerView)
209 return;if(this._file.isTextFile)
210 this._file.requestMetadata(this._metadataReceived.bind(this));},__proto__:WebInspector.VBox.prototype}
211 WebInspector.FileContentView.FileContentProvider=function(file,metadata)
212 {this._file=file;this._metadata=metadata;}
213 WebInspector.FileContentView.FileContentProvider.prototype={contentURL:function()
214 {return this._file.url;},contentType:function()
215 {return this._file.resourceType;},requestContent:function(callback)
216 {var size=(this._metadata.size);this._file.requestFileContent(true,0,size,this._charset||"",this._fileContentReceived.bind(this,callback));},_fileContentReceived:function(callback,errorCode,content,base64Encoded,charset)
217 {if(errorCode||!content){callback(null);return;}
218 this._charset=charset;callback(content);},searchInContent:function(query,caseSensitive,isRegex,callback)
219 {setTimeout(callback.bind(null,[]),0);},updateMetadata:function(metadata)
220 {if(this._metadata.modificationTime>=metadata.modificationTime)
221 return false;this._metadata=metadata.modificationTime;return true;}};WebInspector.FileSystemView=function(fileSystem)
222 {WebInspector.SplitView.call(this,true,false,"fileSystemViewSplitViewState");this.element.classList.add("file-system-view");this.element.classList.add("storage-view");var directoryTreeElement=this.element.createChild("ol","filesystem-directory-tree");this._directoryTree=new TreeOutline(directoryTreeElement);this.sidebarElement().appendChild(directoryTreeElement);this.sidebarElement().classList.add("outline-disclosure","sidebar");var rootItem=new WebInspector.FileSystemView.EntryTreeElement(this,fileSystem.root);rootItem.expanded=true;this._directoryTree.appendChild(rootItem);this._visibleView=null;this._refreshButton=new WebInspector.StatusBarButton(WebInspector.UIString("Refresh"),"refresh-storage-status-bar-item");this._refreshButton.visible=true;this._refreshButton.addEventListener("click",this._refresh,this);this._deleteButton=new WebInspector.StatusBarButton(WebInspector.UIString("Delete"),"delete-storage-status-bar-item");this._deleteButton.visible=true;this._deleteButton.addEventListener("click",this._confirmDelete,this);}
223 WebInspector.FileSystemView.prototype={get statusBarItems()
224 {return[this._refreshButton.element,this._deleteButton.element];},get visibleView()
225 {return this._visibleView;},showView:function(view)
226 {if(this._visibleView===view)
227 return;if(this._visibleView)
228 this._visibleView.detach();this._visibleView=view;view.show(this.mainElement());},_refresh:function()
229 {this._directoryTree.children[0].refresh();},_confirmDelete:function()
230 {if(confirm(WebInspector.UIString("Are you sure you want to delete the selected entry?")))
231 this._delete();},_delete:function()
232 {this._directoryTree.selectedTreeElement.deleteEntry();},__proto__:WebInspector.SplitView.prototype}
233 WebInspector.FileSystemView.EntryTreeElement=function(fileSystemView,entry)
234 {TreeElement.call(this,entry.name,null,entry.isDirectory);this._entry=entry;this._fileSystemView=fileSystemView;}
235 WebInspector.FileSystemView.EntryTreeElement.prototype={onattach:function()
236 {var selection=this.listItemElement.createChild("div","selection");this.listItemElement.insertBefore(selection,this.listItemElement.firstChild);},onselect:function()
237 {if(!this._view){if(this._entry.isDirectory)
238 this._view=new WebInspector.DirectoryContentView();else{var file=(this._entry);this._view=new WebInspector.FileContentView(file);}}
239 this._fileSystemView.showView(this._view);this.refresh();return false;},onpopulate:function()
240 {this.refresh();},_directoryContentReceived:function(errorCode,entries)
241 {if(errorCode===FileError.NOT_FOUND_ERR){if(this.parent!==this.treeOutline)
242 this.parent.refresh();return;}
243 if(errorCode!==0||!entries){console.error("Failed to read directory: "+errorCode);return;}
244 entries.sort(WebInspector.FileSystemModel.Entry.compare);if(this._view)
245 this._view.showEntries(entries);var oldChildren=this.children.slice(0);var newEntryIndex=0;var oldChildIndex=0;var currentTreeItem=0;while(newEntryIndex<entries.length&&oldChildIndex<oldChildren.length){var newEntry=entries[newEntryIndex];var oldChild=oldChildren[oldChildIndex];var order=newEntry.name.compareTo(oldChild._entry.name);if(order===0){if(oldChild._entry.isDirectory)
246 oldChild.shouldRefreshChildren=true;else
247 oldChild.refresh();++newEntryIndex;++oldChildIndex;++currentTreeItem;continue;}
248 if(order<0){this.insertChild(new WebInspector.FileSystemView.EntryTreeElement(this._fileSystemView,newEntry),currentTreeItem);++newEntryIndex;++currentTreeItem;continue;}
249 this.removeChildAtIndex(currentTreeItem);++oldChildIndex;}
250 for(;newEntryIndex<entries.length;++newEntryIndex)
251 this.appendChild(new WebInspector.FileSystemView.EntryTreeElement(this._fileSystemView,entries[newEntryIndex]));for(;oldChildIndex<oldChildren.length;++oldChildIndex)
252 this.removeChild(oldChildren[oldChildIndex]);},refresh:function()
253 {if(!this._entry.isDirectory){if(this._view&&this._view===this._fileSystemView.visibleView){var fileContentView=(this._view);fileContentView.refresh();}}else
254 this._entry.requestDirectoryContent(this._directoryContentReceived.bind(this));},deleteEntry:function()
255 {this._entry.deleteEntry(this._deletionCompleted.bind(this));},_deletionCompleted:function()
256 {if(this._entry!=this._entry.fileSystem.root)
257 this.parent.refresh();},__proto__:TreeElement.prototype};WebInspector.ResourcesPanel=function(database)
258 {WebInspector.PanelWithSidebarTree.call(this,"resources");this.registerRequiredCSS("resourcesPanel.css");WebInspector.settings.resourcesLastSelectedItem=WebInspector.settings.createSetting("resourcesLastSelectedItem",{});this.sidebarElement().classList.add("filter-all","children","small","outline-disclosure");this.sidebarTree.element.classList.remove("sidebar-tree");this.resourcesListTreeElement=new WebInspector.StorageCategoryTreeElement(this,WebInspector.UIString("Frames"),"Frames",["frame-storage-tree-item"]);this.sidebarTree.appendChild(this.resourcesListTreeElement);this.databasesListTreeElement=new WebInspector.StorageCategoryTreeElement(this,WebInspector.UIString("Web SQL"),"Databases",["database-storage-tree-item"]);this.sidebarTree.appendChild(this.databasesListTreeElement);this.indexedDBListTreeElement=new WebInspector.IndexedDBTreeElement(this);this.sidebarTree.appendChild(this.indexedDBListTreeElement);this.localStorageListTreeElement=new WebInspector.StorageCategoryTreeElement(this,WebInspector.UIString("Local Storage"),"LocalStorage",["domstorage-storage-tree-item","local-storage"]);this.sidebarTree.appendChild(this.localStorageListTreeElement);this.sessionStorageListTreeElement=new WebInspector.StorageCategoryTreeElement(this,WebInspector.UIString("Session Storage"),"SessionStorage",["domstorage-storage-tree-item","session-storage"]);this.sidebarTree.appendChild(this.sessionStorageListTreeElement);this.cookieListTreeElement=new WebInspector.StorageCategoryTreeElement(this,WebInspector.UIString("Cookies"),"Cookies",["cookie-storage-tree-item"]);this.sidebarTree.appendChild(this.cookieListTreeElement);this.applicationCacheListTreeElement=new WebInspector.StorageCategoryTreeElement(this,WebInspector.UIString("Application Cache"),"ApplicationCache",["application-cache-storage-tree-item"]);this.sidebarTree.appendChild(this.applicationCacheListTreeElement);if(WebInspector.experimentsSettings.fileSystemInspection.isEnabled()){this.fileSystemListTreeElement=new WebInspector.FileSystemListTreeElement(this);this.sidebarTree.appendChild(this.fileSystemListTreeElement);}
259 var mainView=new WebInspector.VBox();this.storageViews=mainView.element.createChild("div","resources-main diff-container");var statusBarContainer=mainView.element.createChild("div","resources-status-bar");this.storageViewStatusBarItemsContainer=statusBarContainer.createChild("div","status-bar");mainView.show(this.mainElement());this._databaseTableViews=new Map();this._databaseQueryViews=new Map();this._databaseTreeElements=new Map();this._domStorageViews=new Map();this._domStorageTreeElements=new Map();this._cookieViews={};this._domains={};this.sidebarElement().addEventListener("mousemove",this._onmousemove.bind(this),false);this.sidebarElement().addEventListener("mouseout",this._onmouseout.bind(this),false);function sourceFrameGetter()
260 {var view=this.visibleView;if(view&&view instanceof WebInspector.SourceFrame)
261 return(view);return null;}
262 WebInspector.GoToLineDialog.install(this,sourceFrameGetter.bind(this));if(WebInspector.resourceTreeModel.cachedResourcesLoaded())
263 this._cachedResourcesLoaded();WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.Load,this._loadEventFired,this);WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.CachedResourcesLoaded,this._cachedResourcesLoaded,this);WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.WillLoadCachedResources,this._resetWithFrames,this);WebInspector.databaseModel.databases().forEach(this._addDatabase.bind(this));WebInspector.databaseModel.addEventListener(WebInspector.DatabaseModel.Events.DatabaseAdded,this._databaseAdded,this);}
264 WebInspector.ResourcesPanel.prototype={canSearch:function()
265 {return false;},wasShown:function()
266 {WebInspector.Panel.prototype.wasShown.call(this);this._initialize();},_initialize:function()
267 {if(!this._initialized&&this.isShowing()&&this._cachedResourcesWereLoaded){var target=(WebInspector.targetManager.activeTarget());this._populateResourceTree();this._populateDOMStorageTree();this._populateApplicationCacheTree(target);this.indexedDBListTreeElement._initialize();if(WebInspector.experimentsSettings.fileSystemInspection.isEnabled())
268 this.fileSystemListTreeElement._initialize();this._initDefaultSelection();this._initialized=true;}},_loadEventFired:function()
269 {this._initDefaultSelection();},_initDefaultSelection:function()
270 {if(!this._initialized)
271 return;var itemURL=WebInspector.settings.resourcesLastSelectedItem.get();if(itemURL){for(var treeElement=this.sidebarTree.children[0];treeElement;treeElement=treeElement.traverseNextTreeElement(false,this.sidebarTree,true)){if(treeElement.itemURL===itemURL){treeElement.revealAndSelect(true);return;}}}
272 var mainResource=WebInspector.resourceTreeModel.inspectedPageURL()&&this.resourcesListTreeElement&&this.resourcesListTreeElement.expanded?WebInspector.resourceTreeModel.resourceForURL(WebInspector.resourceTreeModel.inspectedPageURL()):null;if(mainResource)
273 this.showResource(mainResource);},_resetWithFrames:function()
274 {this.resourcesListTreeElement.removeChildren();this._treeElementForFrameId={};this._reset();},_reset:function()
275 {this._domains={};var queryViews=this._databaseQueryViews.values();for(var i=0;i<queryViews.length;++i)
276 queryViews[i].removeEventListener(WebInspector.DatabaseQueryView.Events.SchemaUpdated,this._updateDatabaseTables,this);this._databaseTableViews.clear();this._databaseQueryViews.clear();this._databaseTreeElements.clear();this._domStorageViews.clear();this._domStorageTreeElements.clear();this._cookieViews={};this.databasesListTreeElement.removeChildren();this.localStorageListTreeElement.removeChildren();this.sessionStorageListTreeElement.removeChildren();this.cookieListTreeElement.removeChildren();if(this.visibleView&&!(this.visibleView instanceof WebInspector.StorageCategoryView))
277 this.visibleView.detach();this.storageViewStatusBarItemsContainer.removeChildren();if(this.sidebarTree.selectedTreeElement)
278 this.sidebarTree.selectedTreeElement.deselect();},_populateResourceTree:function()
279 {this._treeElementForFrameId={};WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameAdded,this._frameAdded,this);WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameNavigated,this._frameNavigated,this);WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameDetached,this._frameDetached,this);WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded,this._resourceAdded,this);function populateFrame(frame)
280 {this._frameAdded({data:frame});for(var i=0;i<frame.childFrames.length;++i)
281 populateFrame.call(this,frame.childFrames[i]);var resources=frame.resources();for(var i=0;i<resources.length;++i)
282 this._resourceAdded({data:resources[i]});}
283 populateFrame.call(this,WebInspector.resourceTreeModel.mainFrame);},_frameAdded:function(event)
284 {var frame=event.data;var parentFrame=frame.parentFrame;var parentTreeElement=parentFrame?this._treeElementForFrameId[parentFrame.id]:this.resourcesListTreeElement;if(!parentTreeElement){console.warn("No frame to route "+frame.url+" to.")
285 return;}
286 var frameTreeElement=new WebInspector.FrameTreeElement(this,frame);this._treeElementForFrameId[frame.id]=frameTreeElement;parentTreeElement.appendChild(frameTreeElement);},_frameDetached:function(event)
287 {var frame=event.data;var frameTreeElement=this._treeElementForFrameId[frame.id];if(!frameTreeElement)
288 return;delete this._treeElementForFrameId[frame.id];if(frameTreeElement.parent)
289 frameTreeElement.parent.removeChild(frameTreeElement);},_resourceAdded:function(event)
290 {var resource=event.data;var frameId=resource.frameId;if(resource.statusCode>=301&&resource.statusCode<=303)
291 return;var frameTreeElement=this._treeElementForFrameId[frameId];if(!frameTreeElement){return;}
292 frameTreeElement.appendResource(resource);},_frameNavigated:function(event)
293 {var frame=event.data;if(!frame.parentFrame)
294 this._reset();var frameId=frame.id;var frameTreeElement=this._treeElementForFrameId[frameId];if(frameTreeElement)
295 frameTreeElement.frameNavigated(frame);var applicationCacheFrameTreeElement=this._applicationCacheFrameElements[frameId];if(applicationCacheFrameTreeElement)
296 applicationCacheFrameTreeElement.frameNavigated(frame);},_cachedResourcesLoaded:function()
297 {this._cachedResourcesWereLoaded=true;this._initialize();},_databaseAdded:function(event)
298 {var database=(event.data);this._addDatabase(database);},_addDatabase:function(database)
299 {var databaseTreeElement=new WebInspector.DatabaseTreeElement(this,database);this._databaseTreeElements.put(database,databaseTreeElement);this.databasesListTreeElement.appendChild(databaseTreeElement);},addDocumentURL:function(url)
300 {var parsedURL=url.asParsedURL();if(!parsedURL)
301 return;var domain=parsedURL.host;if(!this._domains[domain]){this._domains[domain]=true;var cookieDomainTreeElement=new WebInspector.CookieTreeElement(this,domain);this.cookieListTreeElement.appendChild(cookieDomainTreeElement);}},_domStorageAdded:function(event)
302 {var domStorage=(event.data);this._addDOMStorage(domStorage);},_addDOMStorage:function(domStorage)
303 {console.assert(!this._domStorageTreeElements.get(domStorage));var domStorageTreeElement=new WebInspector.DOMStorageTreeElement(this,domStorage,(domStorage.isLocalStorage?"local-storage":"session-storage"));this._domStorageTreeElements.put(domStorage,domStorageTreeElement);if(domStorage.isLocalStorage)
304 this.localStorageListTreeElement.appendChild(domStorageTreeElement);else
305 this.sessionStorageListTreeElement.appendChild(domStorageTreeElement);},_domStorageRemoved:function(event)
306 {var domStorage=(event.data);this._removeDOMStorage(domStorage);},_removeDOMStorage:function(domStorage)
307 {var treeElement=this._domStorageTreeElements.get(domStorage);if(!treeElement)
308 return;var wasSelected=treeElement.selected;var parentListTreeElement=treeElement.parent;parentListTreeElement.removeChild(treeElement);if(wasSelected)
309 parentListTreeElement.select();this._domStorageTreeElements.remove(domStorage);this._domStorageViews.remove(domStorage);},selectDatabase:function(database)
310 {if(database){this._showDatabase(database);this._databaseTreeElements.get(database).select();}},selectDOMStorage:function(domStorage)
311 {if(domStorage){this._showDOMStorage(domStorage);this._domStorageTreeElements.get(domStorage).select();}},showResource:function(resource,line,column)
312 {var resourceTreeElement=this._findTreeElementForResource(resource);if(resourceTreeElement)
313 resourceTreeElement.revealAndSelect(true);if(typeof line==="number"){var resourceSourceFrame=this._resourceSourceFrameViewForResource(resource);if(resourceSourceFrame)
314 resourceSourceFrame.revealPosition(line,column,true);}
315 return true;},_showResourceView:function(resource)
316 {var view=this._resourceViewForResource(resource);if(!view){this.visibleView.detach();return;}
317 this._innerShowView(view);},_resourceViewForResource:function(resource)
318 {if(WebInspector.ResourceView.hasTextContent(resource)){var treeElement=this._findTreeElementForResource(resource);if(!treeElement)
319 return null;return treeElement.sourceView();}
320 return WebInspector.ResourceView.nonSourceViewForResource(resource);},_resourceSourceFrameViewForResource:function(resource)
321 {var resourceView=this._resourceViewForResource(resource);if(resourceView&&resourceView instanceof WebInspector.ResourceSourceFrame)
322 return(resourceView);return null;},_showDatabase:function(database,tableName)
323 {if(!database)
324 return;var view;if(tableName){var tableViews=this._databaseTableViews.get(database);if(!tableViews){tableViews=({});this._databaseTableViews.put(database,tableViews);}
325 view=tableViews[tableName];if(!view){view=new WebInspector.DatabaseTableView(database,tableName);tableViews[tableName]=view;}}else{view=this._databaseQueryViews.get(database);if(!view){view=new WebInspector.DatabaseQueryView(database);this._databaseQueryViews.put(database,view);view.addEventListener(WebInspector.DatabaseQueryView.Events.SchemaUpdated,this._updateDatabaseTables,this);}}
326 this._innerShowView(view);},showIndexedDB:function(view)
327 {this._innerShowView(view);},_showDOMStorage:function(domStorage)
328 {if(!domStorage)
329 return;var view;view=this._domStorageViews.get(domStorage);if(!view){view=new WebInspector.DOMStorageItemsView(domStorage);this._domStorageViews.put(domStorage,view);}
330 this._innerShowView(view);},showCookies:function(treeElement,cookieDomain)
331 {var view=this._cookieViews[cookieDomain];if(!view){view=new WebInspector.CookieItemsView(treeElement,cookieDomain);this._cookieViews[cookieDomain]=view;}
332 this._innerShowView(view);},clearCookies:function(cookieDomain)
333 {this._cookieViews[cookieDomain].clear();},showApplicationCache:function(frameId)
334 {if(!this._applicationCacheViews[frameId])
335 this._applicationCacheViews[frameId]=new WebInspector.ApplicationCacheItemsView(this._applicationCacheModel,frameId);this._innerShowView(this._applicationCacheViews[frameId]);},showFileSystem:function(view)
336 {this._innerShowView(view);},showCategoryView:function(categoryName)
337 {if(!this._categoryView)
338 this._categoryView=new WebInspector.StorageCategoryView();this._categoryView.setText(categoryName);this._innerShowView(this._categoryView);},_innerShowView:function(view)
339 {if(this.visibleView===view)
340 return;if(this.visibleView)
341 this.visibleView.detach();view.show(this.storageViews);this.visibleView=view;this.storageViewStatusBarItemsContainer.removeChildren();var statusBarItems=view.statusBarItems||[];for(var i=0;i<statusBarItems.length;++i)
342 this.storageViewStatusBarItemsContainer.appendChild(statusBarItems[i]);},closeVisibleView:function()
343 {if(!this.visibleView)
344 return;this.visibleView.detach();delete this.visibleView;},_updateDatabaseTables:function(event)
345 {var database=event.data;if(!database)
346 return;var databasesTreeElement=this._databaseTreeElements.get(database);if(!databasesTreeElement)
347 return;databasesTreeElement.shouldRefreshChildren=true;var tableViews=this._databaseTableViews.get(database);if(!tableViews)
348 return;var tableNamesHash={};var self=this;function tableNamesCallback(tableNames)
349 {var tableNamesLength=tableNames.length;for(var i=0;i<tableNamesLength;++i)
350 tableNamesHash[tableNames[i]]=true;for(var tableName in tableViews){if(!(tableName in tableNamesHash)){if(self.visibleView===tableViews[tableName])
351 self.closeVisibleView();delete tableViews[tableName];}}}
352 database.getTableNames(tableNamesCallback);},_populateDOMStorageTree:function()
353 {WebInspector.domStorageModel.storages().forEach(this._addDOMStorage.bind(this));WebInspector.domStorageModel.addEventListener(WebInspector.DOMStorageModel.Events.DOMStorageAdded,this._domStorageAdded,this);WebInspector.domStorageModel.addEventListener(WebInspector.DOMStorageModel.Events.DOMStorageRemoved,this._domStorageRemoved,this);},_populateApplicationCacheTree:function(target)
354 {this._applicationCacheModel=new WebInspector.ApplicationCacheModel(target);this._applicationCacheViews={};this._applicationCacheFrameElements={};this._applicationCacheManifestElements={};this._applicationCacheModel.addEventListener(WebInspector.ApplicationCacheModel.EventTypes.FrameManifestAdded,this._applicationCacheFrameManifestAdded,this);this._applicationCacheModel.addEventListener(WebInspector.ApplicationCacheModel.EventTypes.FrameManifestRemoved,this._applicationCacheFrameManifestRemoved,this);this._applicationCacheModel.addEventListener(WebInspector.ApplicationCacheModel.EventTypes.FrameManifestStatusUpdated,this._applicationCacheFrameManifestStatusChanged,this);this._applicationCacheModel.addEventListener(WebInspector.ApplicationCacheModel.EventTypes.NetworkStateChanged,this._applicationCacheNetworkStateChanged,this);},_applicationCacheFrameManifestAdded:function(event)
355 {var frameId=event.data;var manifestURL=this._applicationCacheModel.frameManifestURL(frameId);var status=this._applicationCacheModel.frameManifestStatus(frameId)
356 var manifestTreeElement=this._applicationCacheManifestElements[manifestURL]
357 if(!manifestTreeElement){manifestTreeElement=new WebInspector.ApplicationCacheManifestTreeElement(this,manifestURL);this.applicationCacheListTreeElement.appendChild(manifestTreeElement);this._applicationCacheManifestElements[manifestURL]=manifestTreeElement;}
358 var frameTreeElement=new WebInspector.ApplicationCacheFrameTreeElement(this,frameId,manifestURL);manifestTreeElement.appendChild(frameTreeElement);manifestTreeElement.expand();this._applicationCacheFrameElements[frameId]=frameTreeElement;},_applicationCacheFrameManifestRemoved:function(event)
359 {var frameId=event.data;var frameTreeElement=this._applicationCacheFrameElements[frameId];if(!frameTreeElement)
360 return;var manifestURL=frameTreeElement.manifestURL;delete this._applicationCacheFrameElements[frameId];delete this._applicationCacheViews[frameId];frameTreeElement.parent.removeChild(frameTreeElement);var manifestTreeElement=this._applicationCacheManifestElements[manifestURL];if(manifestTreeElement.children.length!==0)
361 return;delete this._applicationCacheManifestElements[manifestURL];manifestTreeElement.parent.removeChild(manifestTreeElement);},_applicationCacheFrameManifestStatusChanged:function(event)
362 {var frameId=event.data;var status=this._applicationCacheModel.frameManifestStatus(frameId)
363 if(this._applicationCacheViews[frameId])
364 this._applicationCacheViews[frameId].updateStatus(status);},_applicationCacheNetworkStateChanged:function(event)
365 {var isNowOnline=event.data;for(var manifestURL in this._applicationCacheViews)
366 this._applicationCacheViews[manifestURL].updateNetworkState(isNowOnline);},_findTreeElementForResource:function(resource)
367 {function getParent(object)
368 {return null;}
369 return this.sidebarTree.findTreeElement(resource,getParent);},showView:function(view)
370 {if(view)
371 this.showResource(view.resource);},_onmousemove:function(event)
372 {var nodeUnderMouse=document.elementFromPoint(event.pageX,event.pageY);if(!nodeUnderMouse)
373 return;var listNode=nodeUnderMouse.enclosingNodeOrSelfWithNodeName("li");if(!listNode)
374 return;var element=listNode.treeElement;if(this._previousHoveredElement===element)
375 return;if(this._previousHoveredElement){this._previousHoveredElement.hovered=false;delete this._previousHoveredElement;}
376 if(element instanceof WebInspector.FrameTreeElement){this._previousHoveredElement=element;element.hovered=true;}},_onmouseout:function(event)
377 {if(this._previousHoveredElement){this._previousHoveredElement.hovered=false;delete this._previousHoveredElement;}},__proto__:WebInspector.PanelWithSidebarTree.prototype}
378 WebInspector.ResourcesPanel.ResourceRevealer=function()
379 {}
380 WebInspector.ResourcesPanel.ResourceRevealer.prototype={reveal:function(resource,lineNumber)
381 {if(resource instanceof WebInspector.Resource)
382 (WebInspector.inspectorView.showPanel("resources")).showResource(resource,lineNumber);}}
383 WebInspector.BaseStorageTreeElement=function(storagePanel,representedObject,title,iconClasses,hasChildren,noIcon)
384 {TreeElement.call(this,"",representedObject,hasChildren);this._storagePanel=storagePanel;this._titleText=title;this._iconClasses=iconClasses;this._noIcon=noIcon;}
385 WebInspector.BaseStorageTreeElement.prototype={onattach:function()
386 {this.listItemElement.removeChildren();if(this._iconClasses){for(var i=0;i<this._iconClasses.length;++i)
387 this.listItemElement.classList.add(this._iconClasses[i]);}
388 var selectionElement=document.createElement("div");selectionElement.className="selection";this.listItemElement.appendChild(selectionElement);if(!this._noIcon){this.imageElement=document.createElement("img");this.imageElement.className="icon";this.listItemElement.appendChild(this.imageElement);}
389 this.titleElement=document.createElement("div");this.titleElement.className="base-storage-tree-element-title";this._titleTextNode=document.createTextNode("");this.titleElement.appendChild(this._titleTextNode);this._updateTitle();this._updateSubtitle();this.listItemElement.appendChild(this.titleElement);},get displayName()
390 {return this._displayName;},_updateDisplayName:function()
391 {this._displayName=this._titleText||"";if(this._subtitleText)
392 this._displayName+=" ("+this._subtitleText+")";},_updateTitle:function()
393 {this._updateDisplayName();if(!this.titleElement)
394 return;this._titleTextNode.textContent=this._titleText||"";},_updateSubtitle:function()
395 {this._updateDisplayName();if(!this.titleElement)
396 return;if(this._subtitleText){if(!this._subtitleElement){this._subtitleElement=document.createElement("span");this._subtitleElement.className="base-storage-tree-element-subtitle";this.titleElement.appendChild(this._subtitleElement);}
397 this._subtitleElement.textContent="("+this._subtitleText+")";}else if(this._subtitleElement){this.titleElement.removeChild(this._subtitleElement);delete this._subtitleElement;}},onselect:function(selectedByUser)
398 {if(!selectedByUser)
399 return false;var itemURL=this.itemURL;if(itemURL)
400 WebInspector.settings.resourcesLastSelectedItem.set(itemURL);return false;},onreveal:function()
401 {if(this.listItemElement)
402 this.listItemElement.scrollIntoViewIfNeeded(false);},get titleText()
403 {return this._titleText;},set titleText(titleText)
404 {this._titleText=titleText;this._updateTitle();},get subtitleText()
405 {return this._subtitleText;},set subtitleText(subtitleText)
406 {this._subtitleText=subtitleText;this._updateSubtitle();},__proto__:TreeElement.prototype}
407 WebInspector.StorageCategoryTreeElement=function(storagePanel,categoryName,settingsKey,iconClasses,noIcon)
408 {WebInspector.BaseStorageTreeElement.call(this,storagePanel,null,categoryName,iconClasses,false,noIcon);this._expandedSettingKey="resources"+settingsKey+"Expanded";WebInspector.settings[this._expandedSettingKey]=WebInspector.settings.createSetting(this._expandedSettingKey,settingsKey==="Frames");this._categoryName=categoryName;this._target=(WebInspector.targetManager.activeTarget());}
409 WebInspector.StorageCategoryTreeElement.prototype={target:function()
410 {return this._target;},get itemURL()
411 {return"category://"+this._categoryName;},onselect:function(selectedByUser)
412 {WebInspector.BaseStorageTreeElement.prototype.onselect.call(this,selectedByUser);this._storagePanel.showCategoryView(this._categoryName);return false;},onattach:function()
413 {WebInspector.BaseStorageTreeElement.prototype.onattach.call(this);if(WebInspector.settings[this._expandedSettingKey].get())
414 this.expand();},onexpand:function()
415 {WebInspector.settings[this._expandedSettingKey].set(true);},oncollapse:function()
416 {WebInspector.settings[this._expandedSettingKey].set(false);},__proto__:WebInspector.BaseStorageTreeElement.prototype}
417 WebInspector.FrameTreeElement=function(storagePanel,frame)
418 {WebInspector.BaseStorageTreeElement.call(this,storagePanel,null,"",["frame-storage-tree-item"]);this._frame=frame;this.frameNavigated(frame);}
419 WebInspector.FrameTreeElement.prototype={frameNavigated:function(frame)
420 {this.removeChildren();this._frameId=frame.id;this.titleText=frame.name;this.subtitleText=new WebInspector.ParsedURL(frame.url).displayName;this._categoryElements={};this._treeElementForResource={};this._storagePanel.addDocumentURL(frame.url);},get itemURL()
421 {return"frame://"+encodeURI(this.displayName);},onselect:function(selectedByUser)
422 {WebInspector.BaseStorageTreeElement.prototype.onselect.call(this,selectedByUser);this._storagePanel.showCategoryView(this.displayName);this.listItemElement.classList.remove("hovered");DOMAgent.hideHighlight();return false;},set hovered(hovered)
423 {if(hovered){this.listItemElement.classList.add("hovered");DOMAgent.highlightFrame(this._frameId,WebInspector.Color.PageHighlight.Content.toProtocolRGBA(),WebInspector.Color.PageHighlight.ContentOutline.toProtocolRGBA());}else{this.listItemElement.classList.remove("hovered");DOMAgent.hideHighlight();}},appendResource:function(resource)
424 {if(resource.isHidden())
425 return;var categoryName=resource.type.name();var categoryElement=resource.type===WebInspector.resourceTypes.Document?this:this._categoryElements[categoryName];if(!categoryElement){categoryElement=new WebInspector.StorageCategoryTreeElement(this._storagePanel,resource.type.categoryTitle(),categoryName,null,true);this._categoryElements[resource.type.name()]=categoryElement;this._insertInPresentationOrder(this,categoryElement);}
426 var resourceTreeElement=new WebInspector.FrameResourceTreeElement(this._storagePanel,resource);this._insertInPresentationOrder(categoryElement,resourceTreeElement);this._treeElementForResource[resource.url]=resourceTreeElement;},resourceByURL:function(url)
427 {var treeElement=this._treeElementForResource[url];return treeElement?treeElement.representedObject:null;},appendChild:function(treeElement)
428 {this._insertInPresentationOrder(this,treeElement);},_insertInPresentationOrder:function(parentTreeElement,childTreeElement)
429 {function typeWeight(treeElement)
430 {if(treeElement instanceof WebInspector.StorageCategoryTreeElement)
431 return 2;if(treeElement instanceof WebInspector.FrameTreeElement)
432 return 1;return 3;}
433 function compare(treeElement1,treeElement2)
434 {var typeWeight1=typeWeight(treeElement1);var typeWeight2=typeWeight(treeElement2);var result;if(typeWeight1>typeWeight2)
435 result=1;else if(typeWeight1<typeWeight2)
436 result=-1;else{var title1=treeElement1.displayName||treeElement1.titleText;var title2=treeElement2.displayName||treeElement2.titleText;result=title1.localeCompare(title2);}
437 return result;}
438 var children=parentTreeElement.children;var i;for(i=0;i<children.length;++i){if(compare(childTreeElement,children[i])<0)
439 break;}
440 parentTreeElement.insertChild(childTreeElement,i);},__proto__:WebInspector.BaseStorageTreeElement.prototype}
441 WebInspector.FrameResourceTreeElement=function(storagePanel,resource)
442 {WebInspector.BaseStorageTreeElement.call(this,storagePanel,resource,resource.displayName,["resource-sidebar-tree-item","resources-type-"+resource.type.name()]);this._resource=resource;this._resource.addEventListener(WebInspector.Resource.Events.MessageAdded,this._consoleMessageAdded,this);this._resource.addEventListener(WebInspector.Resource.Events.MessagesCleared,this._consoleMessagesCleared,this);this.tooltip=resource.url;}
443 WebInspector.FrameResourceTreeElement.prototype={get itemURL()
444 {return this._resource.url;},onselect:function(selectedByUser)
445 {WebInspector.BaseStorageTreeElement.prototype.onselect.call(this,selectedByUser);this._storagePanel._showResourceView(this._resource);return false;},ondblclick:function(event)
446 {InspectorFrontendHost.openInNewTab(this._resource.url);return false;},onattach:function()
447 {WebInspector.BaseStorageTreeElement.prototype.onattach.call(this);if(this._resource.type===WebInspector.resourceTypes.Image){var previewImage=document.createElement("img");previewImage.className="image-resource-icon-preview";this._resource.populateImageSource(previewImage);var iconElement=document.createElement("div");iconElement.className="icon";iconElement.appendChild(previewImage);this.listItemElement.replaceChild(iconElement,this.imageElement);}
448 this._statusElement=document.createElement("div");this._statusElement.className="status";this.listItemElement.insertBefore(this._statusElement,this.titleElement);this.listItemElement.draggable=true;this.listItemElement.addEventListener("dragstart",this._ondragstart.bind(this),false);this.listItemElement.addEventListener("contextmenu",this._handleContextMenuEvent.bind(this),true);this._updateErrorsAndWarningsBubbles();},_ondragstart:function(event)
449 {event.dataTransfer.setData("text/plain",this._resource.content);event.dataTransfer.effectAllowed="copy";return true;},_handleContextMenuEvent:function(event)
450 {var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendApplicableItems(this._resource);contextMenu.show();},_setBubbleText:function(x)
451 {if(!this._bubbleElement){this._bubbleElement=document.createElement("div");this._bubbleElement.className="bubble";this._statusElement.appendChild(this._bubbleElement);}
452 this._bubbleElement.textContent=x;},_resetBubble:function()
453 {if(this._bubbleElement){this._bubbleElement.textContent="";this._bubbleElement.classList.remove("warning");this._bubbleElement.classList.remove("error");}},_updateErrorsAndWarningsBubbles:function()
454 {if(this._storagePanel.currentQuery)
455 return;this._resetBubble();if(this._resource.warnings||this._resource.errors)
456 this._setBubbleText(this._resource.warnings+this._resource.errors);if(this._resource.warnings)
457 this._bubbleElement.classList.add("warning");if(this._resource.errors)
458 this._bubbleElement.classList.add("error");},_consoleMessagesCleared:function()
459 {if(this._sourceView)
460 this._sourceView.clearMessages();this._updateErrorsAndWarningsBubbles();},_consoleMessageAdded:function(event)
461 {var msg=event.data;if(this._sourceView)
462 this._sourceView.addMessage(msg);this._updateErrorsAndWarningsBubbles();},sourceView:function()
463 {if(!this._sourceView){var sourceFrame=new WebInspector.ResourceSourceFrame(this._resource);sourceFrame.setHighlighterType(this._resource.canonicalMimeType());this._sourceView=sourceFrame;if(this._resource.messages){for(var i=0;i<this._resource.messages.length;i++)
464 this._sourceView.addMessage(this._resource.messages[i]);}}
465 return this._sourceView;},__proto__:WebInspector.BaseStorageTreeElement.prototype}
466 WebInspector.DatabaseTreeElement=function(storagePanel,database)
467 {WebInspector.BaseStorageTreeElement.call(this,storagePanel,null,database.name,["database-storage-tree-item"],true);this._database=database;}
468 WebInspector.DatabaseTreeElement.prototype={get itemURL()
469 {return"database://"+encodeURI(this._database.name);},onselect:function(selectedByUser)
470 {WebInspector.BaseStorageTreeElement.prototype.onselect.call(this,selectedByUser);this._storagePanel._showDatabase(this._database);return false;},onexpand:function()
471 {this._updateChildren();},_updateChildren:function()
472 {this.removeChildren();function tableNamesCallback(tableNames)
473 {var tableNamesLength=tableNames.length;for(var i=0;i<tableNamesLength;++i)
474 this.appendChild(new WebInspector.DatabaseTableTreeElement(this._storagePanel,this._database,tableNames[i]));}
475 this._database.getTableNames(tableNamesCallback.bind(this));},__proto__:WebInspector.BaseStorageTreeElement.prototype}
476 WebInspector.DatabaseTableTreeElement=function(storagePanel,database,tableName)
477 {WebInspector.BaseStorageTreeElement.call(this,storagePanel,null,tableName,["database-storage-tree-item"]);this._database=database;this._tableName=tableName;}
478 WebInspector.DatabaseTableTreeElement.prototype={get itemURL()
479 {return"database://"+encodeURI(this._database.name)+"/"+encodeURI(this._tableName);},onselect:function(selectedByUser)
480 {WebInspector.BaseStorageTreeElement.prototype.onselect.call(this,selectedByUser);this._storagePanel._showDatabase(this._database,this._tableName);return false;},__proto__:WebInspector.BaseStorageTreeElement.prototype}
481 WebInspector.IndexedDBTreeElement=function(storagePanel)
482 {WebInspector.StorageCategoryTreeElement.call(this,storagePanel,WebInspector.UIString("IndexedDB"),"IndexedDB",["indexed-db-storage-tree-item"]);}
483 WebInspector.IndexedDBTreeElement.prototype={_initialize:function()
484 {this._createIndexedDBModel();},onattach:function()
485 {WebInspector.StorageCategoryTreeElement.prototype.onattach.call(this);this.listItemElement.addEventListener("contextmenu",this._handleContextMenuEvent.bind(this),true);},_handleContextMenuEvent:function(event)
486 {var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendItem(WebInspector.UIString("Refresh IndexedDB"),this.refreshIndexedDB.bind(this));contextMenu.show();},_createIndexedDBModel:function()
487 {this._indexedDBModel=new WebInspector.IndexedDBModel(this.target());this._idbDatabaseTreeElements=[];this._indexedDBModel.addEventListener(WebInspector.IndexedDBModel.EventTypes.DatabaseAdded,this._indexedDBAdded,this);this._indexedDBModel.addEventListener(WebInspector.IndexedDBModel.EventTypes.DatabaseRemoved,this._indexedDBRemoved,this);this._indexedDBModel.addEventListener(WebInspector.IndexedDBModel.EventTypes.DatabaseLoaded,this._indexedDBLoaded,this);},refreshIndexedDB:function()
488 {if(!this._indexedDBModel){this._createIndexedDBModel();return;}
489 this._indexedDBModel.refreshDatabaseNames();},_indexedDBAdded:function(event)
490 {var databaseId=(event.data);var idbDatabaseTreeElement=new WebInspector.IDBDatabaseTreeElement(this._storagePanel,this._indexedDBModel,databaseId);this._idbDatabaseTreeElements.push(idbDatabaseTreeElement);this.appendChild(idbDatabaseTreeElement);this._indexedDBModel.refreshDatabase(databaseId);},_indexedDBRemoved:function(event)
491 {var databaseId=(event.data);var idbDatabaseTreeElement=this._idbDatabaseTreeElement(databaseId)
492 if(!idbDatabaseTreeElement)
493 return;idbDatabaseTreeElement.clear();this.removeChild(idbDatabaseTreeElement);this._idbDatabaseTreeElements.remove(idbDatabaseTreeElement);},_indexedDBLoaded:function(event)
494 {var database=(event.data);var idbDatabaseTreeElement=this._idbDatabaseTreeElement(database.databaseId)
495 if(!idbDatabaseTreeElement)
496 return;idbDatabaseTreeElement.update(database);},_idbDatabaseTreeElement:function(databaseId)
497 {var index=-1;for(var i=0;i<this._idbDatabaseTreeElements.length;++i){if(this._idbDatabaseTreeElements[i]._databaseId.equals(databaseId)){index=i;break;}}
498 if(index!==-1)
499 return this._idbDatabaseTreeElements[i];return null;},__proto__:WebInspector.StorageCategoryTreeElement.prototype}
500 WebInspector.FileSystemListTreeElement=function(storagePanel)
501 {WebInspector.StorageCategoryTreeElement.call(this,storagePanel,WebInspector.UIString("FileSystem"),"FileSystem",["file-system-storage-tree-item"]);}
502 WebInspector.FileSystemListTreeElement.prototype={_initialize:function()
503 {this._refreshFileSystem();},onattach:function()
504 {WebInspector.StorageCategoryTreeElement.prototype.onattach.call(this);this.listItemElement.addEventListener("contextmenu",this._handleContextMenuEvent.bind(this),true);},_handleContextMenuEvent:function(event)
505 {var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Refresh FileSystem list":"Refresh FileSystem List"),this._refreshFileSystem.bind(this));contextMenu.show();},_fileSystemAdded:function(event)
506 {var fileSystem=(event.data);var fileSystemTreeElement=new WebInspector.FileSystemTreeElement(this._storagePanel,fileSystem);this.appendChild(fileSystemTreeElement);},_fileSystemRemoved:function(event)
507 {var fileSystem=(event.data);var fileSystemTreeElement=this._fileSystemTreeElementByName(fileSystem.name);if(!fileSystemTreeElement)
508 return;fileSystemTreeElement.clear();this.removeChild(fileSystemTreeElement);},_fileSystemTreeElementByName:function(fileSystemName)
509 {for(var i=0;i<this.children.length;++i){var child=(this.children[i]);if(child.fileSystemName===fileSystemName)
510 return this.children[i];}
511 return null;},_refreshFileSystem:function()
512 {if(!this._fileSystemModel){this._fileSystemModel=new WebInspector.FileSystemModel(this.target());this._fileSystemModel.addEventListener(WebInspector.FileSystemModel.EventTypes.FileSystemAdded,this._fileSystemAdded,this);this._fileSystemModel.addEventListener(WebInspector.FileSystemModel.EventTypes.FileSystemRemoved,this._fileSystemRemoved,this);}
513 this._fileSystemModel.refreshFileSystemList();},__proto__:WebInspector.StorageCategoryTreeElement.prototype}
514 WebInspector.IDBDatabaseTreeElement=function(storagePanel,model,databaseId)
515 {WebInspector.BaseStorageTreeElement.call(this,storagePanel,null,databaseId.name+" - "+databaseId.securityOrigin,["indexed-db-storage-tree-item"]);this._model=model;this._databaseId=databaseId;this._idbObjectStoreTreeElements={};}
516 WebInspector.IDBDatabaseTreeElement.prototype={get itemURL()
517 {return"indexedDB://"+this._databaseId.securityOrigin+"/"+this._databaseId.name;},onattach:function()
518 {WebInspector.BaseStorageTreeElement.prototype.onattach.call(this);this.listItemElement.addEventListener("contextmenu",this._handleContextMenuEvent.bind(this),true);},_handleContextMenuEvent:function(event)
519 {var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendItem(WebInspector.UIString("Refresh IndexedDB"),this._refreshIndexedDB.bind(this));contextMenu.show();},_refreshIndexedDB:function()
520 {this._model.refreshDatabaseNames();},update:function(database)
521 {this._database=database;var objectStoreNames={};for(var objectStoreName in this._database.objectStores){var objectStore=this._database.objectStores[objectStoreName];objectStoreNames[objectStore.name]=true;if(!this._idbObjectStoreTreeElements[objectStore.name]){var idbObjectStoreTreeElement=new WebInspector.IDBObjectStoreTreeElement(this._storagePanel,this._model,this._databaseId,objectStore);this._idbObjectStoreTreeElements[objectStore.name]=idbObjectStoreTreeElement;this.appendChild(idbObjectStoreTreeElement);}
522 this._idbObjectStoreTreeElements[objectStore.name].update(objectStore);}
523 for(var objectStoreName in this._idbObjectStoreTreeElements){if(!objectStoreNames[objectStoreName])
524 this._objectStoreRemoved(objectStoreName);}
525 if(this.children.length){this.hasChildren=true;this.expand();}
526 if(this._view)
527 this._view.update(database);this._updateTooltip();},_updateTooltip:function()
528 {this.tooltip=WebInspector.UIString("Version")+": "+this._database.version;},onselect:function(selectedByUser)
529 {WebInspector.BaseStorageTreeElement.prototype.onselect.call(this,selectedByUser);if(!this._view)
530 this._view=new WebInspector.IDBDatabaseView(this._database);this._storagePanel.showIndexedDB(this._view);return false;},_objectStoreRemoved:function(objectStoreName)
531 {var objectStoreTreeElement=this._idbObjectStoreTreeElements[objectStoreName];objectStoreTreeElement.clear();this.removeChild(objectStoreTreeElement);delete this._idbObjectStoreTreeElements[objectStoreName];},clear:function()
532 {for(var objectStoreName in this._idbObjectStoreTreeElements)
533 this._objectStoreRemoved(objectStoreName);},__proto__:WebInspector.BaseStorageTreeElement.prototype}
534 WebInspector.IDBObjectStoreTreeElement=function(storagePanel,model,databaseId,objectStore)
535 {WebInspector.BaseStorageTreeElement.call(this,storagePanel,null,objectStore.name,["indexed-db-object-store-storage-tree-item"]);this._model=model;this._databaseId=databaseId;this._idbIndexTreeElements={};}
536 WebInspector.IDBObjectStoreTreeElement.prototype={get itemURL()
537 {return"indexedDB://"+this._databaseId.securityOrigin+"/"+this._databaseId.name+"/"+this._objectStore.name;},onattach:function()
538 {WebInspector.BaseStorageTreeElement.prototype.onattach.call(this);this.listItemElement.addEventListener("contextmenu",this._handleContextMenuEvent.bind(this),true);},_handleContextMenuEvent:function(event)
539 {var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendItem(WebInspector.UIString("Clear"),this._clearObjectStore.bind(this));contextMenu.show();},_clearObjectStore:function()
540 {function callback(){this.update(this._objectStore);}
541 this._model.clearObjectStore(this._databaseId,this._objectStore.name,callback.bind(this));},update:function(objectStore)
542 {this._objectStore=objectStore;var indexNames={};for(var indexName in this._objectStore.indexes){var index=this._objectStore.indexes[indexName];indexNames[index.name]=true;if(!this._idbIndexTreeElements[index.name]){var idbIndexTreeElement=new WebInspector.IDBIndexTreeElement(this._storagePanel,this._model,this._databaseId,this._objectStore,index);this._idbIndexTreeElements[index.name]=idbIndexTreeElement;this.appendChild(idbIndexTreeElement);}
543 this._idbIndexTreeElements[index.name].update(index);}
544 for(var indexName in this._idbIndexTreeElements){if(!indexNames[indexName])
545 this._indexRemoved(indexName);}
546 for(var indexName in this._idbIndexTreeElements){if(!indexNames[indexName]){this.removeChild(this._idbIndexTreeElements[indexName]);delete this._idbIndexTreeElements[indexName];}}
547 if(this.children.length){this.hasChildren=true;this.expand();}
548 if(this._view)
549 this._view.update(this._objectStore);this._updateTooltip();},_updateTooltip:function()
550 {var keyPathString=this._objectStore.keyPathString;var tooltipString=keyPathString!==null?(WebInspector.UIString("Key path: ")+keyPathString):"";if(this._objectStore.autoIncrement)
551 tooltipString+="\n"+WebInspector.UIString("autoIncrement");this.tooltip=tooltipString},onselect:function(selectedByUser)
552 {WebInspector.BaseStorageTreeElement.prototype.onselect.call(this,selectedByUser);if(!this._view)
553 this._view=new WebInspector.IDBDataView(this._model,this._databaseId,this._objectStore,null);this._storagePanel.showIndexedDB(this._view);return false;},_indexRemoved:function(indexName)
554 {var indexTreeElement=this._idbIndexTreeElements[indexName];indexTreeElement.clear();this.removeChild(indexTreeElement);delete this._idbIndexTreeElements[indexName];},clear:function()
555 {for(var indexName in this._idbIndexTreeElements)
556 this._indexRemoved(indexName);if(this._view)
557 this._view.clear();},__proto__:WebInspector.BaseStorageTreeElement.prototype}
558 WebInspector.IDBIndexTreeElement=function(storagePanel,model,databaseId,objectStore,index)
559 {WebInspector.BaseStorageTreeElement.call(this,storagePanel,null,index.name,["indexed-db-index-storage-tree-item"]);this._model=model;this._databaseId=databaseId;this._objectStore=objectStore;this._index=index;}
560 WebInspector.IDBIndexTreeElement.prototype={get itemURL()
561 {return"indexedDB://"+this._databaseId.securityOrigin+"/"+this._databaseId.name+"/"+this._objectStore.name+"/"+this._index.name;},update:function(index)
562 {this._index=index;if(this._view)
563 this._view.update(this._index);this._updateTooltip();},_updateTooltip:function()
564 {var tooltipLines=[];var keyPathString=this._index.keyPathString;tooltipLines.push(WebInspector.UIString("Key path: ")+keyPathString);if(this._index.unique)
565 tooltipLines.push(WebInspector.UIString("unique"));if(this._index.multiEntry)
566 tooltipLines.push(WebInspector.UIString("multiEntry"));this.tooltip=tooltipLines.join("\n");},onselect:function(selectedByUser)
567 {WebInspector.BaseStorageTreeElement.prototype.onselect.call(this,selectedByUser);if(!this._view)
568 this._view=new WebInspector.IDBDataView(this._model,this._databaseId,this._objectStore,this._index);this._storagePanel.showIndexedDB(this._view);return false;},clear:function()
569 {if(this._view)
570 this._view.clear();},__proto__:WebInspector.BaseStorageTreeElement.prototype}
571 WebInspector.DOMStorageTreeElement=function(storagePanel,domStorage,className)
572 {WebInspector.BaseStorageTreeElement.call(this,storagePanel,null,domStorage.securityOrigin?domStorage.securityOrigin:WebInspector.UIString("Local Files"),["domstorage-storage-tree-item",className]);this._domStorage=domStorage;}
573 WebInspector.DOMStorageTreeElement.prototype={get itemURL()
574 {return"storage://"+this._domStorage.securityOrigin+"/"+(this._domStorage.isLocalStorage?"local":"session");},onselect:function(selectedByUser)
575 {WebInspector.BaseStorageTreeElement.prototype.onselect.call(this,selectedByUser);this._storagePanel._showDOMStorage(this._domStorage);return false;},__proto__:WebInspector.BaseStorageTreeElement.prototype}
576 WebInspector.CookieTreeElement=function(storagePanel,cookieDomain)
577 {WebInspector.BaseStorageTreeElement.call(this,storagePanel,null,cookieDomain?cookieDomain:WebInspector.UIString("Local Files"),["cookie-storage-tree-item"]);this._cookieDomain=cookieDomain;}
578 WebInspector.CookieTreeElement.prototype={get itemURL()
579 {return"cookies://"+this._cookieDomain;},onattach:function()
580 {WebInspector.BaseStorageTreeElement.prototype.onattach.call(this);this.listItemElement.addEventListener("contextmenu",this._handleContextMenuEvent.bind(this),true);},_handleContextMenuEvent:function(event)
581 {var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendItem(WebInspector.UIString("Clear"),this._clearCookies.bind(this));contextMenu.show();},_clearCookies:function(domain)
582 {this._storagePanel.clearCookies(this._cookieDomain);},onselect:function(selectedByUser)
583 {WebInspector.BaseStorageTreeElement.prototype.onselect.call(this,selectedByUser);this._storagePanel.showCookies(this,this._cookieDomain);return false;},__proto__:WebInspector.BaseStorageTreeElement.prototype}
584 WebInspector.ApplicationCacheManifestTreeElement=function(storagePanel,manifestURL)
585 {var title=new WebInspector.ParsedURL(manifestURL).displayName;WebInspector.BaseStorageTreeElement.call(this,storagePanel,null,title,["application-cache-storage-tree-item"]);this.tooltip=manifestURL;this._manifestURL=manifestURL;}
586 WebInspector.ApplicationCacheManifestTreeElement.prototype={get itemURL()
587 {return"appcache://"+this._manifestURL;},get manifestURL()
588 {return this._manifestURL;},onselect:function(selectedByUser)
589 {WebInspector.BaseStorageTreeElement.prototype.onselect.call(this,selectedByUser);this._storagePanel.showCategoryView(this._manifestURL);return false;},__proto__:WebInspector.BaseStorageTreeElement.prototype}
590 WebInspector.ApplicationCacheFrameTreeElement=function(storagePanel,frameId,manifestURL)
591 {WebInspector.BaseStorageTreeElement.call(this,storagePanel,null,"",["frame-storage-tree-item"]);this._frameId=frameId;this._manifestURL=manifestURL;this._refreshTitles();}
592 WebInspector.ApplicationCacheFrameTreeElement.prototype={get itemURL()
593 {return"appcache://"+this._manifestURL+"/"+encodeURI(this.displayName);},get frameId()
594 {return this._frameId;},get manifestURL()
595 {return this._manifestURL;},_refreshTitles:function()
596 {var frame=WebInspector.resourceTreeModel.frameForId(this._frameId);if(!frame){this.subtitleText=WebInspector.UIString("new frame");return;}
597 this.titleText=frame.name;this.subtitleText=new WebInspector.ParsedURL(frame.url).displayName;},frameNavigated:function()
598 {this._refreshTitles();},onselect:function(selectedByUser)
599 {WebInspector.BaseStorageTreeElement.prototype.onselect.call(this,selectedByUser);this._storagePanel.showApplicationCache(this._frameId);return false;},__proto__:WebInspector.BaseStorageTreeElement.prototype}
600 WebInspector.FileSystemTreeElement=function(storagePanel,fileSystem)
601 {var displayName=fileSystem.type+" - "+fileSystem.origin;WebInspector.BaseStorageTreeElement.call(this,storagePanel,null,displayName,["file-system-storage-tree-item"]);this._fileSystem=fileSystem;}
602 WebInspector.FileSystemTreeElement.prototype={get fileSystemName()
603 {return this._fileSystem.name;},get itemURL()
604 {return"filesystem://"+this._fileSystem.name;},onselect:function(selectedByUser)
605 {WebInspector.BaseStorageTreeElement.prototype.onselect.call(this,selectedByUser);this._fileSystemView=new WebInspector.FileSystemView(this._fileSystem);this._storagePanel.showFileSystem(this._fileSystemView);return false;},clear:function()
606 {if(this.fileSystemView&&this._storagePanel.visibleView===this.fileSystemView)
607 this._storagePanel.closeVisibleView();},__proto__:WebInspector.BaseStorageTreeElement.prototype}
608 WebInspector.StorageCategoryView=function()
609 {WebInspector.VBox.call(this);this.element.classList.add("storage-view");this._emptyView=new WebInspector.EmptyView("");this._emptyView.show(this.element);}
610 WebInspector.StorageCategoryView.prototype={setText:function(text)
611 {this._emptyView.text=text;},__proto__:WebInspector.VBox.prototype}