diff options
Diffstat (limited to 'chrome/renderer/resources/renderer_extension_bindings.js')
-rw-r--r-- | chrome/renderer/resources/renderer_extension_bindings.js | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/chrome/renderer/resources/renderer_extension_bindings.js b/chrome/renderer/resources/renderer_extension_bindings.js index 11494e3..667b97d 100644 --- a/chrome/renderer/resources/renderer_extension_bindings.js +++ b/chrome/renderer/resources/renderer_extension_bindings.js @@ -7,41 +7,41 @@ // have your change take effect. // ----------------------------------------------------------------------------- -var chromium = chromium || {}; +var chrome = chrome || {}; (function () { native function OpenChannelToExtension(id); native function PostMessage(portId, msg); // Port object. Represents a connection to another script context through // which messages can be passed. - chromium.Port = function(portId) { - if (chromium.Port.ports_[portId]) { + chrome.Port = function(portId) { + if (chrome.Port.ports_[portId]) { throw new Error("Port '" + portId + "' already exists."); } this.portId_ = portId; // TODO(mpcomplete): readonly - this.onMessage = new chromium.Event(); - chromium.Port.ports_[portId] = this; + this.onMessage = new chrome.Event(); + chrome.Port.ports_[portId] = this; // Note: this object will never get GCed. If we ever care, we could // add an "ondetach" method to the onMessage Event that gets called // when there are no more listeners. }; // Map of port IDs to port object. - chromium.Port.ports_ = {}; + chrome.Port.ports_ = {}; // Called by native code when a channel has been opened to this context. - chromium.Port.dispatchOnConnect_ = function(portId, tab) { - var port = new chromium.Port(portId); + chrome.Port.dispatchOnConnect_ = function(portId, tab) { + var port = new chrome.Port(portId); if (tab) { tab = goog.json.parse(tab); } port.tab = tab; - chromium.Event.dispatch_("channel-connect", [port]); + chrome.Event.dispatch_("channel-connect", [port]); }; // Called by native code when a message has been sent to the given port. - chromium.Port.dispatchOnMessage_ = function(msg, portId) { - var port = chromium.Port.ports_[portId]; + chrome.Port.dispatchOnMessage_ = function(msg, portId) { + var port = chrome.Port.ports_[portId]; if (port) { if (msg) { msg = goog.json.parse(msg); @@ -52,27 +52,27 @@ var chromium = chromium || {}; // Sends a message asynchronously to the context on the other end of this // port. - chromium.Port.prototype.postMessage = function(msg) { + chrome.Port.prototype.postMessage = function(msg) { PostMessage(this.portId_, goog.json.serialize(msg)); }; // Extension object. - chromium.Extension = function(id) { + chrome.Extension = function(id) { this.id_ = id; }; // Opens a message channel to the extension. Returns a Port for // message passing. - chromium.Extension.prototype.connect = function() { + chrome.Extension.prototype.connect = function() { var portId = OpenChannelToExtension(this.id_); if (portId == -1) throw new Error("No such extension: '" + this.id_ + "'"); - return new chromium.Port(portId); + return new chrome.Port(portId); }; // Returns a resource URL that can be used to fetch a resource from this // extension. - chromium.Extension.prototype.getURL = function(path) { + chrome.Extension.prototype.getURL = function(path) { return "chrome-extension://" + this.id_ + "/" + path; }; })(); |