Chromium Code Reviews| Index: src/js/caterpillar.js |
| diff --git a/src/js/caterpillar.js b/src/js/caterpillar.js |
| index 1be41a5b466d995c619c82343cc035b3b321fc75..7ae0f1940cfc08603ccb3ecde735b1dbc8b19886 100644 |
| --- a/src/js/caterpillar.js |
| +++ b/src/js/caterpillar.js |
| @@ -27,6 +27,22 @@ if (!('chrome' in self)) |
| if (!chrome.caterpillar) |
| chrome.caterpillar = {}; |
| +// We need the chrome.runtime namespace to store errors in. |
| +if (!chrome.runtime) |
| + chrome.runtime = { lastError: null }; |
| + |
| +// Stub out chrome.app.runtime.onLaunched.addListener, since this always appears |
| +// in Chrome Apps. |
|
raymes
2016/01/31 23:44:37
I'm not sure what this comment means? Why is it st
Matthew Alger
2016/02/01 00:14:33
chrome.app.runtime.onLaunched.addListener is used
raymes
2016/02/01 00:18:44
Could you make the comment say something like this
Matthew Alger
2016/02/01 00:36:52
Done.
|
| +if (!chrome.app) |
|
Matthew Alger
2016/01/28 04:51:41
Note that Chrome exports chrome.app, so we can't j
raymes
2016/01/31 23:44:37
Could we just always override onLaunched? (do we r
Matthew Alger
2016/02/01 00:14:33
It's not obvious to me that Chrome doesn't/won't e
raymes
2016/02/01 00:18:44
Why not override it? :) I think we had a similar d
Matthew Alger
2016/02/01 00:36:52
Hmmm, okay. Done.
(Though if a chrome.app.runtime
|
| + chrome.app = {}; |
| +if (!chrome.app.runtime) |
| + chrome.app.runtime = {}; |
| +if (!chrome.app.runtime.onLaunched) { |
| + chrome.app.runtime.onLaunched = { |
| + addListener: function() {}, |
| + }; |
| +} |
|
raymes
2016/01/31 23:44:37
Why did this code need to be moved?
Matthew Alger
2016/02/01 00:14:33
- It's static, so I think it should go in a static
raymes
2016/02/01 00:18:44
Sounds good - this would be useful context to have
Matthew Alger
2016/02/01 00:36:52
Done.
|
| + |
| (function() { |
| /** |
| @@ -38,11 +54,8 @@ if (!chrome.caterpillar) |
| * runtime isn't loaded. |
| */ |
| chrome.caterpillar.setError = function(message) { |
| - if (!chrome.runtime) { |
| - console.warn('chrome.runtime not found; runtime errors may not be caught.'); |
| - throw new Error(message); |
| - } |
| + console.warn('Error set in lastError:', message); |
|
raymes
2016/01/31 23:44:37
Do we need to log warnings every time?
Matthew Alger
2016/02/01 00:14:33
Hmm, I'm not sure. I don't think it really matters
raymes
2016/02/01 00:18:44
I think removing it is ok.
Matthew Alger
2016/02/01 00:36:52
Done.
|
| chrome.runtime.lastError = { 'message': message }; |
| }; |
| -}).call(this); |
| +}).call(this); |