Chromium Code Reviews| Index: src/js/polyfills/runtime.polyfill.js |
| diff --git a/src/js/polyfills/runtime.polyfill.js b/src/js/polyfills/runtime.polyfill.js |
| index 46a82ea0753b3d52c9697f3e97d78f9f1e4a240f..3fe8bdfede0063be726924514251647f1583c248 100644 |
| --- a/src/js/polyfills/runtime.polyfill.js |
| +++ b/src/js/polyfills/runtime.polyfill.js |
| @@ -13,16 +13,34 @@ |
| // limitations under the License. |
| /** |
| - * Polyfill for Chrome Apps' runtime API. |
| + * Polyfill for the Chrome Apps runtime API. |
| */ |
| +(function() { |
| + |
| 'use strict'; |
|
raymes
2016/02/10 23:10:35
nit: just move this above function()
Matthew Alger
2016/02/11 00:15:55
Are you sure? This will be included along with oth
raymes
2016/02/11 05:28:29
I'm not sure that is true. I think it should only
Matthew Alger
2016/02/11 22:41:26
Hmm, okay, maybe I'm misreading MDN. I'll update i
|
| // Add namespaces for the polyfill if they don't already exist. |
| if (!chrome.runtime) |
| chrome.runtime = {}; |
| -(function() { |
| +/** |
| + * Not implemented. |
| + */ |
| +chrome.runtime.Port = class { |
| + constructor() { |
| + throw new Error('Port not implemented.'); |
| + } |
| +}; |
| + |
| +/** |
| + * Not implemented. |
| + */ |
| +chrome.runtime.MessageSender = class { |
| + constructor() { |
| + throw new Error('MessageSender not implemented.'); |
| + } |
| +}; |
| /** |
| * The operating system the browser is running on. |
| @@ -123,7 +141,7 @@ chrome.runtime.getBackgroundPage = function(callback) { |
| * |
| * Always sets an error in lastError since this isn't an extension. |
| * |
| - * @param {function} opt_callback Callback function on success or error. |
| + * @param {function=} opt_callback Callback function on success or error. |
| */ |
| chrome.runtime.openOptionsPage = function(opt_callback) { |
| caterpillar_.setError('Could not create an options page.'); |
| @@ -145,13 +163,20 @@ chrome.runtime.getManifest = function() { |
| }; |
| /** |
| + * Not implemented. |
| + */ |
| +chrome.runtime.getURL = function() { |
| + throw new Error('getURL not implemented.'); |
| +}; |
| + |
| +/** |
| * Sets the URL to be visited upon uninstallation. |
| * |
| * Does nothing but call the callback, since there is no uninstallation event |
| * for a progressive web app. |
| * |
| * @param {string} url URL to visit upon uninstallation. |
| - * @param {function} opt_callback Callback function on success or error. |
| + * @param {function=} opt_callback Callback function on success or error. |
| */ |
| chrome.runtime.setUninstallURL = function(url, opt_callback) { |
| if (opt_callback) |
| @@ -200,6 +225,20 @@ chrome.runtime.connectNative = function() { |
| }; |
| /** |
| + * Not implemented. |
| + */ |
| +chrome.runtime.sendMessage = function() { |
| + throw new Error('sendMessage not implemented.'); |
| +}; |
| + |
| +/** |
| + * Not implemented. |
| + */ |
| +chrome.runtime.sendNativeMessage = function() { |
| + throw new Error('sendNativeMessage not implemented.'); |
| +}; |
| + |
| +/** |
| * Gets information about the current operating system. |
| * |
| * @param {function} callback Function taking PlatformInfo. |
| @@ -207,8 +246,8 @@ chrome.runtime.connectNative = function() { |
| chrome.runtime.getPlatformInfo = function(callback) { |
| // Here, we use platform.js to guess a reasonable value for the platform |
| // information expected by Chrome Apps. This is pretty hard since we can't |
| - // make the same guarantees a Chrome App can about the open web, so this is |
| - // a "best guess". |
| + // make the same guarantees a Chrome App can about the open web, so this is a |
| + // "best guess". |
| // We need to guess: android, cros, linux, mac, openbsd, win |
| // We also need to guess: x86-64, x86-32, arm |
| @@ -241,22 +280,53 @@ chrome.runtime.getPackageDirectoryEntry = function() { |
| throw new Error('getPackageDirectoryEntry not implemented.'); |
| }; |
| -// TODO(alger): Implement or stub Port. |
| -// TODO(alger): Implement or stub MessageSender. |
| -// TODO(alger): Implement or stub sendMessage. |
| -// TODO(alger): Implement or stub getURL. |
| -// TODO(alger): Implement or stub sendMessage. |
| -// TODO(alger): Implement or stub sendNativeMessage. |
| -// TODO(alger): Implement or stub onStartup. |
| -// TODO(alger): Implement or stub onInstalled. |
| -// TODO(alger): Implement or stub onSuspend. |
| -// TODO(alger): Implement or stub onSuspendCanceled. |
| -// TODO(alger): Implement or stub onUpdateAvailable. |
| -// TODO(alger): Implement or stub onBrowserUpdateAvailable. |
| -// TODO(alger): Implement or stub onConnect. |
| -// TODO(alger): Implement or stub onConnectExternal. |
| -// TODO(alger): Implement or stub onMessage. |
| -// TODO(alger): Implement or stub onMessageExternal. |
| -// TODO(alger): Implement or stub onRestartRequired. |
| +/** |
| + * Not implemented events. All addListener methods for not implemented events |
| + * have been stubbed in this polyfill. |
| + */ |
| + |
| +chrome.runtime.onStartup = { |
| + addListener: function() {} |
| +}; |
| + |
| +chrome.runtime.onInstalled = { |
| + addListener: function() {} |
| +}; |
| + |
| +chrome.runtime.onSuspend = { |
| + addListener: function() {} |
| +}; |
| + |
| +chrome.runtime.onSuspendCanceled = { |
| + addListener: function() {} |
| +}; |
| + |
| +chrome.runtime.onUpdateAvailable = { |
| + addListener: function() {} |
| +}; |
| + |
| +chrome.runtime.onBrowserUpdateAvailable = { |
| + addListener: function() {} |
| +}; |
| + |
| +chrome.runtime.onConnect = { |
| + addListener: function() {} |
| +}; |
| + |
| +chrome.runtime.onConnectExternal = { |
| + addListener: function() {} |
| +}; |
| + |
| +chrome.runtime.onMessage = { |
| + addListener: function() {} |
| +}; |
| + |
| +chrome.runtime.onMessageExternal = { |
| + addListener: function() {} |
| +}; |
| + |
| +chrome.runtime.onRestartRequired = { |
| + addListener: function() {} |
|
raymes
2016/02/10 23:10:35
Should these throw an exception too?
Matthew Alger
2016/02/11 00:15:55
Yes. Done.
|
| +}; |
| }).call(this); |