summaryrefslogtreecommitdiff
path: root/chromium/chrome/renderer/resources/extensions/page_actions_custom_bindings.js
blob: 2f1b9a18ead3beeebd6da94345162192baff7557 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// 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 binding for the pageActions API.

var binding = require('binding').Binding.create('pageActions');

var Event = require('event_bindings').Event;
var pageActionsNatives = requireNative('page_actions');

binding.registerCustomHook(function(bindingsAPI, extensionId) {
  var pageActions = pageActionsNatives.GetCurrentPageActions(extensionId);
  var pageActionsApi = bindingsAPI.compiledApi;
  var oldStyleEventName = 'pageActions';
  for (var i = 0; i < pageActions.length; ++i) {
    // Setup events for each extension_id/page_action_id string we find.
    pageActionsApi[pageActions[i]] = new Event(oldStyleEventName);
  }
});

exports.binding = binding.generate();