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

Side by Side Diff: Source/devtools/front_end/sources/ServiceWorkersSidebarPane.js

Issue 1172643002: DevTools: migrate sidebar pane's titleElement to use Toolbar. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebaselined Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
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 /** 5 /**
6 * @constructor 6 * @constructor
7 * @extends {WebInspector.SidebarPane} 7 * @extends {WebInspector.SidebarPane}
8 * @implements {WebInspector.TargetManager.Observer} 8 * @implements {WebInspector.TargetManager.Observer}
9 */ 9 */
10 WebInspector.ServiceWorkersSidebarPane = function() 10 WebInspector.ServiceWorkersSidebarPane = function()
11 { 11 {
12 WebInspector.SidebarPane.call(this, WebInspector.UIString("\u2699 Service Wo rkers")); 12 WebInspector.SidebarPane.call(this, WebInspector.UIString("\u2699 Service Wo rkers"));
13 this.registerRequiredCSS("sources/serviceWorkersSidebar.css"); 13 this.registerRequiredCSS("sources/serviceWorkersSidebar.css");
14 this._bodyElement = this.element.createChild("div", "vbox");
14 this.setVisible(false); 15 this.setVisible(false);
15 16
16 /** @type {?WebInspector.ServiceWorkerManager} */ 17 /** @type {?WebInspector.ServiceWorkerManager} */
17 this._manager = null; 18 this._manager = null;
18 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Type.Pag e); 19 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Type.Pag e);
19 this._placeholderElement = createElementWithClass("div", "info"); 20 this._placeholderElement = createElementWithClass("div", "info");
20 this._placeholderElement.textContent = WebInspector.UIString("No service wor kers control this page"); 21 this._placeholderElement.textContent = WebInspector.UIString("No service wor kers control this page");
21 } 22 }
22 23
23 WebInspector.ServiceWorkersSidebarPane.prototype = { 24 WebInspector.ServiceWorkersSidebarPane.prototype = {
(...skipping 16 matching lines...) Expand all
40 */ 41 */
41 targetRemoved: function(target) 42 targetRemoved: function(target)
42 { 43 {
43 target.serviceWorkerManager.removeEventListener(WebInspector.ServiceWork erManager.Events.WorkersUpdated, this._update, this); 44 target.serviceWorkerManager.removeEventListener(WebInspector.ServiceWork erManager.Events.WorkersUpdated, this._update, this);
44 this._updateVisibility(); 45 this._updateVisibility();
45 }, 46 },
46 47
47 _update: function() 48 _update: function()
48 { 49 {
49 this._updateVisibility(); 50 this._updateVisibility();
50 this.bodyElement.removeChildren(); 51 this._bodyElement.removeChildren();
51 52
52 if (!this.isShowing() || !this._manager) 53 if (!this.isShowing() || !this._manager)
53 return; 54 return;
54 55
55 if (!this._manager.hasWorkers()) { 56 if (!this._manager.hasWorkers()) {
56 this.bodyElement.appendChild(this._placeholderElement); 57 this._bodyElement.appendChild(this._placeholderElement);
57 return; 58 return;
58 } 59 }
59 60
60 for (var worker of this._manager.workers()) { 61 for (var worker of this._manager.workers()) {
61 var workerElement = this.bodyElement.createChild("div", "service-wor ker"); 62 var workerElement = this._bodyElement.createChild("div", "service-wo rker");
62 var leftBox = workerElement.createChild("div", "vbox flex-auto"); 63 var leftBox = workerElement.createChild("div", "vbox flex-auto");
63 leftBox.appendChild(WebInspector.linkifyURLAsNode(worker.url(), work er.name())); 64 leftBox.appendChild(WebInspector.linkifyURLAsNode(worker.url(), work er.name()));
64 var scopeElement = leftBox.createChild("span", "service-worker-scope "); 65 var scopeElement = leftBox.createChild("span", "service-worker-scope ");
65 scopeElement.textContent = worker.scope(); 66 scopeElement.textContent = worker.scope();
66 scopeElement.title = worker.scope(); 67 scopeElement.title = worker.scope();
67 workerElement.appendChild(createTextButton(WebInspector.UIString("Un register"), worker.stop.bind(worker))); 68 workerElement.appendChild(createTextButton(WebInspector.UIString("Un register"), worker.stop.bind(worker)));
68 } 69 }
69 }, 70 },
70 71
71 _updateVisibility: function() 72 _updateVisibility: function()
72 { 73 {
73 this._wasVisibleAtLeastOnce = this._wasVisibleAtLeastOnce || !!this._man ager && this._manager.hasWorkers(); 74 this._wasVisibleAtLeastOnce = this._wasVisibleAtLeastOnce || !!this._man ager && this._manager.hasWorkers();
74 this.setVisible(this._wasVisibleAtLeastOnce); 75 this.setVisible(this._wasVisibleAtLeastOnce);
75 }, 76 },
76 77
77 wasShown: function() 78 wasShown: function()
78 { 79 {
79 this._update(); 80 this._update();
80 }, 81 },
81 82
82 __proto__: WebInspector.SidebarPane.prototype 83 __proto__: WebInspector.SidebarPane.prototype
83 } 84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698