| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @extends {WebInspector.VBox} | 7 * @extends {WebInspector.VBox} |
| 8 * @implements {WebInspector.TargetManager.Observer} | 8 * @implements {WebInspector.TargetManager.Observer} |
| 9 * @param {!WebInspector.ResourcesPanel} resourcesPanel | 9 * @param {!WebInspector.ResourcesPanel} resourcesPanel |
| 10 */ | 10 */ |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 var storage = this._reportView.appendSection(WebInspector.UIString("Storage"
)); | 35 var storage = this._reportView.appendSection(WebInspector.UIString("Storage"
)); |
| 36 this._appendItem(storage, WebInspector.UIString("Local and session storage")
, "local_storage"); | 36 this._appendItem(storage, WebInspector.UIString("Local and session storage")
, "local_storage"); |
| 37 this._appendItem(storage, WebInspector.UIString("Indexed DB"), "indexeddb"); | 37 this._appendItem(storage, WebInspector.UIString("Indexed DB"), "indexeddb"); |
| 38 this._appendItem(storage, WebInspector.UIString("Web SQL"), "websql"); | 38 this._appendItem(storage, WebInspector.UIString("Web SQL"), "websql"); |
| 39 this._appendItem(storage, WebInspector.UIString("Cookies"), "cookies"); | 39 this._appendItem(storage, WebInspector.UIString("Cookies"), "cookies"); |
| 40 | 40 |
| 41 var caches = this._reportView.appendSection(WebInspector.UIString("Cache")); | 41 var caches = this._reportView.appendSection(WebInspector.UIString("Cache")); |
| 42 this._appendItem(caches, WebInspector.UIString("Cache storage"), "cache_stor
age"); | 42 this._appendItem(caches, WebInspector.UIString("Cache storage"), "cache_stor
age"); |
| 43 this._appendItem(caches, WebInspector.UIString("Application cache"), "appcac
he"); | 43 this._appendItem(caches, WebInspector.UIString("Application cache"), "appcac
he"); |
| 44 | 44 |
| 45 WebInspector.targetManager.observeTargets(this); | 45 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Capabili
ty.Browser); |
| 46 var footer = this._reportView.appendSection("", "clear-storage-button").appe
ndRow(); | 46 var footer = this._reportView.appendSection("", "clear-storage-button").appe
ndRow(); |
| 47 this._clearButton = createTextButton(WebInspector.UIString("Clear site data"
), this._clear.bind(this), WebInspector.UIString("Clear site data")); | 47 this._clearButton = createTextButton(WebInspector.UIString("Clear site data"
), this._clear.bind(this), WebInspector.UIString("Clear site data")); |
| 48 footer.appendChild(this._clearButton); | 48 footer.appendChild(this._clearButton); |
| 49 } | 49 } |
| 50 | 50 |
| 51 WebInspector.ClearStorageView.prototype = { | 51 WebInspector.ClearStorageView.prototype = { |
| 52 | 52 |
| 53 /** | 53 /** |
| 54 * @param {!WebInspector.ReportView.Section} section | 54 * @param {!WebInspector.ReportView.Section} section |
| 55 * @param {string} title | 55 * @param {string} title |
| 56 * @param {string} settingName | 56 * @param {string} settingName |
| 57 */ | 57 */ |
| 58 _appendItem: function(section, title, settingName) | 58 _appendItem: function(section, title, settingName) |
| 59 { | 59 { |
| 60 var row = section.appendRow(); | 60 var row = section.appendRow(); |
| 61 row.appendChild(WebInspector.SettingsUI.createSettingCheckbox(title, thi
s._settings.get(settingName), true)); | 61 row.appendChild(WebInspector.SettingsUI.createSettingCheckbox(title, thi
s._settings.get(settingName), true)); |
| 62 }, | 62 }, |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * @override | 65 * @override |
| 66 * @param {!WebInspector.Target} target | 66 * @param {!WebInspector.Target} target |
| 67 */ | 67 */ |
| 68 targetAdded: function(target) | 68 targetAdded: function(target) |
| 69 { | 69 { |
| 70 if (this._target) | 70 if (this._target) |
| 71 return; | 71 return; |
| 72 this._target = target; | 72 this._target = target; |
| 73 this._updateOrigin(target.resourceTreeModel.mainFrame ? target.resourceT
reeModel.mainFrame.url : ""); | 73 var securityOriginManager = WebInspector.SecurityOriginManager.fromTarge
t(target); |
| 74 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.E
vents.MainFrameNavigated, this._updateFrame, this); | 74 this._updateOrigin(securityOriginManager.mainSecurityOrigin()); |
| 75 securityOriginManager.addEventListener(WebInspector.SecurityOriginManage
r.EventTypes.MainSecurityOriginChanged, this._originChanged, this); |
| 75 }, | 76 }, |
| 76 | 77 |
| 77 /** | 78 /** |
| 78 * @param {!WebInspector.Event} event | 79 * @param {!WebInspector.Event} event |
| 79 */ | 80 */ |
| 80 _updateFrame: function(event) | 81 _originChanged: function(event) |
| 81 { | 82 { |
| 82 var frame = /** *@type {!WebInspector.ResourceTreeFrame} */ (event.data)
; | 83 var origin = /** *@type {string} */ (event.data); |
| 83 this._updateOrigin(frame.url); | 84 this._updateOrigin(origin); |
| 84 }, | 85 }, |
| 85 | 86 |
| 86 /** | 87 /** |
| 87 * @param {string} url | 88 * @param {string} url |
| 88 */ | 89 */ |
| 89 _updateOrigin: function(url) | 90 _updateOrigin: function(url) |
| 90 { | 91 { |
| 91 this._securityOrigin = new WebInspector.ParsedURL(url).securityOrigin(); | 92 this._securityOrigin = new WebInspector.ParsedURL(url).securityOrigin(); |
| 92 this._reportView.setSubtitle(this._securityOrigin); | 93 this._reportView.setSubtitle(this._securityOrigin); |
| 93 }, | 94 }, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 124 if (set.has(StorageAgent.StorageType.Websql) || hasAll) { | 125 if (set.has(StorageAgent.StorageType.Websql) || hasAll) { |
| 125 var databaseModel = WebInspector.DatabaseModel.fromTarget(this._targ
et); | 126 var databaseModel = WebInspector.DatabaseModel.fromTarget(this._targ
et); |
| 126 if (databaseModel) { | 127 if (databaseModel) { |
| 127 databaseModel.disable(); | 128 databaseModel.disable(); |
| 128 databaseModel.enable(); | 129 databaseModel.enable(); |
| 129 } | 130 } |
| 130 } | 131 } |
| 131 | 132 |
| 132 if (set.has(StorageAgent.StorageType.Cache_storage) || hasAll) { | 133 if (set.has(StorageAgent.StorageType.Cache_storage) || hasAll) { |
| 133 var target = WebInspector.targetManager.mainTarget(); | 134 var target = WebInspector.targetManager.mainTarget(); |
| 134 if (target) { | 135 var model = target && WebInspector.ServiceWorkerCacheModel.fromTarge
t(target); |
| 135 var model = WebInspector.ServiceWorkerCacheModel.fromTarget(targ
et); | 136 if (model) |
| 136 if (model) | 137 model.clearForOrigin(this._securityOrigin); |
| 137 model.clearForOrigin(this._securityOrigin); | |
| 138 } | |
| 139 } | 138 } |
| 140 | 139 |
| 141 if (set.has(StorageAgent.StorageType.Appcache) || hasAll) { | 140 if (set.has(StorageAgent.StorageType.Appcache) || hasAll) { |
| 142 var appcacheModel = WebInspector.ApplicationCacheModel.fromTarget(th
is._target); | 141 var appcacheModel = WebInspector.ApplicationCacheModel.fromTarget(th
is._target); |
| 143 if (appcacheModel) | 142 if (appcacheModel) |
| 144 appcacheModel.reset(); | 143 appcacheModel.reset(); |
| 145 } | 144 } |
| 146 | 145 |
| 147 this._clearButton.disabled = true; | 146 this._clearButton.disabled = true; |
| 148 this._clearButton.textContent = WebInspector.UIString("Clearing..."); | 147 this._clearButton.textContent = WebInspector.UIString("Clearing..."); |
| 149 setTimeout(() => { | 148 setTimeout(() => { |
| 150 this._clearButton.disabled = false; | 149 this._clearButton.disabled = false; |
| 151 this._clearButton.textContent = WebInspector.UIString("Clear selecte
d"); | 150 this._clearButton.textContent = WebInspector.UIString("Clear selecte
d"); |
| 152 }, 500); | 151 }, 500); |
| 153 }, | 152 }, |
| 154 | 153 |
| 155 /** | 154 /** |
| 156 * @override | 155 * @override |
| 157 * @param {!WebInspector.Target} target | 156 * @param {!WebInspector.Target} target |
| 158 */ | 157 */ |
| 159 targetRemoved: function(target) | 158 targetRemoved: function(target) |
| 160 { | 159 { |
| 161 }, | 160 }, |
| 162 | 161 |
| 163 __proto__: WebInspector.VBox.prototype | 162 __proto__: WebInspector.VBox.prototype |
| 164 } | 163 } |
| OLD | NEW |