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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/resources/ServiceWorkersView.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) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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.ServiceWorkersView = class extends WebInspector.VBox { 8 Resources.ServiceWorkersView = class extends UI.VBox {
9 constructor() { 9 constructor() {
10 super(true); 10 super(true);
11 11
12 this._reportView = new WebInspector.ReportView(WebInspector.UIString('Servic e Workers')); 12 this._reportView = new UI.ReportView(Common.UIString('Service Workers'));
13 this._reportView.show(this.contentElement); 13 this._reportView.show(this.contentElement);
14 14
15 this._toolbar = this._reportView.createToolbar(); 15 this._toolbar = this._reportView.createToolbar();
16 16
17 /** @type {!Map<!WebInspector.ServiceWorkerRegistration, !WebInspector.Servi ceWorkersView.Section>} */ 17 /** @type {!Map<!SDK.ServiceWorkerRegistration, !Resources.ServiceWorkersVie w.Section>} */
18 this._sections = new Map(); 18 this._sections = new Map();
19 19
20 this._toolbar.appendToolbarItem(WebInspector.NetworkConditionsSelector.creat eOfflineToolbarCheckbox()); 20 this._toolbar.appendToolbarItem(Components.NetworkConditionsSelector.createO fflineToolbarCheckbox());
21 var forceUpdate = new WebInspector.ToolbarCheckbox( 21 var forceUpdate = new UI.ToolbarCheckbox(
22 WebInspector.UIString('Update on reload'), WebInspector.UIString('Force update Service Worker on page reload'), 22 Common.UIString('Update on reload'), Common.UIString('Force update Servi ce Worker on page reload'),
23 WebInspector.settings.createSetting('serviceWorkerUpdateOnReload', false )); 23 Common.settings.createSetting('serviceWorkerUpdateOnReload', false));
24 this._toolbar.appendToolbarItem(forceUpdate); 24 this._toolbar.appendToolbarItem(forceUpdate);
25 var fallbackToNetwork = new WebInspector.ToolbarCheckbox( 25 var fallbackToNetwork = new UI.ToolbarCheckbox(
26 WebInspector.UIString('Bypass for network'), 26 Common.UIString('Bypass for network'),
27 WebInspector.UIString('Bypass Service Worker and load resources from the network'), 27 Common.UIString('Bypass Service Worker and load resources from the netwo rk'),
28 WebInspector.settings.createSetting('bypassServiceWorker', false)); 28 Common.settings.createSetting('bypassServiceWorker', false));
29 this._toolbar.appendToolbarItem(fallbackToNetwork); 29 this._toolbar.appendToolbarItem(fallbackToNetwork);
30 this._toolbar.appendSpacer(); 30 this._toolbar.appendSpacer();
31 this._showAllCheckbox = new WebInspector.ToolbarCheckbox( 31 this._showAllCheckbox = new UI.ToolbarCheckbox(
32 WebInspector.UIString('Show all'), WebInspector.UIString('Show all Servi ce Workers regardless of the origin')); 32 Common.UIString('Show all'), Common.UIString('Show all Service Workers r egardless of the origin'));
33 this._showAllCheckbox.inputElement.addEventListener('change', this._updateSe ctionVisibility.bind(this), false); 33 this._showAllCheckbox.inputElement.addEventListener('change', this._updateSe ctionVisibility.bind(this), false);
34 this._toolbar.appendToolbarItem(this._showAllCheckbox); 34 this._toolbar.appendToolbarItem(this._showAllCheckbox);
35 35
36 /** @type {!Map<!WebInspector.Target, !Array<!WebInspector.EventTarget.Event Descriptor>>}*/ 36 /** @type {!Map<!SDK.Target, !Array<!Common.EventTarget.EventDescriptor>>}*/
37 this._eventListeners = new Map(); 37 this._eventListeners = new Map();
38 WebInspector.targetManager.observeTargets(this); 38 SDK.targetManager.observeTargets(this);
39 } 39 }
40 40
41 /** 41 /**
42 * @override 42 * @override
43 * @param {!WebInspector.Target} target 43 * @param {!SDK.Target} target
44 */ 44 */
45 targetAdded(target) { 45 targetAdded(target) {
46 if (this._manager || !target.serviceWorkerManager) 46 if (this._manager || !target.serviceWorkerManager)
47 return; 47 return;
48 this._manager = target.serviceWorkerManager; 48 this._manager = target.serviceWorkerManager;
49 this._subTargetsManager = target.subTargetsManager; 49 this._subTargetsManager = target.subTargetsManager;
50 this._securityOriginManager = WebInspector.SecurityOriginManager.fromTarget( target); 50 this._securityOriginManager = SDK.SecurityOriginManager.fromTarget(target);
51 51
52 for (var registration of this._manager.registrations().values()) 52 for (var registration of this._manager.registrations().values())
53 this._updateRegistration(registration); 53 this._updateRegistration(registration);
54 54
55 this._eventListeners.set(target, [ 55 this._eventListeners.set(target, [
56 this._manager.addEventListener( 56 this._manager.addEventListener(
57 WebInspector.ServiceWorkerManager.Events.RegistrationUpdated, this._re gistrationUpdated, this), 57 SDK.ServiceWorkerManager.Events.RegistrationUpdated, this._registratio nUpdated, this),
58 this._manager.addEventListener( 58 this._manager.addEventListener(
59 WebInspector.ServiceWorkerManager.Events.RegistrationDeleted, this._re gistrationDeleted, this), 59 SDK.ServiceWorkerManager.Events.RegistrationDeleted, this._registratio nDeleted, this),
60 this._manager.addEventListener( 60 this._manager.addEventListener(
61 WebInspector.ServiceWorkerManager.Events.RegistrationErrorAdded, this. _registrationErrorAdded, this), 61 SDK.ServiceWorkerManager.Events.RegistrationErrorAdded, this._registra tionErrorAdded, this),
62 this._securityOriginManager.addEventListener( 62 this._securityOriginManager.addEventListener(
63 WebInspector.SecurityOriginManager.Events.SecurityOriginAdded, this._u pdateSectionVisibility, this), 63 SDK.SecurityOriginManager.Events.SecurityOriginAdded, this._updateSect ionVisibility, this),
64 this._securityOriginManager.addEventListener( 64 this._securityOriginManager.addEventListener(
65 WebInspector.SecurityOriginManager.Events.SecurityOriginRemoved, this. _updateSectionVisibility, this), 65 SDK.SecurityOriginManager.Events.SecurityOriginRemoved, this._updateSe ctionVisibility, this),
66 ]); 66 ]);
67 } 67 }
68 68
69 /** 69 /**
70 * @override 70 * @override
71 * @param {!WebInspector.Target} target 71 * @param {!SDK.Target} target
72 */ 72 */
73 targetRemoved(target) { 73 targetRemoved(target) {
74 if (!this._manager || this._manager !== target.serviceWorkerManager) 74 if (!this._manager || this._manager !== target.serviceWorkerManager)
75 return; 75 return;
76 76
77 WebInspector.EventTarget.removeEventListeners(this._eventListeners.get(targe t)); 77 Common.EventTarget.removeEventListeners(this._eventListeners.get(target));
78 this._eventListeners.delete(target); 78 this._eventListeners.delete(target);
79 this._manager = null; 79 this._manager = null;
80 this._subTargetsManager = null; 80 this._subTargetsManager = null;
81 this._securityOriginManager = null; 81 this._securityOriginManager = null;
82 } 82 }
83 83
84 _updateSectionVisibility() { 84 _updateSectionVisibility() {
85 var securityOrigins = new Set(this._securityOriginManager.securityOrigins()) ; 85 var securityOrigins = new Set(this._securityOriginManager.securityOrigins()) ;
86 for (var section of this._sections.values()) { 86 for (var section of this._sections.values()) {
87 var visible = this._showAllCheckbox.checked() || securityOrigins.has(secti on._registration.securityOrigin); 87 var visible = this._showAllCheckbox.checked() || securityOrigins.has(secti on._registration.securityOrigin);
88 section._section.element.classList.toggle('hidden', !visible); 88 section._section.element.classList.toggle('hidden', !visible);
89 } 89 }
90 } 90 }
91 91
92 /** 92 /**
93 * @param {!WebInspector.Event} event 93 * @param {!Common.Event} event
94 */ 94 */
95 _registrationUpdated(event) { 95 _registrationUpdated(event) {
96 var registration = /** @type {!WebInspector.ServiceWorkerRegistration} */ (e vent.data); 96 var registration = /** @type {!SDK.ServiceWorkerRegistration} */ (event.data );
97 this._updateRegistration(registration); 97 this._updateRegistration(registration);
98 } 98 }
99 99
100 /** 100 /**
101 * @param {!WebInspector.Event} event 101 * @param {!Common.Event} event
102 */ 102 */
103 _registrationErrorAdded(event) { 103 _registrationErrorAdded(event) {
104 var registration = /** @type {!WebInspector.ServiceWorkerRegistration} */ (e vent.data['registration']); 104 var registration = /** @type {!SDK.ServiceWorkerRegistration} */ (event.data ['registration']);
105 var error = /** @type {!Protocol.ServiceWorker.ServiceWorkerErrorMessage} */ (event.data['error']); 105 var error = /** @type {!Protocol.ServiceWorker.ServiceWorkerErrorMessage} */ (event.data['error']);
106 var section = this._sections.get(registration); 106 var section = this._sections.get(registration);
107 if (!section) 107 if (!section)
108 return; 108 return;
109 section._addError(error); 109 section._addError(error);
110 } 110 }
111 111
112 /** 112 /**
113 * @param {!WebInspector.ServiceWorkerRegistration} registration 113 * @param {!SDK.ServiceWorkerRegistration} registration
114 */ 114 */
115 _updateRegistration(registration) { 115 _updateRegistration(registration) {
116 var section = this._sections.get(registration); 116 var section = this._sections.get(registration);
117 if (!section) { 117 if (!section) {
118 section = new WebInspector.ServiceWorkersView.Section( 118 section = new Resources.ServiceWorkersView.Section(
119 this._manager, this._subTargetsManager, this._reportView.appendSection (''), registration); 119 this._manager, this._subTargetsManager, this._reportView.appendSection (''), registration);
120 this._sections.set(registration, section); 120 this._sections.set(registration, section);
121 } 121 }
122 this._updateSectionVisibility(); 122 this._updateSectionVisibility();
123 section._scheduleUpdate(); 123 section._scheduleUpdate();
124 } 124 }
125 125
126 /** 126 /**
127 * @param {!WebInspector.Event} event 127 * @param {!Common.Event} event
128 */ 128 */
129 _registrationDeleted(event) { 129 _registrationDeleted(event) {
130 var registration = /** @type {!WebInspector.ServiceWorkerRegistration} */ (e vent.data); 130 var registration = /** @type {!SDK.ServiceWorkerRegistration} */ (event.data );
131 var section = this._sections.get(registration); 131 var section = this._sections.get(registration);
132 if (section) 132 if (section)
133 section._section.remove(); 133 section._section.remove();
134 this._sections.delete(registration); 134 this._sections.delete(registration);
135 } 135 }
136 }; 136 };
137 137
138 /** 138 /**
139 * @unrestricted 139 * @unrestricted
140 */ 140 */
141 WebInspector.ServiceWorkersView.Section = class { 141 Resources.ServiceWorkersView.Section = class {
142 /** 142 /**
143 * @param {!WebInspector.ServiceWorkerManager} manager 143 * @param {!SDK.ServiceWorkerManager} manager
144 * @param {!WebInspector.SubTargetsManager} subTargetsManager 144 * @param {!SDK.SubTargetsManager} subTargetsManager
145 * @param {!WebInspector.ReportView.Section} section 145 * @param {!UI.ReportView.Section} section
146 * @param {!WebInspector.ServiceWorkerRegistration} registration 146 * @param {!SDK.ServiceWorkerRegistration} registration
147 */ 147 */
148 constructor(manager, subTargetsManager, section, registration) { 148 constructor(manager, subTargetsManager, section, registration) {
149 this._manager = manager; 149 this._manager = manager;
150 this._subTargetsManager = subTargetsManager; 150 this._subTargetsManager = subTargetsManager;
151 this._section = section; 151 this._section = section;
152 this._registration = registration; 152 this._registration = registration;
153 153
154 this._toolbar = section.createToolbar(); 154 this._toolbar = section.createToolbar();
155 this._toolbar.renderAsLinks(); 155 this._toolbar.renderAsLinks();
156 this._updateButton = 156 this._updateButton =
157 new WebInspector.ToolbarButton(WebInspector.UIString('Update'), undefine d, WebInspector.UIString('Update')); 157 new UI.ToolbarButton(Common.UIString('Update'), undefined, Common.UIStri ng('Update'));
158 this._updateButton.addEventListener('click', this._updateButtonClicked.bind( this)); 158 this._updateButton.addEventListener('click', this._updateButtonClicked.bind( this));
159 this._toolbar.appendToolbarItem(this._updateButton); 159 this._toolbar.appendToolbarItem(this._updateButton);
160 this._pushButton = new WebInspector.ToolbarButton( 160 this._pushButton = new UI.ToolbarButton(
161 WebInspector.UIString('Emulate push event'), undefined, WebInspector.UIS tring('Push')); 161 Common.UIString('Emulate push event'), undefined, Common.UIString('Push' ));
162 this._pushButton.addEventListener('click', this._pushButtonClicked.bind(this )); 162 this._pushButton.addEventListener('click', this._pushButtonClicked.bind(this ));
163 this._toolbar.appendToolbarItem(this._pushButton); 163 this._toolbar.appendToolbarItem(this._pushButton);
164 this._syncButton = new WebInspector.ToolbarButton( 164 this._syncButton = new UI.ToolbarButton(
165 WebInspector.UIString('Emulate background sync event'), undefined, WebIn spector.UIString('Sync')); 165 Common.UIString('Emulate background sync event'), undefined, Common.UISt ring('Sync'));
166 this._syncButton.addEventListener('click', this._syncButtonClicked.bind(this )); 166 this._syncButton.addEventListener('click', this._syncButtonClicked.bind(this ));
167 this._toolbar.appendToolbarItem(this._syncButton); 167 this._toolbar.appendToolbarItem(this._syncButton);
168 this._deleteButton = new WebInspector.ToolbarButton( 168 this._deleteButton = new UI.ToolbarButton(
169 WebInspector.UIString('Unregister service worker'), undefined, WebInspec tor.UIString('Unregister')); 169 Common.UIString('Unregister service worker'), undefined, Common.UIString ('Unregister'));
170 this._deleteButton.addEventListener('click', this._unregisterButtonClicked.b ind(this)); 170 this._deleteButton.addEventListener('click', this._unregisterButtonClicked.b ind(this));
171 this._toolbar.appendToolbarItem(this._deleteButton); 171 this._toolbar.appendToolbarItem(this._deleteButton);
172 172
173 // Preserve the order. 173 // Preserve the order.
174 this._section.appendField(WebInspector.UIString('Source')); 174 this._section.appendField(Common.UIString('Source'));
175 this._section.appendField(WebInspector.UIString('Status')); 175 this._section.appendField(Common.UIString('Status'));
176 this._section.appendField(WebInspector.UIString('Clients')); 176 this._section.appendField(Common.UIString('Clients'));
177 this._section.appendField(WebInspector.UIString('Errors')); 177 this._section.appendField(Common.UIString('Errors'));
178 this._errorsList = this._wrapWidget(this._section.appendRow()); 178 this._errorsList = this._wrapWidget(this._section.appendRow());
179 this._errorsList.classList.add('service-worker-error-stack', 'monospace', 'h idden'); 179 this._errorsList.classList.add('service-worker-error-stack', 'monospace', 'h idden');
180 180
181 this._linkifier = new WebInspector.Linkifier(); 181 this._linkifier = new Components.Linkifier();
182 /** @type {!Map<string, !WebInspector.TargetInfo>} */ 182 /** @type {!Map<string, !SDK.TargetInfo>} */
183 this._clientInfoCache = new Map(); 183 this._clientInfoCache = new Map();
184 for (var error of registration.errors) 184 for (var error of registration.errors)
185 this._addError(error); 185 this._addError(error);
186 this._throttler = new WebInspector.Throttler(500); 186 this._throttler = new Common.Throttler(500);
187 } 187 }
188 188
189 _scheduleUpdate() { 189 _scheduleUpdate() {
190 if (WebInspector.ServiceWorkersView._noThrottle) { 190 if (Resources.ServiceWorkersView._noThrottle) {
191 this._update(); 191 this._update();
192 return; 192 return;
193 } 193 }
194 this._throttler.schedule(this._update.bind(this)); 194 this._throttler.schedule(this._update.bind(this));
195 } 195 }
196 196
197 /** 197 /**
198 * @param {string} versionId 198 * @param {string} versionId
199 * @return {?WebInspector.Target} 199 * @return {?SDK.Target}
200 */ 200 */
201 _targetForVersionId(versionId) { 201 _targetForVersionId(versionId) {
202 var version = this._manager.findVersion(versionId); 202 var version = this._manager.findVersion(versionId);
203 if (!version || !version.targetId) 203 if (!version || !version.targetId)
204 return null; 204 return null;
205 return this._subTargetsManager.targetForId(version.targetId); 205 return this._subTargetsManager.targetForId(version.targetId);
206 } 206 }
207 207
208 /** 208 /**
209 * @return {!Promise} 209 * @return {!Promise}
210 */ 210 */
211 _update() { 211 _update() {
212 var fingerprint = this._registration.fingerprint(); 212 var fingerprint = this._registration.fingerprint();
213 if (fingerprint === this._fingerprint) 213 if (fingerprint === this._fingerprint)
214 return Promise.resolve(); 214 return Promise.resolve();
215 this._fingerprint = fingerprint; 215 this._fingerprint = fingerprint;
216 216
217 this._toolbar.setEnabled(!this._registration.isDeleted); 217 this._toolbar.setEnabled(!this._registration.isDeleted);
218 218
219 var versions = this._registration.versionsByMode(); 219 var versions = this._registration.versionsByMode();
220 var title = this._registration.isDeleted ? WebInspector.UIString('%s - delet ed', this._registration.scopeURL) : 220 var title = this._registration.isDeleted ? Common.UIString('%s - deleted', t his._registration.scopeURL) :
221 this._registration.scopeURL; 221 this._registration.scopeURL;
222 this._section.setTitle(title); 222 this._section.setTitle(title);
223 223
224 var active = versions.get(WebInspector.ServiceWorkerVersion.Modes.Active); 224 var active = versions.get(SDK.ServiceWorkerVersion.Modes.Active);
225 var waiting = versions.get(WebInspector.ServiceWorkerVersion.Modes.Waiting); 225 var waiting = versions.get(SDK.ServiceWorkerVersion.Modes.Waiting);
226 var installing = versions.get(WebInspector.ServiceWorkerVersion.Modes.Instal ling); 226 var installing = versions.get(SDK.ServiceWorkerVersion.Modes.Installing);
227 227
228 var statusValue = this._wrapWidget(this._section.appendField(WebInspector.UI String('Status'))); 228 var statusValue = this._wrapWidget(this._section.appendField(Common.UIString ('Status')));
229 statusValue.removeChildren(); 229 statusValue.removeChildren();
230 var versionsStack = statusValue.createChild('div', 'service-worker-version-s tack'); 230 var versionsStack = statusValue.createChild('div', 'service-worker-version-s tack');
231 versionsStack.createChild('div', 'service-worker-version-stack-bar'); 231 versionsStack.createChild('div', 'service-worker-version-stack-bar');
232 232
233 if (active) { 233 if (active) {
234 var scriptElement = this._section.appendField(WebInspector.UIString('Sourc e')); 234 var scriptElement = this._section.appendField(Common.UIString('Source'));
235 scriptElement.removeChildren(); 235 scriptElement.removeChildren();
236 var fileName = WebInspector.ParsedURL.extractName(active.scriptURL); 236 var fileName = Common.ParsedURL.extractName(active.scriptURL);
237 scriptElement.appendChild(WebInspector.linkifyURLAsNode(active.scriptURL, fileName)); 237 scriptElement.appendChild(UI.linkifyURLAsNode(active.scriptURL, fileName)) ;
238 scriptElement.createChild('div', 'report-field-value-subtitle').textConten t = 238 scriptElement.createChild('div', 'report-field-value-subtitle').textConten t =
239 WebInspector.UIString('Received %s', new Date(active.scriptResponseTim e * 1000).toLocaleString()); 239 Common.UIString('Received %s', new Date(active.scriptResponseTime * 10 00).toLocaleString());
240 240
241 var activeEntry = versionsStack.createChild('div', 'service-worker-version '); 241 var activeEntry = versionsStack.createChild('div', 'service-worker-version ');
242 activeEntry.createChild('div', 'service-worker-active-circle'); 242 activeEntry.createChild('div', 'service-worker-active-circle');
243 activeEntry.createChild('span').textContent = 243 activeEntry.createChild('span').textContent =
244 WebInspector.UIString('#%s activated and is %s', active.id, active.run ningStatus); 244 Common.UIString('#%s activated and is %s', active.id, active.runningSt atus);
245 245
246 if (active.isRunning() || active.isStarting()) { 246 if (active.isRunning() || active.isStarting()) {
247 createLink(activeEntry, WebInspector.UIString('stop'), this._stopButtonC licked.bind(this, active.id)); 247 createLink(activeEntry, Common.UIString('stop'), this._stopButtonClicked .bind(this, active.id));
248 if (!this._targetForVersionId(active.id)) 248 if (!this._targetForVersionId(active.id))
249 createLink(activeEntry, WebInspector.UIString('inspect'), this._inspec tButtonClicked.bind(this, active.id)); 249 createLink(activeEntry, Common.UIString('inspect'), this._inspectButto nClicked.bind(this, active.id));
250 } else if (active.isStartable()) { 250 } else if (active.isStartable()) {
251 createLink(activeEntry, WebInspector.UIString('start'), this._startButto nClicked.bind(this)); 251 createLink(activeEntry, Common.UIString('start'), this._startButtonClick ed.bind(this));
252 } 252 }
253 253
254 var clientsList = this._wrapWidget(this._section.appendField(WebInspector. UIString('Clients'))); 254 var clientsList = this._wrapWidget(this._section.appendField(Common.UIStri ng('Clients')));
255 clientsList.removeChildren(); 255 clientsList.removeChildren();
256 this._section.setFieldVisible(WebInspector.UIString('Clients'), active.con trolledClients.length); 256 this._section.setFieldVisible(Common.UIString('Clients'), active.controlle dClients.length);
257 for (var client of active.controlledClients) { 257 for (var client of active.controlledClients) {
258 var clientLabelText = clientsList.createChild('div', 'service-worker-cli ent'); 258 var clientLabelText = clientsList.createChild('div', 'service-worker-cli ent');
259 if (this._clientInfoCache.has(client)) 259 if (this._clientInfoCache.has(client))
260 this._updateClientInfo( 260 this._updateClientInfo(
261 clientLabelText, /** @type {!WebInspector.TargetInfo} */ (this._cl ientInfoCache.get(client))); 261 clientLabelText, /** @type {!SDK.TargetInfo} */ (this._clientInfoC ache.get(client)));
262 this._subTargetsManager.getTargetInfo(client, this._onClientInfo.bind(th is, clientLabelText)); 262 this._subTargetsManager.getTargetInfo(client, this._onClientInfo.bind(th is, clientLabelText));
263 } 263 }
264 } 264 }
265 265
266 if (waiting) { 266 if (waiting) {
267 var waitingEntry = versionsStack.createChild('div', 'service-worker-versio n'); 267 var waitingEntry = versionsStack.createChild('div', 'service-worker-versio n');
268 waitingEntry.createChild('div', 'service-worker-waiting-circle'); 268 waitingEntry.createChild('div', 'service-worker-waiting-circle');
269 waitingEntry.createChild('span').textContent = WebInspector.UIString('#%s waiting to activate', waiting.id); 269 waitingEntry.createChild('span').textContent = Common.UIString('#%s waitin g to activate', waiting.id);
270 createLink(waitingEntry, WebInspector.UIString('skipWaiting'), this._skipB uttonClicked.bind(this)); 270 createLink(waitingEntry, Common.UIString('skipWaiting'), this._skipButtonC licked.bind(this));
271 waitingEntry.createChild('div', 'service-worker-subtitle').textContent = 271 waitingEntry.createChild('div', 'service-worker-subtitle').textContent =
272 new Date(waiting.scriptResponseTime * 1000).toLocaleString(); 272 new Date(waiting.scriptResponseTime * 1000).toLocaleString();
273 if (!this._targetForVersionId(waiting.id) && (waiting.isRunning() || waiti ng.isStarting())) 273 if (!this._targetForVersionId(waiting.id) && (waiting.isRunning() || waiti ng.isStarting()))
274 createLink(waitingEntry, WebInspector.UIString('inspect'), this._inspect ButtonClicked.bind(this, waiting.id)); 274 createLink(waitingEntry, Common.UIString('inspect'), this._inspectButton Clicked.bind(this, waiting.id));
275 } 275 }
276 if (installing) { 276 if (installing) {
277 var installingEntry = versionsStack.createChild('div', 'service-worker-ver sion'); 277 var installingEntry = versionsStack.createChild('div', 'service-worker-ver sion');
278 installingEntry.createChild('div', 'service-worker-installing-circle'); 278 installingEntry.createChild('div', 'service-worker-installing-circle');
279 installingEntry.createChild('span').textContent = WebInspector.UIString('# %s installing', installing.id); 279 installingEntry.createChild('span').textContent = Common.UIString('#%s ins talling', installing.id);
280 installingEntry.createChild('div', 'service-worker-subtitle').textContent = 280 installingEntry.createChild('div', 'service-worker-subtitle').textContent =
281 new Date(installing.scriptResponseTime * 1000).toLocaleString(); 281 new Date(installing.scriptResponseTime * 1000).toLocaleString();
282 if (!this._targetForVersionId(installing.id) && (installing.isRunning() || installing.isStarting())) 282 if (!this._targetForVersionId(installing.id) && (installing.isRunning() || installing.isStarting()))
283 createLink( 283 createLink(
284 installingEntry, WebInspector.UIString('inspect'), this._inspectButt onClicked.bind(this, installing.id)); 284 installingEntry, Common.UIString('inspect'), this._inspectButtonClic ked.bind(this, installing.id));
285 } 285 }
286 286
287 this._section.setFieldVisible(WebInspector.UIString('Errors'), !!this._regis tration.errors.length); 287 this._section.setFieldVisible(Common.UIString('Errors'), !!this._registratio n.errors.length);
288 var errorsValue = this._wrapWidget(this._section.appendField(WebInspector.UI String('Errors'))); 288 var errorsValue = this._wrapWidget(this._section.appendField(Common.UIString ('Errors')));
289 var errorsLabel = createLabel(String(this._registration.errors.length), 'sma llicon-error'); 289 var errorsLabel = createLabel(String(this._registration.errors.length), 'sma llicon-error');
290 errorsLabel.classList.add('service-worker-errors-label'); 290 errorsLabel.classList.add('service-worker-errors-label');
291 errorsValue.appendChild(errorsLabel); 291 errorsValue.appendChild(errorsLabel);
292 this._moreButton = createLink( 292 this._moreButton = createLink(
293 errorsValue, this._errorsList.classList.contains('hidden') ? WebInspecto r.UIString('details') : 293 errorsValue, this._errorsList.classList.contains('hidden') ? Common.UISt ring('details') :
294 WebInspecto r.UIString('hide'), 294 Common.UISt ring('hide'),
295 this._moreErrorsButtonClicked.bind(this)); 295 this._moreErrorsButtonClicked.bind(this));
296 createLink(errorsValue, WebInspector.UIString('clear'), this._clearErrorsBut tonClicked.bind(this)); 296 createLink(errorsValue, Common.UIString('clear'), this._clearErrorsButtonCli cked.bind(this));
297 297
298 /** 298 /**
299 * @param {!Element} parent 299 * @param {!Element} parent
300 * @param {string} title 300 * @param {string} title
301 * @param {function()} listener 301 * @param {function()} listener
302 * @return {!Element} 302 * @return {!Element}
303 */ 303 */
304 function createLink(parent, title, listener) { 304 function createLink(parent, title, listener) {
305 var span = parent.createChild('span', 'link'); 305 var span = parent.createChild('span', 'link');
306 span.textContent = title; 306 span.textContent = title;
(...skipping 29 matching lines...) Expand all
336 } 336 }
337 337
338 _syncButtonClicked() { 338 _syncButtonClicked() {
339 var tag = 'test-tag-from-devtools'; 339 var tag = 'test-tag-from-devtools';
340 var lastChance = true; 340 var lastChance = true;
341 this._manager.dispatchSyncEvent(this._registration.id, tag, lastChance); 341 this._manager.dispatchSyncEvent(this._registration.id, tag, lastChance);
342 } 342 }
343 343
344 /** 344 /**
345 * @param {!Element} element 345 * @param {!Element} element
346 * @param {?WebInspector.TargetInfo} targetInfo 346 * @param {?SDK.TargetInfo} targetInfo
347 */ 347 */
348 _onClientInfo(element, targetInfo) { 348 _onClientInfo(element, targetInfo) {
349 if (!targetInfo) 349 if (!targetInfo)
350 return; 350 return;
351 this._clientInfoCache.set(targetInfo.id, targetInfo); 351 this._clientInfoCache.set(targetInfo.id, targetInfo);
352 this._updateClientInfo(element, targetInfo); 352 this._updateClientInfo(element, targetInfo);
353 } 353 }
354 354
355 /** 355 /**
356 * @param {!Element} element 356 * @param {!Element} element
357 * @param {!WebInspector.TargetInfo} targetInfo 357 * @param {!SDK.TargetInfo} targetInfo
358 */ 358 */
359 _updateClientInfo(element, targetInfo) { 359 _updateClientInfo(element, targetInfo) {
360 if (!targetInfo.canActivate) { 360 if (!targetInfo.canActivate) {
361 element.createTextChild(targetInfo.title); 361 element.createTextChild(targetInfo.title);
362 return; 362 return;
363 } 363 }
364 element.removeChildren(); 364 element.removeChildren();
365 element.createTextChild(targetInfo.url); 365 element.createTextChild(targetInfo.url);
366 var focusLabel = element.createChild('label', 'link'); 366 var focusLabel = element.createChild('label', 'link');
367 focusLabel.createTextChild('focus'); 367 focusLabel.createTextChild('focus');
(...skipping 17 matching lines...) Expand all
385 385
386 /** 386 /**
387 * @param {string} versionId 387 * @param {string} versionId
388 */ 388 */
389 _stopButtonClicked(versionId) { 389 _stopButtonClicked(versionId) {
390 this._manager.stopWorker(versionId); 390 this._manager.stopWorker(versionId);
391 } 391 }
392 392
393 _moreErrorsButtonClicked() { 393 _moreErrorsButtonClicked() {
394 var newVisible = this._errorsList.classList.contains('hidden'); 394 var newVisible = this._errorsList.classList.contains('hidden');
395 this._moreButton.textContent = newVisible ? WebInspector.UIString('hide') : WebInspector.UIString('details'); 395 this._moreButton.textContent = newVisible ? Common.UIString('hide') : Common .UIString('details');
396 this._errorsList.classList.toggle('hidden', !newVisible); 396 this._errorsList.classList.toggle('hidden', !newVisible);
397 } 397 }
398 398
399 _clearErrorsButtonClicked() { 399 _clearErrorsButtonClicked() {
400 this._errorsList.removeChildren(); 400 this._errorsList.removeChildren();
401 this._registration.clearErrors(); 401 this._registration.clearErrors();
402 this._scheduleUpdate(); 402 this._scheduleUpdate();
403 if (!this._errorsList.classList.contains('hidden')) 403 if (!this._errorsList.classList.contains('hidden'))
404 this._moreErrorsButtonClicked(); 404 this._moreErrorsButtonClicked();
405 } 405 }
406 406
407 /** 407 /**
408 * @param {string} versionId 408 * @param {string} versionId
409 */ 409 */
410 _inspectButtonClicked(versionId) { 410 _inspectButtonClicked(versionId) {
411 this._manager.inspectWorker(versionId); 411 this._manager.inspectWorker(versionId);
412 } 412 }
413 413
414 /** 414 /**
415 * @param {!Element} container 415 * @param {!Element} container
416 * @return {!Element} 416 * @return {!Element}
417 */ 417 */
418 _wrapWidget(container) { 418 _wrapWidget(container) {
419 var shadowRoot = WebInspector.createShadowRootWithCoreStyles(container); 419 var shadowRoot = UI.createShadowRootWithCoreStyles(container);
420 WebInspector.appendStyle(shadowRoot, 'resources/serviceWorkersView.css'); 420 UI.appendStyle(shadowRoot, 'resources/serviceWorkersView.css');
421 var contentElement = createElement('div'); 421 var contentElement = createElement('div');
422 shadowRoot.appendChild(contentElement); 422 shadowRoot.appendChild(contentElement);
423 return contentElement; 423 return contentElement;
424 } 424 }
425 425
426 _dispose() { 426 _dispose() {
427 this._linkifier.dispose(); 427 this._linkifier.dispose();
428 if (this._pendingUpdate) 428 if (this._pendingUpdate)
429 clearTimeout(this._pendingUpdate); 429 clearTimeout(this._pendingUpdate);
430 } 430 }
431 }; 431 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698