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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 } | 82 } |
83 | 83 |
84 return { | 84 return { |
85 update: update, | 85 update: update, |
86 onOperationComplete: onOperationComplete, | 86 onOperationComplete: onOperationComplete, |
87 onPartitionData: onPartitionData, | 87 onPartitionData: onPartitionData, |
88 }; | 88 }; |
89 }); | 89 }); |
90 | 90 |
91 document.addEventListener('DOMContentLoaded', serviceworker.update); | 91 document.addEventListener('DOMContentLoaded', serviceworker.update); |
OLD | NEW |