| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 natives = requireNative('app'); | 5 var chrome = chrome || {}; |
| 6 var GetIsInstalled = natives.GetIsInstalled; | 6 (function() { |
| 7 var Install = natives.Install; | 7 native function GetChromeHidden(); |
| 8 var GetDetails = natives.GetDetails; | 8 native function GetIsInstalled(); |
| 9 var GetDetailsForFrame = natives.GetDetailsForFrame; | 9 native function Install(); |
| 10 var GetAppNotifyChannel = natives.GetAppNotifyChannel; | 10 native function GetDetails(); |
| 11 native function GetDetailsForFrame(); |
| 12 native function GetAppNotifyChannel(); |
| 11 | 13 |
| 12 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); | 14 var chromeHidden = GetChromeHidden(); |
| 13 var callbacks = {}; | 15 var callbacks = {}; |
| 14 var nextCallbackId = 1; | 16 var nextCallbackId = 1; |
| 15 | 17 |
| 16 chrome.app = new function() { | 18 chrome.app = new function() { |
| 17 this.__defineGetter__('isInstalled', GetIsInstalled); | 19 this.__defineGetter__('isInstalled', GetIsInstalled); |
| 18 this.install = Install; | 20 this.install = Install; |
| 19 this.getDetails = GetDetails; | 21 this.getDetails = GetDetails; |
| 20 this.getDetailsForFrame = GetDetailsForFrame; | 22 this.getDetailsForFrame = GetDetailsForFrame; |
| 21 }(); | 23 }(); |
| 22 | 24 |
| 23 chrome.appNotifications = new function() { | 25 chrome.appNotifications = new function() { |
| 24 this.getChannel = function(clientId, callback) { | 26 this.getChannel = function(clientId, callback) { |
| 25 var callbackId = 0; | 27 var callbackId = 0; |
| 26 if (callback) { | 28 if (callback) { |
| 27 callbackId = nextCallbackId++; | 29 callbackId = nextCallbackId++; |
| 28 callbacks[callbackId] = callback; | 30 callbacks[callbackId] = callback; |
| 29 } | 31 } |
| 30 GetAppNotifyChannel(clientId, callbackId); | 32 GetAppNotifyChannel(clientId, callbackId); |
| 31 }; | 33 }; |
| 32 }(); | 34 }(); |
| 33 | 35 |
| 34 chromeHidden.app = {}; | 36 chromeHidden.app = {}; |
| 35 chromeHidden.app.onGetAppNotifyChannelResponse = | 37 chromeHidden.app.onGetAppNotifyChannelResponse = |
| 36 function(channelId, error, callbackId) { | 38 function(channelId, error, callbackId) { |
| 37 if (callbackId) { | 39 if (callbackId) { |
| 38 callbacks[callbackId](channelId, error); | 40 callbacks[callbackId](channelId, error); |
| 39 delete callbacks[callbackId]; | 41 delete callbacks[callbackId]; |
| 40 } | 42 } |
| 41 }; | 43 }; |
| 44 })(); |
| OLD | NEW |