| 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 // require cr.js | 5 // require cr.js |
| 6 // require cr/event_target.js | 6 // require cr/event_target.js |
| 7 // require cr/util.js | 7 // require cr/util.js |
| 8 | 8 |
| 9 cr.define('chrome.sync', function() { | 9 cr.define('chrome.sync', function() { |
| 10 'use strict'; | 10 'use strict'; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 * @param {string} name The name of the event type. | 76 * @param {string} name The name of the event type. |
| 77 * @param {!Object} details A collection of event-specific details. | 77 * @param {!Object} details A collection of event-specific details. |
| 78 */ | 78 */ |
| 79 var dispatchEvent = function(name, details) { | 79 var dispatchEvent = function(name, details) { |
| 80 var e = new Event(name); | 80 var e = new Event(name); |
| 81 e.details = details; | 81 e.details = details; |
| 82 chrome.sync.events.dispatchEvent(e); | 82 chrome.sync.events.dispatchEvent(e); |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 /** | 85 /** |
| 86 * Registers to receive a stream of events through |
| 87 * chrome.sync.dispatchEvent(). |
| 88 */ |
| 89 var registerForEvents = function() { |
| 90 chrome.send('registerForEvents'); |
| 91 }; |
| 92 |
| 93 /** |
| 86 * Asks the browser to refresh our snapshot of sync state. Should result | 94 * Asks the browser to refresh our snapshot of sync state. Should result |
| 87 * in an onAboutInfoUpdated event being emitted. | 95 * in an onAboutInfoUpdated event being emitted. |
| 88 */ | 96 */ |
| 89 var requestUpdatedAboutInfo = function() { | 97 var requestUpdatedAboutInfo = function() { |
| 90 chrome.send('requestUpdatedAboutInfo'); | 98 chrome.send('requestUpdatedAboutInfo'); |
| 91 }; | 99 }; |
| 92 | 100 |
| 93 /** | 101 /** |
| 94 * Asks the browser to send us the list of registered types. Should result | 102 * Asks the browser to send us the list of registered types. Should result |
| 95 * in an onReceivedListOfTypes event being emitted. | 103 * in an onReceivedListOfTypes event being emitted. |
| 96 */ | 104 */ |
| 97 var requestListOfTypes = function() { | 105 var requestListOfTypes = function() { |
| 98 chrome.send('requestListOfTypes'); | 106 chrome.send('requestListOfTypes'); |
| 99 }; | 107 }; |
| 100 | 108 |
| 101 return { | 109 return { |
| 102 makeTimer: makeTimer, | 110 makeTimer: makeTimer, |
| 103 dispatchEvent: dispatchEvent, | 111 dispatchEvent: dispatchEvent, |
| 104 events: new cr.EventTarget(), | 112 events: new cr.EventTarget(), |
| 105 | 113 |
| 114 registerForEvents: registerForEvents, |
| 106 requestUpdatedAboutInfo: requestUpdatedAboutInfo, | 115 requestUpdatedAboutInfo: requestUpdatedAboutInfo, |
| 107 requestListOfTypes: requestListOfTypes, | 116 requestListOfTypes: requestListOfTypes, |
| 108 }; | 117 }; |
| 109 }); | 118 }); |
| OLD | NEW |