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