Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / resources / inspect / inspect.js
index 437758e..3355967 100644 (file)
@@ -198,30 +198,6 @@ function populateRemoteTargets(devices) {
         device.adbConnected ? '' : 'Pending authentication: please accept ' +
           'debugging session on the device.';
 
-    var devicePorts = deviceSection.querySelector('.device-ports');
-    devicePorts.textContent = '';
-    if (device.adbPortStatus) {
-      for (var port in device.adbPortStatus) {
-        var status = device.adbPortStatus[port];
-        var portIcon = document.createElement('div');
-        portIcon.className = 'port-icon';
-        if (status > 0)
-          portIcon.classList.add('connected');
-        else if (status == -1 || status == -2)
-          portIcon.classList.add('transient');
-        else if (status < 0)
-          portIcon.classList.add('error');
-        devicePorts.appendChild(portIcon);
-
-        var portNumber = document.createElement('div');
-        portNumber.className = 'port-number';
-        portNumber.textContent = ':' + port;
-        if (status > 0)
-          portNumber.textContent += '(' + status + ')';
-        devicePorts.appendChild(portNumber);
-      }
-    }
-
     var browserList = deviceSection.querySelector('.browsers');
     var newBrowserIds =
         device.browsers.map(function(b) { return b.id });
@@ -516,6 +492,7 @@ function addTargetToList(data, list, properties) {
 function addActionLink(row, text, handler, opt_disabled) {
   var link = document.createElement('span');
   link.classList.add('action');
+  link.setAttribute('tabindex', 1);
   if (opt_disabled)
     link.classList.add('disabled');
   else
@@ -820,6 +797,55 @@ function commitFreshLineIfValid(opt_selectNew) {
   return true;
 }
 
+function populatePortStatus(devicesStatusMap) {
+  for (var deviceId in devicesStatusMap) {
+    if (!devicesStatusMap.hasOwnProperty(deviceId))
+      continue;
+    var deviceStatusMap = devicesStatusMap[deviceId];
+
+    var deviceSection = $(deviceId);
+    if (!deviceSection)
+      continue;
+
+    var devicePorts = deviceSection.querySelector('.device-ports');
+    devicePorts.textContent = '';
+    for (var port in deviceStatusMap) {
+      if (!deviceStatusMap.hasOwnProperty(port))
+        continue;
+
+      var status = deviceStatusMap[port];
+      var portIcon = document.createElement('div');
+      portIcon.className = 'port-icon';
+      // status === 0 is the default (connected) state.
+      // Positive values correspond to the tunnelling connection count
+      // (in DEBUG_DEVTOOLS mode).
+      if (status > 0)
+        portIcon.classList.add('connected');
+      else if (status === -1 || status === -2)
+        portIcon.classList.add('transient');
+      else if (status < 0)
+        portIcon.classList.add('error');
+      devicePorts.appendChild(portIcon);
+
+      var portNumber = document.createElement('div');
+      portNumber.className = 'port-number';
+      portNumber.textContent = ':' + port;
+      if (status > 0)
+        portNumber.textContent += '(' + status + ')';
+      devicePorts.appendChild(portNumber);
+    }
+  }
+
+  function clearPorts(deviceSection) {
+    if (deviceSection.id in devicesStatusMap)
+      return;
+    deviceSection.querySelector('.device-ports').textContent = '';
+  }
+
+  Array.prototype.forEach.call(
+      document.querySelectorAll('.device'), clearPorts);
+}
+
 document.addEventListener('DOMContentLoaded', onload);
 
 window.addEventListener('hashchange', onHashChange);