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 | 9 |
10 function inspect(data) { | 10 function inspect(data) { |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 pageList.className = 'list pages'; | 271 pageList.className = 'list pages'; |
272 browserSection.appendChild(pageList); | 272 browserSection.appendChild(pageList); |
273 } | 273 } |
274 | 274 |
275 if (alreadyDisplayed(browserSection, browser)) | 275 if (alreadyDisplayed(browserSection, browser)) |
276 continue; | 276 continue; |
277 | 277 |
278 pageList.textContent = ''; | 278 pageList.textContent = ''; |
279 for (var p = 0; p < browser.pages.length; p++) { | 279 for (var p = 0; p < browser.pages.length; p++) { |
280 var page = browser.pages[p]; | 280 var page = browser.pages[p]; |
281 // Attached targets have no unique id until Chrome 26. | 281 // Attached targets have no unique id until Chrome 26. For such targets |
282 // For such targets it is impossible: | 282 // it is impossible to activate existing DevTools window. |
283 // - to issue 'close' command, | 283 page.hasNoUniqueId = page.attached && |
284 // - to activate existing DevTools window. | 284 majorChromeVersion < MIN_VERSION_TARGET_ID; |
285 page.hasUniqueId = !page.attached || | |
286 majorChromeVersion >= MIN_VERSION_TARGET_ID; | |
287 var row = addTargetToList( | 285 var row = addTargetToList( |
288 page, pageList, ['faviconUrl', 'name', 'url', 'description']); | 286 page, pageList, ['faviconUrl', 'name', 'url', 'description']); |
289 if (isChrome) { | 287 if (isChrome) { |
290 if (majorChromeVersion >= MIN_VERSION_TAB_ACTIVATE) { | 288 if (majorChromeVersion >= MIN_VERSION_TAB_ACTIVATE) { |
291 row.appendChild(createActionLink( | 289 row.appendChild(createActionLink( |
292 'activate', activate.bind(null, page), false)); | 290 'activate', activate.bind(null, page), false)); |
293 } | 291 } |
294 row.appendChild(createActionLink( | 292 row.appendChild(createActionLink( |
295 'reload', reload.bind(null, page), page.attached)); | 293 'reload', reload.bind(null, page), page.attached)); |
296 if (majorChromeVersion >= MIN_VERSION_TAB_CLOSE) { | 294 if (majorChromeVersion >= MIN_VERSION_TAB_CLOSE) { |
297 row.appendChild(createActionLink( | 295 row.appendChild(createActionLink( |
298 'close', | 296 'close', terminate.bind(null, page), page.attached)); |
299 terminate.bind(null, page), | |
300 page.attached || !page.hasUniqueId)); | |
301 } | 297 } |
302 } | 298 } |
303 } | 299 } |
304 } | 300 } |
305 } | 301 } |
306 } | 302 } |
307 | 303 |
308 function addToPagesList(data) { | 304 function addToPagesList(data) { |
309 addTargetToList(data, $('pages-list'), ['faviconUrl', 'name', 'url']); | 305 addTargetToList(data, $('pages-list'), ['faviconUrl', 'name', 'url']); |
310 } | 306 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 try { | 391 try { |
396 description = JSON.parse(data['description']); | 392 description = JSON.parse(data['description']); |
397 } catch (e) {} | 393 } catch (e) {} |
398 } | 394 } |
399 } | 395 } |
400 | 396 |
401 if (description) | 397 if (description) |
402 addWebViewDescription(description, row); | 398 addWebViewDescription(description, row); |
403 | 399 |
404 row.appendChild(createActionLink( | 400 row.appendChild(createActionLink( |
405 'inspect', inspect.bind(null, data), !data.hasUniqueId)); | 401 'inspect', inspect.bind(null, data), data.hasNoUniqueId)); |
406 | 402 |
407 list.appendChild(row); | 403 list.appendChild(row); |
408 return row; | 404 return row; |
409 } | 405 } |
410 | 406 |
411 function createActionLink(text, handler, opt_disabled) { | 407 function createActionLink(text, handler, opt_disabled) { |
412 var link = document.createElement('a'); | 408 var link = document.createElement('a'); |
413 if (opt_disabled) | 409 if (opt_disabled) |
414 link.classList.add('disabled'); | 410 link.classList.add('disabled'); |
415 else | 411 else |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 if (line.querySelector('.invalid')) | 642 if (line.querySelector('.invalid')) |
647 return; | 643 return; |
648 line.classList.remove('fresh'); | 644 line.classList.remove('fresh'); |
649 var freshLine = createEmptyConfigLine(); | 645 var freshLine = createEmptyConfigLine(); |
650 line.parentNode.appendChild(freshLine); | 646 line.parentNode.appendChild(freshLine); |
651 if (opt_selectNew) | 647 if (opt_selectNew) |
652 freshLine.querySelector('.port').focus(); | 648 freshLine.querySelector('.port').focus(); |
653 } | 649 } |
654 | 650 |
655 document.addEventListener('DOMContentLoaded', onload); | 651 document.addEventListener('DOMContentLoaded', onload); |
OLD | NEW |