| 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 logActivity = requireNative('activityLogger'); | 8 var logActivity = requireNative('activityLogger'); |
| 9 var logging = requireNative('logging'); | 9 var logging = requireNative('logging'); |
| 10 var process = requireNative('process'); | 10 var process = requireNative('process'); |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 throw new Error('NOT IMPLEMENTED (extension_api.json error): ' + | 412 throw new Error('NOT IMPLEMENTED (extension_api.json error): ' + |
| 413 'Cannot parse values for type "' + type + '"'); | 413 'Cannot parse values for type "' + type + '"'); |
| 414 } | 414 } |
| 415 m[propertyName] = value; | 415 m[propertyName] = value; |
| 416 } | 416 } |
| 417 }); | 417 }); |
| 418 }; | 418 }; |
| 419 | 419 |
| 420 addProperties(mod, schema); | 420 addProperties(mod, schema); |
| 421 | 421 |
| 422 var availability = GetAvailability(schema.namespace); | 422 // This generate() call is considered successful if any functions, |
| 423 if (!availability.is_available && $Object.keys(mod).length == 0) { | 423 // properties, or events were created. |
| 424 var success = ($Object.keys(mod).length > 0); |
| 425 |
| 426 // The special case is runtime.lastError which is only occasionally set, so |
| 427 // specifically check its availability. |
| 428 if (schema.namespace == 'runtime' && |
| 429 GetAvailability('runtime.lastError').is_available) { |
| 430 success = true; |
| 431 } |
| 432 |
| 433 if (!success) { |
| 434 // If an API was available it should have been successfully generated. |
| 435 logging.DCHECK(!GetAvailability(schema.namespace).is_available); |
| 424 console.error('chrome.' + schema.namespace + ' is not available: ' + | 436 console.error('chrome.' + schema.namespace + ' is not available: ' + |
| 425 availability.message); | 437 availability.message); |
| 426 return; | 438 return; |
| 427 } | 439 } |
| 428 | 440 |
| 429 this.runHooks_(mod); | 441 this.runHooks_(mod); |
| 430 return mod; | 442 return mod; |
| 431 } | 443 } |
| 432 }; | 444 }; |
| 433 | 445 |
| 434 exports.Binding = Binding; | 446 exports.Binding = Binding; |
| OLD | NEW |