OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Custom binding for the app API. | 5 // Custom binding for the app API. |
6 | 6 |
7 var GetAvailability = requireNative('v8_context').GetAvailability; | |
8 if (!GetAvailability('app').is_available) { | |
9 exports.$set('binding', {}); | |
10 exports.$set('onInstallStateResponse', function(){}); | |
11 return; | |
12 } | |
13 | |
14 var appNatives = requireNative('app'); | 7 var appNatives = requireNative('app'); |
15 var process = requireNative('process'); | 8 var process = requireNative('process'); |
16 var extensionId = process.GetExtensionId(); | 9 var extensionId = process.GetExtensionId(); |
17 var logActivity = requireNative('activityLogger'); | 10 var logActivity = requireNative('activityLogger'); |
18 | 11 |
19 function wrapForLogging(fun) { | 12 function wrapForLogging(fun) { |
20 if (!extensionId) | 13 if (!extensionId) |
21 return fun; // nothing interesting to log without an extension | 14 return fun; // nothing interesting to log without an extension |
22 | 15 |
23 return function() { | 16 return function() { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 app.installState = function getInstallState(callback) { | 58 app.installState = function getInstallState(callback) { |
66 var callbackId = nextCallbackId++; | 59 var callbackId = nextCallbackId++; |
67 callbacks[callbackId] = callback; | 60 callbacks[callbackId] = callback; |
68 appNatives.GetInstallState(callbackId); | 61 appNatives.GetInstallState(callbackId); |
69 }; | 62 }; |
70 if (extensionId) | 63 if (extensionId) |
71 app.installState = wrapForLogging(app.installState); | 64 app.installState = wrapForLogging(app.installState); |
72 | 65 |
73 exports.$set('binding', app); | 66 exports.$set('binding', app); |
74 exports.$set('onInstallStateResponse', onInstallStateResponse); | 67 exports.$set('onInstallStateResponse', onInstallStateResponse); |
OLD | NEW |