| 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 var Event = require('event_bindings').Event; | 5 var Event = require('event_bindings').Event; |
| 6 var forEach = require('utils').forEach; | 6 var forEach = require('utils').forEach; |
| 7 var GetAvailability = requireNative('v8_context').GetAvailability; | 7 var GetAvailability = requireNative('v8_context').GetAvailability; |
| 8 var exceptionHandler = require('uncaught_exception_handler'); |
| 8 var lastError = require('lastError'); | 9 var lastError = require('lastError'); |
| 9 var logActivity = requireNative('activityLogger'); | 10 var logActivity = requireNative('activityLogger'); |
| 10 var logging = requireNative('logging'); | 11 var logging = requireNative('logging'); |
| 11 var process = requireNative('process'); | 12 var process = requireNative('process'); |
| 12 var schemaRegistry = requireNative('schema_registry'); | 13 var schemaRegistry = requireNative('schema_registry'); |
| 13 var schemaUtils = require('schemaUtils'); | 14 var schemaUtils = require('schemaUtils'); |
| 14 var utils = require('utils'); | 15 var utils = require('utils'); |
| 15 var sendRequestHandler = require('sendRequest'); | 16 var sendRequestHandler = require('sendRequest'); |
| 16 | 17 |
| 17 var contextType = process.GetContextType(); | 18 var contextType = process.GetContextType(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 return ret; | 63 return ret; |
| 63 }); | 64 }); |
| 64 }; | 65 }; |
| 65 | 66 |
| 66 APIFunctions.prototype.setHandleRequestWithPromise = | 67 APIFunctions.prototype.setHandleRequestWithPromise = |
| 67 function(apiName, customizedFunction) { | 68 function(apiName, customizedFunction) { |
| 68 var prefix = this.namespace; | 69 var prefix = this.namespace; |
| 69 return this.setHook_(apiName, 'handleRequest', function() { | 70 return this.setHook_(apiName, 'handleRequest', function() { |
| 70 var name = prefix + '.' + apiName; | 71 var name = prefix + '.' + apiName; |
| 71 logActivity.LogAPICall(extensionId, name, $Array.slice(arguments)); | 72 logActivity.LogAPICall(extensionId, name, $Array.slice(arguments)); |
| 72 var stack = sendRequestHandler.getExtensionStackTrace(); | 73 var stack = exceptionHandler.getExtensionStackTrace(); |
| 73 var callback = arguments[arguments.length - 1]; | 74 var callback = arguments[arguments.length - 1]; |
| 74 var args = $Array.slice(arguments, 0, arguments.length - 1); | 75 var args = $Array.slice(arguments, 0, arguments.length - 1); |
| 75 $Function.apply(customizedFunction, this, args).then(function(result) { | 76 $Function.apply(customizedFunction, this, args).then(function(result) { |
| 76 sendRequestHandler.safeCallbackApply( | 77 sendRequestHandler.safeCallbackApply( |
| 77 name, {'stack': stack}, callback, [result]); | 78 name, {'stack': stack}, callback, [result]); |
| 78 }).catch(function(error) { | 79 }).catch(function(error) { |
| 79 lastError.run(name, error.message, stack, callback); | 80 var message = exceptionHandler.safeErrorToString(error, true); |
| 81 lastError.run(name, message, stack, callback); |
| 80 }); | 82 }); |
| 81 }); | 83 }); |
| 82 }; | 84 }; |
| 83 | 85 |
| 84 APIFunctions.prototype.setUpdateArgumentsPostValidate = | 86 APIFunctions.prototype.setUpdateArgumentsPostValidate = |
| 85 function(apiName, customizedFunction) { | 87 function(apiName, customizedFunction) { |
| 86 return this.setHook_( | 88 return this.setHook_( |
| 87 apiName, 'updateArgumentsPostValidate', customizedFunction); | 89 apiName, 'updateArgumentsPostValidate', customizedFunction); |
| 88 }; | 90 }; |
| 89 | 91 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 for (var i = 0; i < platforms.length; i++) { | 129 for (var i = 0; i < platforms.length; i++) { |
| 128 if ($RegExp.test(platforms[i][0], navigator.appVersion)) { | 130 if ($RegExp.test(platforms[i][0], navigator.appVersion)) { |
| 129 return platforms[i][1]; | 131 return platforms[i][1]; |
| 130 } | 132 } |
| 131 } | 133 } |
| 132 return "unknown"; | 134 return "unknown"; |
| 133 } | 135 } |
| 134 | 136 |
| 135 function isPlatformSupported(schemaNode, platform) { | 137 function isPlatformSupported(schemaNode, platform) { |
| 136 return !schemaNode.platforms || | 138 return !schemaNode.platforms || |
| 137 schemaNode.platforms.indexOf(platform) > -1; | 139 $Array.indexOf(schemaNode.platforms, platform) > -1; |
| 138 } | 140 } |
| 139 | 141 |
| 140 function isManifestVersionSupported(schemaNode, manifestVersion) { | 142 function isManifestVersionSupported(schemaNode, manifestVersion) { |
| 141 return !schemaNode.maximumManifestVersion || | 143 return !schemaNode.maximumManifestVersion || |
| 142 manifestVersion <= schemaNode.maximumManifestVersion; | 144 manifestVersion <= schemaNode.maximumManifestVersion; |
| 143 } | 145 } |
| 144 | 146 |
| 145 function isSchemaNodeSupported(schemaNode, platform, manifestVersion) { | 147 function isSchemaNodeSupported(schemaNode, platform, manifestVersion) { |
| 146 return isPlatformSupported(schemaNode, platform) && | 148 return isPlatformSupported(schemaNode, platform) && |
| 147 isManifestVersionSupported(schemaNode, manifestVersion); | 149 isManifestVersionSupported(schemaNode, manifestVersion); |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 availability.message); | 472 availability.message); |
| 471 return; | 473 return; |
| 472 } | 474 } |
| 473 | 475 |
| 474 this.runHooks_(mod); | 476 this.runHooks_(mod); |
| 475 return mod; | 477 return mod; |
| 476 } | 478 } |
| 477 }; | 479 }; |
| 478 | 480 |
| 479 exports.Binding = Binding; | 481 exports.Binding = Binding; |
| OLD | NEW |