OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 chrome.runtime.onStartup.addListener( | 5 chrome.runtime.onStartup.addListener( |
6 function() { | 6 function() { |
7 chrome.alarms.create('hangout_services_fxpre', {'delayInMinutes': 2}); | 7 chrome.alarms.create('hangout_services_fxpre', {'delayInMinutes': 2}); |
8 }); | 8 }); |
9 | 9 |
10 chrome.alarms.onAlarm.addListener(function(alarm) { | 10 chrome.alarms.onAlarm.addListener(function(alarm) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 return true; | 112 return true; |
113 } else if (method == 'isExtensionEnabled') { | 113 } else if (method == 'isExtensionEnabled') { |
114 // This method is necessary because there may be more than one | 114 // This method is necessary because there may be more than one |
115 // version of this extension, under different extension IDs. By | 115 // version of this extension, under different extension IDs. By |
116 // first calling this method on the extension ID, the client can | 116 // first calling this method on the extension ID, the client can |
117 // check if it's loaded; if it's not, the extension system will | 117 // check if it's loaded; if it's not, the extension system will |
118 // call the callback with no arguments and set | 118 // call the callback with no arguments and set |
119 // chrome.runtime.lastError. | 119 // chrome.runtime.lastError. |
120 doSendResponse(); | 120 doSendResponse(); |
121 return false; | 121 return false; |
| 122 } else if (method == 'getNaclArchitecture') { |
| 123 chrome.runtime.getPlatformInfo(function(obj) { |
| 124 doSendResponse(obj.nacl_arch); |
| 125 }); |
| 126 return true; |
122 } | 127 } |
123 throw new Error('Unknown method: ' + method); | 128 throw new Error('Unknown method: ' + method); |
124 } catch (e) { | 129 } catch (e) { |
125 doSendResponse(null, e.name + ': ' + e.message); | 130 doSendResponse(null, e.name + ': ' + e.message); |
126 } | 131 } |
127 }); | 132 }); |
128 | 133 |
129 // If Hangouts connects with a port named 'onSinksChangedListener', we | 134 // If Hangouts connects with a port named 'onSinksChangedListener', we |
130 // will register a listener and send it a message {'eventName': | 135 // will register a listener and send it a message {'eventName': |
131 // 'onSinksChanged'} whenever the event fires. | 136 // 'onSinksChanged'} whenever the event fires. |
132 chrome.runtime.onConnectExternal.addListener( | 137 chrome.runtime.onConnectExternal.addListener( |
133 function(port) { | 138 function(port) { |
134 if (port.name == 'onSinksChangedListener') { | 139 if (port.name == 'onSinksChangedListener') { |
135 function clientListener() { | 140 function clientListener() { |
136 port.postMessage({'eventName': 'onSinksChanged'}); | 141 port.postMessage({'eventName': 'onSinksChanged'}); |
137 } | 142 } |
138 chrome.webrtcAudioPrivate.onSinksChanged.addListener(clientListener); | 143 chrome.webrtcAudioPrivate.onSinksChanged.addListener(clientListener); |
139 | 144 |
140 port.onDisconnect(function() { | 145 port.onDisconnect(function() { |
141 chrome.webrtcAudioPrivate.onSinksChanged.removeListener( | 146 chrome.webrtcAudioPrivate.onSinksChanged.removeListener( |
142 clientListener); | 147 clientListener); |
143 }); | 148 }); |
144 } | 149 } |
145 }); | 150 }); |
OLD | NEW |