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 bindings for the runtime API. | 5 // Custom bindings for the runtime API. |
6 | 6 |
7 var extensionNatives = requireNative('extension'); | 7 var extensionNatives = requireNative('extension'); |
8 var GetExtensionViews = extensionNatives.GetExtensionViews; | 8 var GetExtensionViews = extensionNatives.GetExtensionViews; |
9 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); | 9 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); |
10 var sendRequest = require('sendRequest').sendRequest; | 10 var sendRequest = require('sendRequest').sendRequest; |
11 | 11 |
12 chromeHidden.registerCustomHook('experimental.runtime', function(bindingsAPI) { | 12 chromeHidden.registerCustomHook('runtime', function(bindingsAPI) { |
13 var apiFunctions = bindingsAPI.apiFunctions; | 13 var apiFunctions = bindingsAPI.apiFunctions; |
14 | 14 |
15 apiFunctions.setCustomCallback('getBackgroundPage', | 15 apiFunctions.setCustomCallback('getBackgroundPage', |
16 function(name, request, response) { | 16 function(name, request, response) { |
17 if (request.callback) { | 17 if (request.callback) { |
18 var bg = GetExtensionViews(-1, 'BACKGROUND')[0] || null; | 18 var bg = GetExtensionViews(-1, 'BACKGROUND')[0] || null; |
19 request.callback(bg); | 19 request.callback(bg); |
20 } | 20 } |
21 request.callback = null; | 21 request.callback = null; |
22 }); | 22 }); |
23 }); | 23 }); |
OLD | NEW |