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

Unified Diff: Source/devtools/front_end/main/AdvancedApp.js

Issue 408853002: [DevTools] Make toolbar counters declarative. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/main/AdvancedApp.js
diff --git a/Source/devtools/front_end/main/AdvancedApp.js b/Source/devtools/front_end/main/AdvancedApp.js
index 30aee9156f90f269dd764102d65748bb338a1027..93e2767bb9628247d78e52320d1b5ee9566acebe 100644
--- a/Source/devtools/front_end/main/AdvancedApp.js
+++ b/Source/devtools/front_end/main/AdvancedApp.js
@@ -163,6 +163,49 @@ WebInspector.AdvancedApp.prototype = {
/**
* @constructor
+ * @implements {WebInspector.StatusBarItem.Provider}
+ */
+WebInspector.AdvancedApp.DeviceCounter = function()
+{
+ if (!WebInspector.experimentsSettings.devicesPanel.isEnabled() || !(WebInspector.app instanceof WebInspector.AdvancedApp)) {
+ this._counter = null;
+ return;
+ }
+
+ this._counter = new WebInspector.StatusBarCounter(["device-icon-small"]);
+ this._counter.addEventListener("click", showDevices);
+
+ function showDevices()
+ {
+ WebInspector.inspectorView.showViewInDrawer("devices", true);
+ }
+
+ InspectorFrontendHost.setDeviceCountUpdatesEnabled(true);
+ InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Events.DeviceCountUpdated, this._onDeviceCountUpdated, this);
+}
+
+WebInspector.AdvancedApp.DeviceCounter.prototype = {
+ /**
+ * @param {!WebInspector.Event} event
+ */
+ _onDeviceCountUpdated: function(event)
+ {
+ var count = /** @type {number} */ (event.data);
+ this._counter.setCounter("device-icon-small", count, WebInspector.UIString(((count > 1) ? "%d devices found" : "%d device found"), count));
apavlov 2014/07/21 13:34:06 the parentheses around (count > 1) are not require
dgozman 2014/07/21 14:24:34 Done.
+ WebInspector.inspectorView.toolbarItemResized();
+ },
+
+ /**
+ * @return {?WebInspector.StatusBarItem}
+ */
+ item: function()
+ {
+ return this._counter;
+ }
+}
+
+/**
+ * @constructor
*/
WebInspector.Toolbox = function()
{

Powered by Google App Engine
This is Rietveld 408576698