| 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 // ----------------------------------------------------------------------------- | 5 // ----------------------------------------------------------------------------- |
| 6 // NOTE: If you change this file you need to touch renderer_resources.grd to | 6 // NOTE: If you change this file you need to touch renderer_resources.grd to |
| 7 // have your change take effect. | 7 // have your change take effect. |
| 8 // ----------------------------------------------------------------------------- | 8 // ----------------------------------------------------------------------------- |
| 9 | 9 |
| 10 // This script contains privileged chrome extension related javascript APIs. | 10 // This script contains privileged chrome extension related javascript APIs. |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 // Module events may have been defined earlier by hand. Don't clobber | 282 // Module events may have been defined earlier by hand. Don't clobber |
| 283 // them. | 283 // them. |
| 284 if (module[eventDef.name]) | 284 if (module[eventDef.name]) |
| 285 return; | 285 return; |
| 286 | 286 |
| 287 var eventName = apiDef.namespace + "." + eventDef.name; | 287 var eventName = apiDef.namespace + "." + eventDef.name; |
| 288 module[eventDef.name] = new chrome.Event(eventName, | 288 module[eventDef.name] = new chrome.Event(eventName, |
| 289 eventDef.parameters); | 289 eventDef.parameters); |
| 290 }); | 290 }); |
| 291 } | 291 } |
| 292 |
| 293 |
| 294 // getTabContentses is retained for backwards compatibility |
| 295 // See http://crbug.com/21433 |
| 296 chrome.extension.getTabContentses = chrome.extension.getExtensionTabs |
| 292 }); | 297 }); |
| 293 | 298 |
| 294 apiFunctions["tabs.connect"].handleRequest = function(tabId, connectInfo) { | 299 apiFunctions["tabs.connect"].handleRequest = function(tabId, connectInfo) { |
| 295 var name = ""; | 300 var name = ""; |
| 296 if (connectInfo) { | 301 if (connectInfo) { |
| 297 name = connectInfo.name || name; | 302 name = connectInfo.name || name; |
| 298 } | 303 } |
| 299 var portId = OpenChannelToTab( | 304 var portId = OpenChannelToTab( |
| 300 tabId, chrome.extension.id_, name); | 305 tabId, chrome.extension.id_, name); |
| 301 return chromeHidden.Port.createPort(portId, name); | 306 return chromeHidden.Port.createPort(portId, name); |
| 302 } | 307 } |
| 303 | 308 |
| 304 apiFunctions["extension.getViews"].handleRequest = function() { | 309 apiFunctions["extension.getViews"].handleRequest = function() { |
| 305 return GetExtensionViews(-1, "ALL"); | 310 return GetExtensionViews(-1, "ALL"); |
| 306 } | 311 } |
| 307 | 312 |
| 308 apiFunctions["extension.getBackgroundPage"].handleRequest = function() { | 313 apiFunctions["extension.getBackgroundPage"].handleRequest = function() { |
| 309 return GetExtensionViews(-1, "BACKGROUND")[0] || null; | 314 return GetExtensionViews(-1, "BACKGROUND")[0] || null; |
| 310 } | 315 } |
| 311 | 316 |
| 312 apiFunctions["extension.getToolstrips"].handleRequest = | 317 apiFunctions["extension.getToolstrips"].handleRequest = |
| 313 function(windowId) { | 318 function(windowId) { |
| 314 if (typeof(windowId) == "undefined") | 319 if (typeof(windowId) == "undefined") |
| 315 windowId = -1; | 320 windowId = -1; |
| 316 return GetExtensionViews(windowId, "TOOLSTRIP"); | 321 return GetExtensionViews(windowId, "TOOLSTRIP"); |
| 317 } | 322 } |
| 318 | 323 |
| 319 apiFunctions["extension.getTabContentses"].handleRequest = | 324 apiFunctions["extension.getExtensionTabs"].handleRequest = |
| 320 function(windowId) { | 325 function(windowId) { |
| 321 if (typeof(windowId) == "undefined") | 326 if (typeof(windowId) == "undefined") |
| 322 windowId = -1; | 327 windowId = -1; |
| 323 return GetExtensionViews(windowId, "TAB"); | 328 return GetExtensionViews(windowId, "TAB"); |
| 324 } | 329 } |
| 325 | 330 |
| 326 apiFunctions["devtools.getTabEvents"].handleRequest = function(tabId) { | 331 apiFunctions["devtools.getTabEvents"].handleRequest = function(tabId) { |
| 327 var tabIdProxy = {}; | 332 var tabIdProxy = {}; |
| 328 var functions = ["onPageEvent", "onTabUrlChange", "onTabClose"]; | 333 var functions = ["onPageEvent", "onTabUrlChange", "onTabClose"]; |
| 329 functions.forEach(function(name) { | 334 functions.forEach(function(name) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 348 sendCustomRequest(SetBrowserActionIcon, "browserAction.setIcon", | 353 sendCustomRequest(SetBrowserActionIcon, "browserAction.setIcon", |
| 349 idOrImageData, this.definition.parameters); | 354 idOrImageData, this.definition.parameters); |
| 350 } | 355 } |
| 351 } | 356 } |
| 352 | 357 |
| 353 setupPageActionEvents(extensionId); | 358 setupPageActionEvents(extensionId); |
| 354 setupBrowserActionEvent(extensionId); | 359 setupBrowserActionEvent(extensionId); |
| 355 setupToolstripEvents(GetRenderViewId()); | 360 setupToolstripEvents(GetRenderViewId()); |
| 356 }); | 361 }); |
| 357 })(); | 362 })(); |
| OLD | NEW |