net.xpc.NativeMessagingTransport Extends goog.net.xpc.Transport
The native messaging transport Uses document.postMessage() to send messages to other documents. Receiving is done by listening on 'message'-events on the document.

Inheritance

Constructor

goog.net.xpc.NativeMessagingTransport(channelpeerHostnameopt_domHelperopt_oneSidedHandshakeopt_protocolVersion)

Parameters

channel : goog.net.xpc.CrossPageChannel
The channel this transport belongs to.
peerHostname : string
The hostname (protocol, domain, and port) of the peer.
opt_domHelper : goog.dom.DomHelper=
The dom helper to use for finding the correct window/document.
opt_oneSidedHandshake : boolean=
If this is true, only the outer transport sends a SETUP message and expects a SETUP_ACK. The inner transport goes connected when it receives the SETUP.
opt_protocolVersion : number=
Which version of its setup protocol the transport should use. The default is '2'.

Instance Methods

Public Protected Private
connect()
Connects this transport.
code »
couldPeerVersionBe_(version) boolean
Checks whether the peer transport protocol version could be as indicated.
Arguments:
version : number
The version to check for.
Returns: boolean  Whether the peer transport protocol version is as indicated, or null.
code »
disposeInternal()
No description.
code »
maybeAttemptToConnect_()
Connects to other peer. In the case of the outer peer, the setup messages are likely sent before the inner peer is ready to receive them. Therefore, this function will continue trying to send the SETUP message until the inner peer responds. In the case of the inner peer, it will occasionally have its channel name fall out of sync with the outer peer, particularly during soft-reloads and history navigations.
code »
notifyConnected_()
Notify the channel that this transport is connected. If either transport is protocol v1, a short delay is required to paper over timing vulnerabilities in that protocol version.
code »
send(servicepayload)
Sends a message.
Arguments:
service : string
The name off the service the message is to be delivered to.
payload : string
The message content.
code »
sendSetupAckMessage_(protocolVersion)
Sends a SETUP_ACK transport service message of the correct protocol number for our current situation.
Arguments:
protocolVersion : number
The protocol version of the SETUP message which gave rise to this ack message.
code »
sendSetupMessage_()
Sends a SETUP transport service message of the correct protocol number for our current situation.
code »
setPeerProtocolVersion_(version)
Attempts to set the peer protocol number. Downgrades from 2 to 1 are not permitted.
Arguments:
version : number
The new protocol number.
code »
transportServiceHandler(payload)
Handles transport service messages.
Arguments:
payload : string
The message content.
code »
getName() string
Return the transport name.
Returns: string  the transport name.
code »
getType() number
No description.
Returns: number  The transport type identifier.
code »
getWindow() !Window
Returns the window associated with this transport instance.
Returns: !Window  The window to use.
code »
send(servicepayload)
Sends a message.
Arguments:
service : string
The name off the service the message is to be delivered to.
payload : string
The message content.
code »
transportServiceHandler(payload)
Handles transport service messages (internal signalling).
Arguments:
payload : string
The message content.
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

The channel this transport belongs to.
Code »
connected_ : goog.async.Deferred
Fires once we're marked connected.
Code »
constructor :
No description.
Code »
endpointId_ :
The unique ID of this side of the connection. Used to determine when a peer is reloaded.
Code »
eventHandler_ : goog.events.EventHandler
The event handler.
Code »
initialized_ :
Flag indicating if this instance of the transport has been initialized.
Code »
maybeAttemptToConnectTimer_ : goog.Timer
Timer for connection reattempts.
Code »
oneSidedHandshake_ :
Whether one-sided handshakes are enabled.
Code »
peerEndpointId_ :
The unique ID of the peer. If we get a message from a peer with an ID we don't expect, we reset the connection.
Code »
peerHostname_ :
The hostname of the peer. This parameterizes all calls to postMessage, and should contain the precise protocol, domain, and port of the peer window.
Code »
peerProtocolVersion_ :
Current determination of peer's protocol version, or null for unknown.
Code »
protocolVersion_ :
Which version of the transport's protocol should be used.
Code »
setupAckReceived_ : goog.async.Deferred
Fires once we've received our SETUP_ACK message.
Code »
setupAckSent_ : goog.async.Deferred
Fires once we've sent our SETUP_ACK message.
Code »
transportType :
The transport type.
Code »
connect :
Connects this transport. The transport implementation is expected to call CrossPageChannel.prototype.notifyConnected when the channel is ready to be used.
Code »
constructor :
No description.
Code »
domHelper_ : goog.dom.DomHelper
The dom helper to use for finding the window objects to reference.
Code »
transportType :
The transport type.
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.NativeMessagingTransport.initialize_(listenWindow)
Initializes this transport. Registers a listener for 'message'-events on the document.
Arguments:
listenWindow : Window
The window to listen to events on.
code »
goog.net.xpc.NativeMessagingTransport.messageReceived_(msgEvt) boolean
Processes an incoming message-event.
Arguments:
msgEvt : goog.events.BrowserEvent
The message event.
Returns: boolean  True if message was successfully delivered to a channel.
code »
goog.net.xpc.NativeMessagingTransport.parseTransportPayload_(payload) !Array.<?string>
Parse a transport service payload message. For v1, it is simply expected to be 'SETUP' or 'SETUP_ACK'. For v2, an example setup message is 'SETUP_NTPV2,abc123', where the second part is the endpoint id. The v2 setup ack message is simply 'SETUP_ACK_NTPV2'.
Arguments:
payload : string
The payload.
Returns: !Array.<?string>  An array with the message type as the first member and the endpoint id as the second, if one was sent, or null otherwise.
code »

Static Properties

goog.net.xpc.NativeMessagingTransport.CONNECTION_DELAY_MS_ :
Length of the delay in milliseconds between the channel being connected and the connection callback being called, in cases where coverage of timing flaws is required.
Code »
goog.net.xpc.NativeMessagingTransport.MESSAGE_DELIMITER_ :
The delimiter used for transport service messages.
Code »
goog.net.xpc.NativeMessagingTransport.activeCount_ :
Tracks the number of NativeMessagingTransport channels that have been initialized but not disposed yet in a map keyed by the UID of the window object. This allows for multiple windows to be initiallized and listening for messages.
Code »
goog.net.xpc.NativeMessagingTransport.sendTimerId_ :
Id of a timer user during postMessage sends.
Code »
goog.net.xpc.NativeMessagingTransport.superClass_ :
No description.
Code »

Package net.xpc

Package Reference