| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium 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 unprivileged javascript APIs related to chrome | 5 // This script contains unprivileged javascript APIs related to chrome |
| 6 // extensions. It is loaded by any extension-related context, such as content | 6 // extensions. It is loaded by any extension-related context, such as content |
| 7 // scripts or toolstrips. | 7 // scripts or toolstrips. |
| 8 // See user_script_slave.cc for script that is loaded by content scripts only. | 8 // See user_script_slave.cc for script that is loaded by content scripts only. |
| 9 // TODO(mpcomplete): we also load this in regular web pages, but don't need to. | 9 // TODO(mpcomplete): we also load this in regular web pages, but don't need to. |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 // which messages can be passed. | 39 // which messages can be passed. |
| 40 chrome.Port = function(portId, opt_name) { | 40 chrome.Port = function(portId, opt_name) { |
| 41 this.portId_ = portId; | 41 this.portId_ = portId; |
| 42 this.name = opt_name; | 42 this.name = opt_name; |
| 43 this.onDisconnect = new chrome.Event(); | 43 this.onDisconnect = new chrome.Event(); |
| 44 this.onMessage = new chrome.Event(); | 44 this.onMessage = new chrome.Event(); |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 chromeHidden.Port = {}; | 47 chromeHidden.Port = {}; |
| 48 | 48 |
| 49 // Returns true if the specified port id is in this context. This is used by | |
| 50 // the C++ to avoid creating the javascript message for all the contexts that | |
| 51 // don't care about a particular message. | |
| 52 chromeHidden.Port.hasPort = function(portId) { | |
| 53 return portId in ports; | |
| 54 }; | |
| 55 | |
| 56 // Hidden port creation function. We don't want to expose an API that lets | 49 // Hidden port creation function. We don't want to expose an API that lets |
| 57 // people add arbitrary port IDs to the port list. | 50 // people add arbitrary port IDs to the port list. |
| 58 chromeHidden.Port.createPort = function(portId, opt_name) { | 51 chromeHidden.Port.createPort = function(portId, opt_name) { |
| 59 if (ports[portId]) { | 52 if (ports[portId]) { |
| 60 throw new Error("Port '" + portId + "' already exists."); | 53 throw new Error("Port '" + portId + "' already exists."); |
| 61 } | 54 } |
| 62 var port = new chrome.Port(portId, opt_name); | 55 var port = new chrome.Port(portId, opt_name); |
| 63 ports[portId] = port; | 56 ports[portId] = port; |
| 64 portReleasers[portId] = PortRelease.bind(this, portId); | 57 portReleasers[portId] = PortRelease.bind(this, portId); |
| 65 chromeHidden.onUnload.addListener(portReleasers[portId]); | 58 chromeHidden.onUnload.addListener(portReleasers[portId]); |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 "extension.onRequestExternal", | 353 "extension.onRequestExternal", |
| 361 "extension.setUpdateUrlData", | 354 "extension.setUpdateUrlData", |
| 362 "i18n.getAcceptLanguages" | 355 "i18n.getAcceptLanguages" |
| 363 ]; | 356 ]; |
| 364 for (var i = 0; i < privileged.length; i++) { | 357 for (var i = 0; i < privileged.length; i++) { |
| 365 createStub(privileged[i]); | 358 createStub(privileged[i]); |
| 366 } | 359 } |
| 367 } | 360 } |
| 368 | 361 |
| 369 })(); | 362 })(); |
| OLD | NEW |