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 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * | 7 * |
8 * In Chrome Apps, some platform APIs can only be called from the background | 8 * In Chrome Apps, some platform APIs can only be called from the background |
9 * page (e.g. reloading a chrome.app.AppWindow). Likewise, some chrome API's | 9 * page (e.g. reloading a chrome.app.AppWindow). Likewise, some chrome API's |
10 * must be initiated by user interaction, which can only be called from the | 10 * must be initiated by user interaction, which can only be called from the |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 } | 139 } |
140 }; | 140 }; |
141 | 141 |
142 /** | 142 /** |
143 * Invokes a method on a remote page | 143 * Invokes a method on a remote page |
144 * | 144 * |
145 * @param {string} methodName | 145 * @param {string} methodName |
146 * @param {...} var_args | 146 * @param {...} var_args |
147 * @return {Promise} A Promise that would resolve to the return value of the | 147 * @return {Promise} A Promise that would resolve to the return value of the |
148 * handler or reject if the handler throws an exception. | 148 * handler or reject if the handler throws an exception. |
| 149 * @suppress {reportUnknownTypes} |
149 */ | 150 */ |
150 base.Ipc.invoke = function(methodName, var_args) { | 151 base.Ipc.invoke = function(methodName, var_args) { |
151 var params = Array.prototype.slice.call(arguments, 1); | 152 var params = Array.prototype.slice.call(arguments, 1); |
152 var sendMessage = base.Promise.as( | 153 var sendMessage = base.Promise.as( |
153 chrome.runtime.sendMessage, | 154 chrome.runtime.sendMessage, |
154 [null, new base.Ipc.Request_(methodName, params)]); | 155 [null, new base.Ipc.Request_(methodName, params)]); |
155 | 156 |
156 return sendMessage.then( | 157 return sendMessage.then( |
157 /** @param {?{error: Error}} response */ | 158 /** @param {?{error: Error}} response */ |
158 function(response) { | 159 function(response) { |
(...skipping 18 matching lines...) Expand all Loading... |
177 }; | 178 }; |
178 | 179 |
179 base.Ipc.deleteInstance = function() { | 180 base.Ipc.deleteInstance = function() { |
180 if (instance_) { | 181 if (instance_) { |
181 instance_.dispose_(); | 182 instance_.dispose_(); |
182 instance_ = null; | 183 instance_ = null; |
183 } | 184 } |
184 }; | 185 }; |
185 | 186 |
186 })(); | 187 })(); |
OLD | NEW |