| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 cr.define('serviceworker', function() { | 5 cr.define('serviceworker', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 function update() { | 8 function update() { |
| 9 chrome.send('getAllRegistrations'); | 9 chrome.send('getAllRegistrations'); |
| 10 } | 10 } |
| 11 | 11 |
| 12 function progressNodeFor(link) { | 12 function progressNodeFor(link) { |
| 13 return link.parentNode.querySelector('.operation-status'); | 13 return link.parentNode.querySelector('.operation-status'); |
| 14 } | 14 } |
| 15 | 15 |
| 16 // All commands are sent with the partition_path and scope, and | 16 // All commands are sent with the partition_path and scope, and |
| 17 // are all completed with 'onOperationComplete'. | 17 // are all completed with 'onOperationComplete'. |
| 18 var COMMANDS = ['unregister', 'start', 'stop']; | 18 var COMMANDS = ['unregister', 'start', 'stop', 'sync']; |
| 19 function commandHandler(command) { | 19 function commandHandler(command) { |
| 20 return function(event) { | 20 return function(event) { |
| 21 var link = event.target; | 21 var link = event.target; |
| 22 progressNodeFor(link).style.display = 'inline'; | 22 progressNodeFor(link).style.display = 'inline'; |
| 23 chrome.send(command, [link.partition_path, | 23 chrome.send(command, [link.partition_path, |
| 24 link.scope]); | 24 link.scope]); |
| 25 return false; | 25 return false; |
| 26 }; | 26 }; |
| 27 }; | 27 }; |
| 28 | 28 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 } | 79 } |
| 80 | 80 |
| 81 return { | 81 return { |
| 82 update: update, | 82 update: update, |
| 83 onOperationComplete: onOperationComplete, | 83 onOperationComplete: onOperationComplete, |
| 84 onPartitionData: onPartitionData, | 84 onPartitionData: onPartitionData, |
| 85 }; | 85 }; |
| 86 }); | 86 }); |
| 87 | 87 |
| 88 document.addEventListener('DOMContentLoaded', serviceworker.update); | 88 document.addEventListener('DOMContentLoaded', serviceworker.update); |
| OLD | NEW |