| OLD | NEW |
| 1 // Copyright (c) 2009 The chrome Authors. All rights reserved. | 1 // Copyright (c) 2009 The chrome 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 // This script contains privileged chrome extension related javascript APIs. | 5 // This script contains privileged chrome extension related javascript APIs. |
| 6 // It is loaded by pages whose URL has the chrome-extension protocol. | 6 // It is loaded by pages whose URL has the chrome-extension protocol. |
| 7 | 7 |
| 8 var chrome = chrome || {}; | 8 var chrome = chrome || {}; |
| 9 (function() { | 9 (function() { |
| 10 native function GetExtensionAPIDefinition(); | 10 native function GetExtensionAPIDefinition(); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 return function() { | 185 return function() { |
| 186 return func.apply(obj, arguments); | 186 return func.apply(obj, arguments); |
| 187 }; | 187 }; |
| 188 } | 188 } |
| 189 | 189 |
| 190 // --- Setup additional api's not currently handled in common/extensions/api | 190 // --- Setup additional api's not currently handled in common/extensions/api |
| 191 | 191 |
| 192 // Page action events send (pageActionId, {tabId, tabUrl}). | 192 // Page action events send (pageActionId, {tabId, tabUrl}). |
| 193 function setupPageActionEvents(extensionId) { | 193 function setupPageActionEvents(extensionId) { |
| 194 var pageActions = GetCurrentPageActions(extensionId); | 194 var pageActions = GetCurrentPageActions(extensionId); |
| 195 var eventName = ""; | 195 var eventName = "pageAction/" + extensionId; |
| 196 // TODO(EXTENSIONS_DEPRECATED): only one page action |
| 196 for (var i = 0; i < pageActions.length; ++i) { | 197 for (var i = 0; i < pageActions.length; ++i) { |
| 197 eventName = extensionId + "/" + pageActions[i]; | |
| 198 // Setup events for each extension_id/page_action_id string we find. | 198 // Setup events for each extension_id/page_action_id string we find. |
| 199 chrome.pageActions[pageActions[i]] = new chrome.Event(eventName); | 199 chrome.pageActions[pageActions[i]] = new chrome.Event(eventName); |
| 200 } | 200 } |
| 201 chrome.pageAction = chrome.pageAction || {}; |
| 202 chrome.pageAction.onClicked = new chrome.Event(eventName); |
| 201 } | 203 } |
| 202 | 204 |
| 203 // Browser action events send {windowpId}. | 205 // Browser action events send {windowpId}. |
| 204 function setupBrowserActionEvent(extensionId) { | 206 function setupBrowserActionEvent(extensionId) { |
| 205 var eventName = "browserAction/" + extensionId; | 207 var eventName = "browserAction/" + extensionId; |
| 206 chrome.browserAction = chrome.browserAction || {}; | 208 chrome.browserAction = chrome.browserAction || {}; |
| 207 chrome.browserAction.onClicked = new chrome.Event(eventName); | 209 chrome.browserAction.onClicked = new chrome.Event(eventName); |
| 208 } | 210 } |
| 209 | 211 |
| 210 function setupToolstripEvents(renderViewId) { | 212 function setupToolstripEvents(renderViewId) { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 sendCustomRequest(SetBrowserActionIcon, "browserAction.setIcon", | 341 sendCustomRequest(SetBrowserActionIcon, "browserAction.setIcon", |
| 340 idOrImageData, this.definition.parameters); | 342 idOrImageData, this.definition.parameters); |
| 341 } | 343 } |
| 342 } | 344 } |
| 343 | 345 |
| 344 setupPageActionEvents(extensionId); | 346 setupPageActionEvents(extensionId); |
| 345 setupBrowserActionEvent(extensionId); | 347 setupBrowserActionEvent(extensionId); |
| 346 setupToolstripEvents(GetRenderViewId()); | 348 setupToolstripEvents(GetRenderViewId()); |
| 347 }); | 349 }); |
| 348 })(); | 350 })(); |
| OLD | NEW |