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

var pageActionsNatives = requireNative('page_actions');
var GetCurrentPageActions = pageActionsNatives.GetCurrentPageActions;

var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();

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