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

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

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // 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 * @implements {WebInspector.TargetManager.Observer} 5 * @implements {SDK.TargetManager.Observer}
6 * @unrestricted 6 * @unrestricted
7 */ 7 */
8 WebInspector.ClearStorageView = class extends WebInspector.VBox { 8 Resources.ClearStorageView = class extends UI.VBox {
9 /** 9 /**
10 * @param {!WebInspector.ResourcesPanel} resourcesPanel 10 * @param {!Resources.ResourcesPanel} resourcesPanel
11 */ 11 */
12 constructor(resourcesPanel) { 12 constructor(resourcesPanel) {
13 super(true); 13 super(true);
14 14
15 this._resourcesPanel = resourcesPanel; 15 this._resourcesPanel = resourcesPanel;
16 this._reportView = new WebInspector.ReportView(WebInspector.UIString('Clear storage')); 16 this._reportView = new UI.ReportView(Common.UIString('Clear storage'));
17 this._reportView.registerRequiredCSS('resources/clearStorageView.css'); 17 this._reportView.registerRequiredCSS('resources/clearStorageView.css');
18 this._reportView.element.classList.add('clear-storage-header'); 18 this._reportView.element.classList.add('clear-storage-header');
19 this._reportView.show(this.contentElement); 19 this._reportView.show(this.contentElement);
20 20
21 this._settings = new Map(); 21 this._settings = new Map();
22 for (var type 22 for (var type
23 of [Protocol.Storage.StorageType.Appcache, Protocol.Storage.Storage Type.Cache_storage, 23 of [Protocol.Storage.StorageType.Appcache, Protocol.Storage.Storage Type.Cache_storage,
24 Protocol.Storage.StorageType.Cookies, Protocol.Storage.StorageT ype.Indexeddb, 24 Protocol.Storage.StorageType.Cookies, Protocol.Storage.StorageT ype.Indexeddb,
25 Protocol.Storage.StorageType.Local_storage, Protocol.Storage.St orageType.Service_workers, 25 Protocol.Storage.StorageType.Local_storage, Protocol.Storage.St orageType.Service_workers,
26 Protocol.Storage.StorageType.Websql]) { 26 Protocol.Storage.StorageType.Websql]) {
27 this._settings.set(type, WebInspector.settings.createSetting('clear-storag e-' + type, true)); 27 this._settings.set(type, Common.settings.createSetting('clear-storage-' + type, true));
28 } 28 }
29 29
30 var application = this._reportView.appendSection(WebInspector.UIString('Appl ication')); 30 var application = this._reportView.appendSection(Common.UIString('Applicatio n'));
31 this._appendItem(application, WebInspector.UIString('Unregister service work ers'), 'service_workers'); 31 this._appendItem(application, Common.UIString('Unregister service workers'), 'service_workers');
32 32
33 var storage = this._reportView.appendSection(WebInspector.UIString('Storage' )); 33 var storage = this._reportView.appendSection(Common.UIString('Storage'));
34 this._appendItem(storage, WebInspector.UIString('Local and session storage') , 'local_storage'); 34 this._appendItem(storage, Common.UIString('Local and session storage'), 'loc al_storage');
35 this._appendItem(storage, WebInspector.UIString('Indexed DB'), 'indexeddb'); 35 this._appendItem(storage, Common.UIString('Indexed DB'), 'indexeddb');
36 this._appendItem(storage, WebInspector.UIString('Web SQL'), 'websql'); 36 this._appendItem(storage, Common.UIString('Web SQL'), 'websql');
37 this._appendItem(storage, WebInspector.UIString('Cookies'), 'cookies'); 37 this._appendItem(storage, Common.UIString('Cookies'), 'cookies');
38 38
39 var caches = this._reportView.appendSection(WebInspector.UIString('Cache')); 39 var caches = this._reportView.appendSection(Common.UIString('Cache'));
40 this._appendItem(caches, WebInspector.UIString('Cache storage'), 'cache_stor age'); 40 this._appendItem(caches, Common.UIString('Cache storage'), 'cache_storage');
41 this._appendItem(caches, WebInspector.UIString('Application cache'), 'appcac he'); 41 this._appendItem(caches, Common.UIString('Application cache'), 'appcache');
42 42
43 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Capabili ty.Browser); 43 SDK.targetManager.observeTargets(this, SDK.Target.Capability.Browser);
44 var footer = this._reportView.appendSection('', 'clear-storage-button').appe ndRow(); 44 var footer = this._reportView.appendSection('', 'clear-storage-button').appe ndRow();
45 this._clearButton = createTextButton( 45 this._clearButton = createTextButton(
46 WebInspector.UIString('Clear site data'), this._clear.bind(this), WebIns pector.UIString('Clear site data')); 46 Common.UIString('Clear site data'), this._clear.bind(this), Common.UIStr ing('Clear site data'));
47 footer.appendChild(this._clearButton); 47 footer.appendChild(this._clearButton);
48 } 48 }
49 49
50 /** 50 /**
51 * @param {!WebInspector.ReportView.Section} section 51 * @param {!UI.ReportView.Section} section
52 * @param {string} title 52 * @param {string} title
53 * @param {string} settingName 53 * @param {string} settingName
54 */ 54 */
55 _appendItem(section, title, settingName) { 55 _appendItem(section, title, settingName) {
56 var row = section.appendRow(); 56 var row = section.appendRow();
57 row.appendChild(WebInspector.SettingsUI.createSettingCheckbox(title, this._s ettings.get(settingName), true)); 57 row.appendChild(UI.SettingsUI.createSettingCheckbox(title, this._settings.ge t(settingName), true));
58 } 58 }
59 59
60 /** 60 /**
61 * @override 61 * @override
62 * @param {!WebInspector.Target} target 62 * @param {!SDK.Target} target
63 */ 63 */
64 targetAdded(target) { 64 targetAdded(target) {
65 if (this._target) 65 if (this._target)
66 return; 66 return;
67 this._target = target; 67 this._target = target;
68 var securityOriginManager = WebInspector.SecurityOriginManager.fromTarget(ta rget); 68 var securityOriginManager = SDK.SecurityOriginManager.fromTarget(target);
69 this._updateOrigin(securityOriginManager.mainSecurityOrigin()); 69 this._updateOrigin(securityOriginManager.mainSecurityOrigin());
70 securityOriginManager.addEventListener( 70 securityOriginManager.addEventListener(
71 WebInspector.SecurityOriginManager.Events.MainSecurityOriginChanged, thi s._originChanged, this); 71 SDK.SecurityOriginManager.Events.MainSecurityOriginChanged, this._origin Changed, this);
72 } 72 }
73 73
74 /** 74 /**
75 * @override 75 * @override
76 * @param {!WebInspector.Target} target 76 * @param {!SDK.Target} target
77 */ 77 */
78 targetRemoved(target) { 78 targetRemoved(target) {
79 if (this._target !== target) 79 if (this._target !== target)
80 return; 80 return;
81 var securityOriginManager = WebInspector.SecurityOriginManager.fromTarget(ta rget); 81 var securityOriginManager = SDK.SecurityOriginManager.fromTarget(target);
82 securityOriginManager.removeEventListener( 82 securityOriginManager.removeEventListener(
83 WebInspector.SecurityOriginManager.Events.MainSecurityOriginChanged, thi s._originChanged, this); 83 SDK.SecurityOriginManager.Events.MainSecurityOriginChanged, this._origin Changed, this);
84 } 84 }
85 85
86 /** 86 /**
87 * @param {!WebInspector.Event} event 87 * @param {!Common.Event} event
88 */ 88 */
89 _originChanged(event) { 89 _originChanged(event) {
90 var origin = /** *@type {string} */ (event.data); 90 var origin = /** *@type {string} */ (event.data);
91 this._updateOrigin(origin); 91 this._updateOrigin(origin);
92 } 92 }
93 93
94 /** 94 /**
95 * @param {string} url 95 * @param {string} url
96 */ 96 */
97 _updateOrigin(url) { 97 _updateOrigin(url) {
98 this._securityOrigin = new WebInspector.ParsedURL(url).securityOrigin(); 98 this._securityOrigin = new Common.ParsedURL(url).securityOrigin();
99 this._reportView.setSubtitle(this._securityOrigin); 99 this._reportView.setSubtitle(this._securityOrigin);
100 } 100 }
101 101
102 _clear() { 102 _clear() {
103 var storageTypes = []; 103 var storageTypes = [];
104 for (var type of this._settings.keys()) { 104 for (var type of this._settings.keys()) {
105 if (this._settings.get(type).get()) 105 if (this._settings.get(type).get())
106 storageTypes.push(type); 106 storageTypes.push(type);
107 } 107 }
108 108
109 this._target.storageAgent().clearDataForOrigin(this._securityOrigin, storage Types.join(',')); 109 this._target.storageAgent().clearDataForOrigin(this._securityOrigin, storage Types.join(','));
110 110
111 var set = new Set(storageTypes); 111 var set = new Set(storageTypes);
112 var hasAll = set.has(Protocol.Storage.StorageType.All); 112 var hasAll = set.has(Protocol.Storage.StorageType.All);
113 if (set.has(Protocol.Storage.StorageType.Cookies) || hasAll) 113 if (set.has(Protocol.Storage.StorageType.Cookies) || hasAll)
114 this._resourcesPanel.clearCookies(this._securityOrigin); 114 this._resourcesPanel.clearCookies(this._securityOrigin);
115 115
116 if (set.has(Protocol.Storage.StorageType.Indexeddb) || hasAll) { 116 if (set.has(Protocol.Storage.StorageType.Indexeddb) || hasAll) {
117 for (var target of WebInspector.targetManager.targets()) { 117 for (var target of SDK.targetManager.targets()) {
118 var indexedDBModel = WebInspector.IndexedDBModel.fromTarget(target); 118 var indexedDBModel = Resources.IndexedDBModel.fromTarget(target);
119 if (indexedDBModel) 119 if (indexedDBModel)
120 indexedDBModel.clearForOrigin(this._securityOrigin); 120 indexedDBModel.clearForOrigin(this._securityOrigin);
121 } 121 }
122 } 122 }
123 123
124 if (set.has(Protocol.Storage.StorageType.Local_storage) || hasAll) { 124 if (set.has(Protocol.Storage.StorageType.Local_storage) || hasAll) {
125 var storageModel = WebInspector.DOMStorageModel.fromTarget(this._target); 125 var storageModel = Resources.DOMStorageModel.fromTarget(this._target);
126 if (storageModel) 126 if (storageModel)
127 storageModel.clearForOrigin(this._securityOrigin); 127 storageModel.clearForOrigin(this._securityOrigin);
128 } 128 }
129 129
130 if (set.has(Protocol.Storage.StorageType.Websql) || hasAll) { 130 if (set.has(Protocol.Storage.StorageType.Websql) || hasAll) {
131 var databaseModel = WebInspector.DatabaseModel.fromTarget(this._target); 131 var databaseModel = Resources.DatabaseModel.fromTarget(this._target);
132 if (databaseModel) { 132 if (databaseModel) {
133 databaseModel.disable(); 133 databaseModel.disable();
134 databaseModel.enable(); 134 databaseModel.enable();
135 } 135 }
136 } 136 }
137 137
138 if (set.has(Protocol.Storage.StorageType.Cache_storage) || hasAll) { 138 if (set.has(Protocol.Storage.StorageType.Cache_storage) || hasAll) {
139 var target = WebInspector.targetManager.mainTarget(); 139 var target = SDK.targetManager.mainTarget();
140 var model = target && WebInspector.ServiceWorkerCacheModel.fromTarget(targ et); 140 var model = target && SDK.ServiceWorkerCacheModel.fromTarget(target);
141 if (model) 141 if (model)
142 model.clearForOrigin(this._securityOrigin); 142 model.clearForOrigin(this._securityOrigin);
143 } 143 }
144 144
145 if (set.has(Protocol.Storage.StorageType.Appcache) || hasAll) { 145 if (set.has(Protocol.Storage.StorageType.Appcache) || hasAll) {
146 var appcacheModel = WebInspector.ApplicationCacheModel.fromTarget(this._ta rget); 146 var appcacheModel = SDK.ApplicationCacheModel.fromTarget(this._target);
147 if (appcacheModel) 147 if (appcacheModel)
148 appcacheModel.reset(); 148 appcacheModel.reset();
149 } 149 }
150 150
151 this._clearButton.disabled = true; 151 this._clearButton.disabled = true;
152 this._clearButton.textContent = WebInspector.UIString('Clearing...'); 152 this._clearButton.textContent = Common.UIString('Clearing...');
153 setTimeout(() => { 153 setTimeout(() => {
154 this._clearButton.disabled = false; 154 this._clearButton.disabled = false;
155 this._clearButton.textContent = WebInspector.UIString('Clear selected'); 155 this._clearButton.textContent = Common.UIString('Clear selected');
156 }, 500); 156 }, 500);
157 } 157 }
158 }; 158 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698