summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/resources/extensions/devtools_custom_bindings.js
blob: d1ad34c248a9aa8f2eae577d24aa2e1743c4ad2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Custom bindings for the devtools API.

(function() {

native function GetChromeHidden();

GetChromeHidden().registerCustomHook('devtools', function(bindingsAPI) {
  var apiFunctions = bindingsAPI.apiFunctions;

  apiFunctions.setHandleRequest('getTabEvents', function(tabId) {
    var tabIdProxy = {};
    var functions = ['onPageEvent', 'onTabClose'];
    functions.forEach(function(name) {
      // Event disambiguation is handled by name munging.  See
      // chrome/browser/extensions/extension_devtools_events.h for the C++
      // equivalent of this logic.
      tabIdProxy[name] = new chrome.Event('devtools.' + tabId + '.' + name);
    });
    return tabIdProxy;
  });
});

})();