| 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 = "pageAction/" + extensionId; | 195 |
| 196 var oldStyleEventName = "pageActions/" + extensionId; |
| 196 // TODO(EXTENSIONS_DEPRECATED): only one page action | 197 // TODO(EXTENSIONS_DEPRECATED): only one page action |
| 197 for (var i = 0; i < pageActions.length; ++i) { | 198 for (var i = 0; i < pageActions.length; ++i) { |
| 198 // Setup events for each extension_id/page_action_id string we find. | 199 // Setup events for each extension_id/page_action_id string we find. |
| 199 chrome.pageActions[pageActions[i]] = new chrome.Event(eventName); | 200 chrome.pageActions[pageActions[i]] = new chrome.Event(oldStyleEventName); |
| 200 } | 201 } |
| 202 |
| 203 // Note this is singular. |
| 204 var eventName = "pageAction/" + extensionId; |
| 201 chrome.pageAction = chrome.pageAction || {}; | 205 chrome.pageAction = chrome.pageAction || {}; |
| 202 chrome.pageAction.onClicked = new chrome.Event(eventName); | 206 chrome.pageAction.onClicked = new chrome.Event(eventName); |
| 203 } | 207 } |
| 204 | 208 |
| 205 // Browser action events send {windowpId}. | 209 // Browser action events send {windowpId}. |
| 206 function setupBrowserActionEvent(extensionId) { | 210 function setupBrowserActionEvent(extensionId) { |
| 207 var eventName = "browserAction/" + extensionId; | 211 var eventName = "browserAction/" + extensionId; |
| 208 chrome.browserAction = chrome.browserAction || {}; | 212 chrome.browserAction = chrome.browserAction || {}; |
| 209 chrome.browserAction.onClicked = new chrome.Event(eventName); | 213 chrome.browserAction.onClicked = new chrome.Event(eventName); |
| 210 } | 214 } |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 | 416 |
| 413 apiFunctions["pageAction.setIcon"].handleRequest = function(details) { | 417 apiFunctions["pageAction.setIcon"].handleRequest = function(details) { |
| 414 setIconCommon(details, this.name, this.definition.parameters); | 418 setIconCommon(details, this.name, this.definition.parameters); |
| 415 }; | 419 }; |
| 416 | 420 |
| 417 setupBrowserActionEvent(extensionId); | 421 setupBrowserActionEvent(extensionId); |
| 418 setupPageActionEvents(extensionId); | 422 setupPageActionEvents(extensionId); |
| 419 setupToolstripEvents(GetRenderViewId()); | 423 setupToolstripEvents(GetRenderViewId()); |
| 420 }); | 424 }); |
| 421 })(); | 425 })(); |
| OLD | NEW |