Chromium Code Reviews| 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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 var availability = GetAvailability(schema.namespace); |
| 423 if (!availability.is_available && $Object.keys(mod).length == 0) { | 423 if (!availability.is_available) { |
| 424 console.error('chrome.' + schema.namespace + ' is not available: ' + | 424 // The namespace isn't available, but some of its functions may be, so we |
| 425 availability.message); | 425 // still allow access to the API. |
| 426 return; | 426 // |
| 427 // A special case is runtime.lastError which is only occasionally set, so | |
| 428 // specifically check that availability. | |
| 429 if ($Object.keys(mod).length == 0 && | |
| 430 !(schema.namespace == 'runtime' && | |
| 431 GetAvailability('runtime.lastError').is_available)) { | |
|
Ken Rockot(use gerrit already)
2014/07/18 22:33:40
I'm not sure how to make this less confusing, but
not at google - send to devlin
2014/07/18 23:28:35
I was confused when I re-read my own CL. How does
| |
| 432 console.error('chrome.' + schema.namespace + ' is not available: ' + | |
| 433 availability.message); | |
| 434 return; | |
| 435 } | |
| 427 } | 436 } |
| 428 | 437 |
| 429 this.runHooks_(mod); | 438 this.runHooks_(mod); |
| 430 return mod; | 439 return mod; |
| 431 } | 440 } |
| 432 }; | 441 }; |
| 433 | 442 |
| 434 exports.Binding = Binding; | 443 exports.Binding = Binding; |
| OLD | NEW |