Chromium Code Reviews| Index: content/browser/resources/service_worker/serviceworker_internals.js |
| diff --git a/content/browser/resources/service_worker/serviceworker_internals.js b/content/browser/resources/service_worker/serviceworker_internals.js |
| index 1be184cf6fcc7e33dde303d9a0b560bda16e7719..67c55f9a2d75b9b98480c28ce8a7b091a4648f98 100644 |
| --- a/content/browser/resources/service_worker/serviceworker_internals.js |
| +++ b/content/browser/resources/service_worker/serviceworker_internals.js |
| @@ -5,6 +5,22 @@ |
| cr.define('serviceworker', function() { |
| 'use strict'; |
| + function initialize() { |
| + if (window.location.hash == "#iframe") { |
| + // This page is loaded from chrome://inspect. |
| + window.addEventListener('message', onMessage.bind(this), false); |
| + } |
| + update(); |
| + } |
| + |
| + function onMessage(event) { |
| + if (event.origin != 'chrome://inspect') { |
| + return; |
|
yurys
2014/05/23 09:22:41
style: wrong alignment
horo
2014/05/23 10:49:02
Done.
|
| + } |
| + chrome.send(event.data.action, |
| + [event.data.partition_path, event.data.scope]); |
| + } |
| + |
| function update() { |
| chrome.send('getAllRegistrations'); |
| } |
| @@ -48,8 +64,34 @@ cr.define('serviceworker', function() { |
| var allLogMessages = {}; |
| + // Send the active ServiceWorker information to chrome://inspect. |
| + function sendToInspectPage(registrations, partition_id, partition_path) { |
| + var workers = []; |
| + for (var i = 0; i < registrations.length; i++) { |
| + var registration = registrations[i]; |
|
yurys
2014/05/23 09:22:41
style: wrong alignment here and below.
horo
2014/05/23 10:49:02
Done.
|
| + if (!registration.active || |
| + registration.active.running_status != 'RUNNING') { |
| + continue; |
| + } |
| + workers.push({ |
| + 'partition_path': partition_path, |
| + 'scope': registration['scope'], |
| + 'url': registration['script_url'] |
| + }) |
| + } |
| + window.parent.postMessage({ |
| + 'partition_id': partition_id, |
| + 'workers': workers, |
| + }, 'chrome://inspect') |
| + } |
| + |
| // Fired once per partition from the backend. |
| function onPartitionData(registrations, partition_id, partition_path) { |
| + if (window.location.hash == "#iframe") { |
| + // This page is loaded from chrome://inspect. |
| + sendToInspectPage(registrations, partition_id, partition_path); |
| + return; |
| + } |
| var template; |
| var container = $('serviceworker-list'); |
| @@ -164,6 +206,7 @@ cr.define('serviceworker', function() { |
| } |
| return { |
| + initialize: initialize, |
| update: update, |
| onOperationComplete: onOperationComplete, |
| onPartitionData: onPartitionData, |
| @@ -177,4 +220,4 @@ cr.define('serviceworker', function() { |
| }; |
| }); |
| -document.addEventListener('DOMContentLoaded', serviceworker.update); |
| +document.addEventListener('DOMContentLoaded', serviceworker.initialize); |