net.xpc.CrossPageChannel Extends goog.messaging.AbstractChannel
A communication channel between two documents from different domains. Provides asynchronous messaging.

Inheritance

Constructor

goog.net.xpc.CrossPageChannel(cfgopt_domHelper)

Parameters

cfg : Object
Channel configuration object.
opt_domHelper : goog.dom.DomHelper=
The optional dom helper to use for looking up elements in the dom.

Instance Methods

Public Protected Private
cleanUpIncompleteConnection_()
Clean up after any incomplete attempt to establish and connect to a peer iframe.
code »
close()
Closes the channel.
code »
connect(opt_connectCb)
Initiates connecting the channel. When this method is called, all the information needed to connect the channel has to be available.
Arguments:
opt_connectCb : Function=
The function to be called when the channel has been connected and is ready to be used.
code »
continueConnection_()
Continues the connection process once we're as sure as we can be that the peer iframe has been created.
code »
createPeerIframe(parentElmopt_configureIframeCbopt_addCfgParam) !HTMLIFrameElement
Creates the iframe containing the peer page in a specified parent element. This method does not connect the channel, connect() still has to be called separately.
Arguments:
parentElm : !Element
The container element the iframe is appended to.
opt_configureIframeCb : Function=
If present, this function gets called with the iframe element as parameter to allow setting properties on it before it gets added to the DOM. If absent, the iframe's width and height are set to '100%'.
opt_addCfgParam : boolean=
Whether to add the peer configuration as URL parameter (default: true).
Returns: !HTMLIFrameElement  The iframe element.
code »
createTransport_()
Creates the transport for this channel. Chooses from the available transport based on the user agent and the configuration.
code »
determineTransportType_() goog.net.xpc.TransportTypes | undefined
Determine which transport type to use for this channel / useragent.
Returns: goog.net.xpc.TransportTypes | undefined  The best transport type.
code »
disposeInternal()
No description.
code »
escapeServiceName_(name) string
Escape the user-provided service name for sending across the channel. This URL-encodes certain special characters so they don't conflict with delimiters used by some of the transports, and adds a special prefix if the name conflicts with the reserved transport service name. This is the opposite of #unescapeServiceName_.
Arguments:
name : string
The name of the service to escape.
Returns: string  The escaped service name.
code »
getConfig() Object
Returns the configuration object for this channel. Package private. Do not call from outside goog.net.xpc.
Returns: Object  The configuration object for this channel.
code »
getIframeElement() Object
Returns a reference to the iframe-element. Package private. Do not call from outside goog.net.xpc.
Returns: Object  A reference to the iframe-element.
code »
getPeerConfiguration() !Object
No description.
Returns: !Object  Configuration-object to be used by the peer to initialize the channel.
code »
getPeerUri(opt_addCfgParam) !goog.Uri
Returns the peer URI, with an optional URL parameter for configuring the peer window.
Arguments:
opt_addCfgParam : boolean=
Whether to add the peer configuration as URL parameter (default: true).
Returns: !goog.Uri  The peer URI.
code »
getPeerWindowObject() Object
Returns the window object the foreign document resides in. Package private. Do not call from outside goog.net.xpc.
Returns: Object  The window object of the peer.
code »
getRole() number
Returns the role of this channel (either inner or outer).
Returns: number  The role of this channel.
code »
getTransportName() string
Returns the tranport name in use for this channel.
Returns: string  The transport name.
code »
getTransportType() number
Returns the transport type in use for this channel.
Returns: number  Transport-type identifier.
code »
isConnected() boolean
No description.
Returns: boolean  Whether the channel is connected.
code »
isMessageOriginAcceptable_(opt_origin) boolean
Returns whether an incoming message with the given origin is acceptable. If an incoming request comes with a specified (non-empty) origin, and the PEER_HOSTNAME config parameter has also been provided, the two must match, or the message is unacceptable.
Arguments:
opt_origin : string=
The origin associated with the incoming message.
Returns: boolean  Whether the message is acceptable.
code »
isPeerAvailable() boolean
Determines whether the peer window is available (e.g. not closed). Package private. Do not call from outside goog.net.xpc.
Returns: boolean  Whether the peer window is available.
code »
notifyConnected(opt_delay)
Package-private. Called by the transport when the channel is connected.
Arguments:
opt_delay : number=
Delay this number of milliseconds before calling the connection callback. Usage is discouraged, but can be used to paper over timing vulnerabilities when there is no alternative.
code »
notifyConnected_()
Alias for notifyConected, for backward compatibility reasons.
code »
notifyTransportError()
Called by the transport in case of an unrecoverable failure. Package private. Do not call from outside goog.net.xpc.
code »
send()
No description.
code »
setPeerWindowObject(peerWindowObject)
Sets the window object the foreign document resides in.
Arguments:
peerWindowObject : Object
The window object of the peer.
code »
unescapeServiceName_(name) string
Unescape the escaped service name that was sent across the channel. This is the opposite of #escapeServiceName_.
Arguments:
name : string
The name of the service to unescape.
Returns: string  The unescaped service name.
code »
updateChannelNameAndCatalog(name)
Sets the channel name. Note, this doesn't establish a unique channel to communicate on.
Arguments:
name : string
The new channel name.
code »
xpcDeliver(serviceNamepayloadopt_origin)
Delivers messages to the appropriate service-handler. Named xpcDeliver to avoid name conflict with deliver function in superclass goog.messaging.AbstractChannel. Package private. Do not call from outside goog.net.xpc.
Arguments:
serviceName : string
The name of the port.
payload : string
The payload.
opt_origin : string=
An optional origin for the message, where the underlying transport makes that available. If this is specified, and the PEER_HOSTNAME parameter was provided, they must match or the message will be rejected.
code »
connect()
Immediately calls opt_connectCb if given, and is otherwise a no-op. If subclasses have configuration that needs to happen before the channel is connected, they should override this and #isConnected.
code »
decodePayload(serviceNamepayloadobjectPayload) string | Object
Converts the message payload into the format expected by the registered service (either JSON or string).
Arguments:
serviceName : string
The name of the service receiving the message.
payload : string | !Object
The contents of the message.
objectPayload : boolean
Whether the service expects an object or a plain string.
Returns: string | Object  The payload in the format expected by the service, or null if something went wrong.
code »
defaultService_()
The default service to be run when no other services match.
code »
deliver(serviceNamepayload)
Delivers a message to the appropriate service. This is meant to be called by subclasses when they receive messages. This method takes into account both explicitly-registered and default services, as well as making sure that JSON payloads are decoded when necessary. If the subclass is capable of passing objects as payloads, those objects can be passed in to this method directly. Otherwise, the (potentially JSON-encoded) strings should be passed in.
Arguments:
serviceName : string
The name of the service receiving the message.
payload : string | !Object
The contents of the message.
code »
disposeInternal()
No description.
code »
getService(serviceNamepayload) ?{callback: function((string | !Object)), objectPayload: boolean
Find the service object for a given service name. If there's no service explicitly registered, but there is a default service, a service object is constructed for it.
Arguments:
serviceName : string
The name of the service receiving the message.
payload : string | !Object
The contents of the message.
Returns: ?{callback: function((string | !Object)), objectPayload: boolean  } The service object for the given service, or null if none was found.
code »
isConnected()
Always returns true. If subclasses have configuration that needs to happen before the channel is connected, they should override this and #connect.
code »
registerDefaultService()
No description.
code »
registerService()
No description.
code »
addOnDisposeCallback(callbackopt_scope)
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.
Arguments:
callback : function(this:T):?
The callback function.
opt_scope : T=
An optional scope to call the callback in.
code »
dispose() void
Disposes of the object. If the object hasn't already been disposed of, calls #disposeInternal. Classes that extend goog.Disposable should override #disposeInternal in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.
Returns: void  Nothing.
code »
disposeInternal()
Deletes or nulls out any references to COM objects, DOM nodes, or other disposable objects. Classes that extend goog.Disposable should override this method. Not reentrant. To avoid calling it twice, it must only be called from the subclass' disposeInternal method. Everywhere else the public dispose method must be used. For example:
  mypackage.MyClass = function() {
    mypackage.MyClass.base(this, 'constructor');
    // Constructor logic specific to MyClass.
    ...
  };
  goog.inherits(mypackage.MyClass, goog.Disposable);

  mypackage.MyClass.prototype.disposeInternal = function() {
    // Dispose logic specific to MyClass.
    ...
    // Call superclass's disposeInternal at the end of the subclass's, like
    // in C++, to avoid hard-to-catch issues.
    mypackage.MyClass.base(this, 'disposeInternal');
  };
code »
getDisposed() boolean
Use #isDisposed instead. No description.
Returns: boolean  Whether the object has been disposed of.
code »
isDisposed() boolean
No description.
Returns: boolean  Whether the object has been disposed of.
code »
registerDisposable(disposable)
Associates a disposable object with this object so that they will be disposed together.
Arguments:
disposable : goog.disposable.IDisposable
that will be disposed when this object is disposed.
code »

Instance Properties

cfg_ :
The configuration for this channel.
Code »
connectionDelay_ : goog.async.Delay
A delay between the transport reporting as connected and the calling of the connection callback. Sometimes used to paper over timing vulnerabilities.
Code »
constructor :
No description.
Code »
deferredDeliveries_ :
Collects deferred function calls which will be made once the connection has been fully set up.
Code »
domHelper_ : goog.dom.DomHelper
The dom helper to use for accessing the dom.
Code »
iframeElement_ :
Reference to the iframe-element.
Code »
name :
The name of the channel. Please use updateChannelNameAndCatalog to change this from the transports vs changing the property directly.
Code »
peerLoadHandler_ : goog.events.EventHandler
An event handler used to listen for load events on peer iframes.
Code »
peerWindowDeferred_ : goog.async.Deferred
A deferred which is set to non-null while a peer iframe is being created but has not yet thrown its load event, and which fires when that load event arrives.
Code »
peerWindowObject_ :
Reference to the window-object of the peer page.
Code »
state_ :
The channel state.
Code »
transport_ : goog.net.xpc.Transport
The transport.
Code »
constructor :
No description.
Code »
Logger for this class.
Code »
send :
No description.
Code »
services_ :
The services registered for this channel.
Code »
creationStack :
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
Code »
disposed_ :
Whether the object has been disposed of.
Code »
onDisposeCallbacks_ :
Callbacks to invoke when this object is disposed.
Code »

Static Methods

goog.net.xpc.CrossPageChannel.disposeAll_()
Disposes all channels.
code »

Static Properties

goog.net.xpc.CrossPageChannel.TRANSPORT_SERVICE_ESCAPE_RE_ :
Regexp for escaping service names.
Code »
goog.net.xpc.CrossPageChannel.TRANSPORT_SERVICE_UNESCAPE_RE_ :
Regexp for unescaping service names.
Code »
goog.net.xpc.CrossPageChannel.superClass_ :
No description.
Code »

Package net.xpc

Package Reference