Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 var MIN_VERSION_TAB_CLOSE = 25; | 5 var MIN_VERSION_TAB_CLOSE = 25; |
| 6 var MIN_VERSION_TARGET_ID = 26; | 6 var MIN_VERSION_TARGET_ID = 26; |
| 7 var MIN_VERSION_NEW_TAB = 29; | 7 var MIN_VERSION_NEW_TAB = 29; |
| 8 var MIN_VERSION_TAB_ACTIVATE = 30; | 8 var MIN_VERSION_TAB_ACTIVATE = 30; |
| 9 var WEBRTC_SERIAL = 'WEBRTC'; | 9 var WEBRTC_SERIAL = 'WEBRTC'; |
| 10 | 10 |
| 11 var queryParamsObject = {}; | 11 var queryParamsObject = {}; |
| 12 | 12 |
| 13 (function() { | 13 (function() { |
| 14 var queryParams = window.location.search; | 14 var queryParams = window.location.search; |
| 15 if (!queryParams) | 15 if (!queryParams) |
| 16 return; | 16 return; |
| 17 var params = queryParams.substring(1).split('&'); | 17 var params = queryParams.substring(1).split('&'); |
| 18 for (var i = 0; i < params.length; ++i) { | 18 for (var i = 0; i < params.length; ++i) { |
| 19 var pair = params[i].split('='); | 19 var pair = params[i].split('='); |
| 20 queryParamsObject[pair[0]] = pair[1]; | 20 queryParamsObject[pair[0]] = pair[1]; |
| 21 } | 21 } |
| 22 | 22 |
| 23 })(); | 23 })(); |
| 24 | 24 |
| 25 var browserInspector; | |
| 26 var browserInspectorTitle; | |
| 27 if ('trace' in queryParamsObject || 'tracing' in queryParamsObject) { | |
|
dgozman
2015/01/14 14:12:01
Move the code inside anonymous function above.
vkuzkokov
2015/01/14 15:01:21
Done.
| |
| 28 browserInspector = 'chrome://tracing'; | |
| 29 browserInspectorTitle = 'trace'; | |
| 30 } else { | |
| 31 browserInspector = queryParamsObject['browser-inspector']; | |
| 32 browserInspectorTitle = 'inspect'; | |
| 33 } | |
| 34 | |
| 25 function sendCommand(command, args) { | 35 function sendCommand(command, args) { |
| 26 chrome.send(command, Array.prototype.slice.call(arguments, 1)); | 36 chrome.send(command, Array.prototype.slice.call(arguments, 1)); |
| 27 } | 37 } |
| 28 | 38 |
| 29 function sendTargetCommand(command, target) { | 39 function sendTargetCommand(command, target) { |
| 30 sendCommand(command, target.source, target.id); | 40 sendCommand(command, target.source, target.id); |
| 31 } | 41 } |
| 32 | 42 |
| 33 function removeChildren(element_id) { | 43 function removeChildren(element_id) { |
| 34 var element = $(element_id); | 44 var element = $(element_id); |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 | 299 |
| 290 if (incompatibleVersion) { | 300 if (incompatibleVersion) { |
| 291 var warningSection = document.createElement('div'); | 301 var warningSection = document.createElement('div'); |
| 292 warningSection.className = 'warning'; | 302 warningSection.className = 'warning'; |
| 293 warningSection.textContent = | 303 warningSection.textContent = |
| 294 'You may need a newer version of desktop Chrome. ' + | 304 'You may need a newer version of desktop Chrome. ' + |
| 295 'Please try Chrome ' + browser.adbBrowserVersion + ' or later.'; | 305 'Please try Chrome ' + browser.adbBrowserVersion + ' or later.'; |
| 296 browserSection.appendChild(warningSection); | 306 browserSection.appendChild(warningSection); |
| 297 } | 307 } |
| 298 | 308 |
| 299 var browserInspector; | |
| 300 var browserInspectorTitle; | |
| 301 if ('trace' in queryParamsObject || 'tracing' in queryParamsObject) { | |
| 302 browserInspector = 'chrome://tracing'; | |
| 303 browserInspectorTitle = 'trace'; | |
| 304 } else { | |
| 305 browserInspector = queryParamsObject['browser-inspector']; | |
| 306 browserInspectorTitle = 'inspect'; | |
| 307 } | |
| 308 if (browserInspector) { | 309 if (browserInspector) { |
| 309 var link = document.createElement('span'); | 310 var link = document.createElement('span'); |
| 310 link.classList.add('action'); | 311 link.classList.add('action'); |
| 311 link.setAttribute('tabindex', 1); | 312 link.setAttribute('tabindex', 1); |
| 312 link.textContent = browserInspectorTitle; | 313 link.textContent = browserInspectorTitle; |
| 313 browserHeader.appendChild(link); | 314 browserHeader.appendChild(link); |
| 314 link.addEventListener( | 315 link.addEventListener( |
| 315 'click', | 316 'click', |
| 316 sendCommand.bind(null, 'inspect-browser', browser.source, | 317 sendCommand.bind(null, 'inspect-browser', browser.source, |
| 317 browser.id, browserInspector), false); | 318 browser.id, browserInspector), false); |
| 318 } | 319 } |
| 319 | 320 |
| 320 pageList = document.createElement('div'); | 321 pageList = document.createElement('div'); |
| 321 pageList.className = 'list pages'; | 322 pageList.className = 'list pages'; |
| 322 browserSection.appendChild(pageList); | 323 browserSection.appendChild(pageList); |
| 323 } | 324 } |
| 324 | 325 |
| 326 var portForwardingIcon = | |
| 327 browserSection.querySelector('.used-for-port-forwarding'); | |
| 328 | |
| 329 browserSection.hidden = majorChromeVersion === 0 && | |
| 330 browser.pages.length === 0 && | |
| 331 !browserInspector && | |
| 332 portForwardingIcon.hidden; | |
| 333 | |
| 325 if (incompatibleVersion || alreadyDisplayed(browserSection, browser)) | 334 if (incompatibleVersion || alreadyDisplayed(browserSection, browser)) |
| 326 continue; | 335 continue; |
| 327 | 336 |
| 328 pageList.textContent = ''; | 337 pageList.textContent = ''; |
| 329 for (var p = 0; p < browser.pages.length; p++) { | 338 for (var p = 0; p < browser.pages.length; p++) { |
| 330 var page = browser.pages[p]; | 339 var page = browser.pages[p]; |
| 331 // Attached targets have no unique id until Chrome 26. For such targets | 340 // Attached targets have no unique id until Chrome 26. For such targets |
| 332 // it is impossible to activate existing DevTools window. | 341 // it is impossible to activate existing DevTools window. |
| 333 page.hasNoUniqueId = page.attached && | 342 page.hasNoUniqueId = page.attached && |
| 334 (majorChromeVersion && majorChromeVersion < MIN_VERSION_TARGET_ID); | 343 (majorChromeVersion && majorChromeVersion < MIN_VERSION_TARGET_ID); |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 900 | 909 |
| 901 var portNumber = document.createElement('div'); | 910 var portNumber = document.createElement('div'); |
| 902 portNumber.className = 'port-number'; | 911 portNumber.className = 'port-number'; |
| 903 portNumber.textContent = ':' + port; | 912 portNumber.textContent = ':' + port; |
| 904 if (status > 0) | 913 if (status > 0) |
| 905 portNumber.textContent += '(' + status + ')'; | 914 portNumber.textContent += '(' + status + ')'; |
| 906 devicePorts.appendChild(portNumber); | 915 devicePorts.appendChild(portNumber); |
| 907 } | 916 } |
| 908 | 917 |
| 909 function updatePortForwardingInfo(browserSection) { | 918 function updatePortForwardingInfo(browserSection) { |
| 919 browserSection.hidden = !browserSection.querySelector('.open') && | |
|
dgozman
2015/01/14 14:12:01
Please use the single function to update browserSe
vkuzkokov
2015/01/14 15:01:21
Done.
| |
| 920 !browserSection.querySelector('.page') && | |
| 921 !browserInspector && | |
| 922 browserSection.id !== deviceStatus.browserId; | |
| 910 var icon = browserSection.querySelector('.used-for-port-forwarding'); | 923 var icon = browserSection.querySelector('.used-for-port-forwarding'); |
| 911 if (icon) | 924 if (icon) |
| 912 icon.hidden = (browserSection.id !== deviceStatus.browserId); | 925 icon.hidden = (browserSection.id !== deviceStatus.browserId); |
| 913 } | 926 } |
| 914 | 927 |
| 915 Array.prototype.forEach.call( | 928 Array.prototype.forEach.call( |
| 916 deviceSection.querySelectorAll('.browser'), updatePortForwardingInfo); | 929 deviceSection.querySelectorAll('.browser'), updatePortForwardingInfo); |
| 917 } | 930 } |
| 918 | 931 |
| 919 function clearPorts(deviceSection) { | 932 function clearPorts(deviceSection) { |
| 920 if (deviceSection.id in devicesStatusMap) | 933 if (deviceSection.id in devicesStatusMap) |
| 921 return; | 934 return; |
| 922 deviceSection.querySelector('.device-ports').textContent = ''; | 935 deviceSection.querySelector('.device-ports').textContent = ''; |
| 923 } | 936 } |
| 924 | 937 |
| 925 Array.prototype.forEach.call( | 938 Array.prototype.forEach.call( |
| 926 document.querySelectorAll('.device'), clearPorts); | 939 document.querySelectorAll('.device'), clearPorts); |
| 927 } | 940 } |
| 928 | 941 |
| 929 document.addEventListener('DOMContentLoaded', onload); | 942 document.addEventListener('DOMContentLoaded', onload); |
| 930 | 943 |
| 931 window.addEventListener('hashchange', onHashChange); | 944 window.addEventListener('hashchange', onHashChange); |
| OLD | NEW |