Class CrossSiteIframeLinker

java.lang.Object
com.google.gwt.core.ext.Linker
com.google.gwt.core.ext.linker.AbstractLinker
com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
com.google.gwt.core.linker.CrossSiteIframeLinker
Direct Known Subclasses:
DirectInstallLinker

@LinkerOrder(PRIMARY) @Shardable public class CrossSiteIframeLinker extends com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
This linker uses an iframe to hold the code and a script tag to download the code. It can download code cross-site, because it uses a script tag to download it and because it never uses XHR. The iframe, meanwhile, makes it trivial to install additional code as the app runs.
  • Constructor Details

    • CrossSiteIframeLinker

      public CrossSiteIframeLinker()
  • Method Details

    • getDescription

      public String getDescription()
      Description copied from class: Linker
      Returns a human-readable String describing the Linker.
      Specified by:
      getDescription in class Linker
    • fillSelectionScriptTemplate

      protected String fillSelectionScriptTemplate(StringBuffer ss, TreeLogger logger, LinkerContext context, ArtifactSet artifacts, CompilationResult result) throws UnableToCompleteException
      Description copied from class: com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
      Generate a selection script. The selection information should previously have been scanned using PermutationsUtil.setupPermutationsMap(ArtifactSet).
      Overrides:
      fillSelectionScriptTemplate in class com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
      Throws:
      UnableToCompleteException
    • getBooleanConfigurationProperty

      protected boolean getBooleanConfigurationProperty(LinkerContext context, String name, boolean def)
    • getCompilationExtension

      protected String getCompilationExtension(TreeLogger logger, LinkerContext context)
      Specified by:
      getCompilationExtension in class com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
    • getDeferredFragmentSuffix2

      protected String getDeferredFragmentSuffix2(TreeLogger logger, LinkerContext context, int fragment, String strongName)
      Description copied from class: com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
      Returns the suffix at the end of a JavaScript fragment other than the initial fragment.
      Overrides:
      getDeferredFragmentSuffix2 in class com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
    • getHostedFilename

      protected String getHostedFilename()
      Overrides:
      getHostedFilename in class com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
    • getHostedFilenameFull

      protected String getHostedFilenameFull(LinkerContext context)
    • getJsComputeScriptBase

      protected String getJsComputeScriptBase(LinkerContext context)
      Returns the name of the ComputeScriptBase script. By default, returns "com/google/gwt/core/ext/linker/impl/computeScriptBase.js".
      Parameters:
      context - a LinkerContext
    • getJsComputeUrlForResource

      protected String getJsComputeUrlForResource(LinkerContext context)
      Returns the name of the UrlForResource script. By default, returns "com/google/gwt/core/ext/linker/impl/computeUrlForResource.js".
      Parameters:
      context - a LinkerContext
    • getJsDevModeRedirectHook

      protected String getJsDevModeRedirectHook(LinkerContext context)
      Returns a JavaScript fragment that starts Super Dev Mode, if enabled. (May return either the JavaScript itself or the name of a Java resource ending with ".js".)
    • getJsDevModeUrlValidation

      protected String getJsDevModeUrlValidation(LinkerContext context)
      Returns a JavaScript fragment that validates "devModeUrl"—the URL that Super Dev Mode's JavaScript is loaded from—before it's used. The variable may be modified to change what what URL is loaded, or it maybe be set to "" to disable completely. (May return either the JavaScript itself or the name of a Java resource ending with ".js".)
    • getJsDevModeRedirectHookPermitted

      protected String getJsDevModeRedirectHookPermitted(LinkerContext context)
      Returns a JavaScript expression that determines whether Super Dev Mode may be turned on for the current page. (May return either the JavaScript itself or the name of a Java resource ending with ".js".)

      The default implementation allows Super Dev Mode only on http: and file: pages. It could be overridden to implement a blacklist or whitelist of hostnames where Super Dev Mode may run. As a safety precaution, it's recommended to return false for https and for the hostnames in URL's visited by end users.

      If you override this method to allow https, it probably won't work anyway because browsers often disallow loading JavaScript from http URL's into https pages. To make it work, you will also have to find a way to run the code server using https.

    • getJsInstallLocation

      protected String getJsInstallLocation(LinkerContext context)
      Returns the name of the JsInstallLocation script. By default, returns "com/google/gwt/core/ext/linker/impl/installLocationIframe.js".
      Parameters:
      context - a LinkerContext
    • getJsInstallScript

      protected String getJsInstallScript(LinkerContext context)
      Returns the name of the JsInstallScript script. The default is chosen based on the value of shouldInstallCode(com.google.gwt.core.ext.LinkerContext).

      If you override this, verify that shouldInstallCode(com.google.gwt.core.ext.LinkerContext) is set consistently or fragment loading won't work.

    • getJsIsBodyLoaded

      protected String getJsIsBodyLoaded(LinkerContext context)
      Returns the name of the JsIsBodyLoaded script. By default, returns "com/google/gwt/core/ext/linker/impl/isBodyLoaded.js".
      Parameters:
      context - a LinkerContext
    • getJsLoadExternalStylesheets

      protected String getJsLoadExternalStylesheets(LinkerContext context)
      Returns the name of the JsLoadExternalStylesheets script. By default, returns "com/google/gwt/core/ext/linker/impl/loadExternalStylesheets.js".
      Parameters:
      context - a LinkerContext
    • getJsModuleFunctionErrorCatch

      protected String getJsModuleFunctionErrorCatch(LinkerContext context)
      Returns the name of the JsModuleFunctionErrorCatch script. By default returns null. This script executes if there's an error loading the module function or executing it. The error will be available under a local variable named "moduleError". If non-null, the module function and the call to the module function will be placed in a try/catch block.
      Parameters:
      context - a LinkerContext
    • getJsPermutations

      protected String getJsPermutations(LinkerContext context)
      Returns the name of the JsPermutations script. By default, returns "com/google/gwt/core/ext/linker/impl/permutations.js".
      Parameters:
      context - a LinkerContext
    • getJsProcessMetas

      protected String getJsProcessMetas(LinkerContext context)
      Returns the name of the JsProcessMetas script. By default, returns "com/google/gwt/core/ext/linker/impl/processMetas.js".
      Parameters:
      context - a LinkerContext
    • getJsProperties

      protected String getJsProperties(LinkerContext context)
      Returns the name of the JsProperties script. By default, returns "com/google/gwt/core/ext/linker/impl/properties.js".
      Parameters:
      context - a LinkerContext
    • getJsRunAsync

      protected String getJsRunAsync(LinkerContext context)
      Returns the name of the JsRunAsync script. By default, returns "com/google/gwt/core/ext/linker/impl/runAsync.js".
      Parameters:
      context - a LinkerContext
    • getJsWaitForBodyLoaded

      protected String getJsWaitForBodyLoaded(LinkerContext context)
      Returns the name of the JsWaitForBodyLoaded script. By default, returns "com/google/gwt/core/ext/linker/impl/waitForBodyLoaded.js".
      Parameters:
      context - a LinkerContext
    • getModulePrefix

      protected String getModulePrefix(TreeLogger logger, LinkerContext context, String strongName) throws UnableToCompleteException
      Description copied from class: com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
      Compute the beginning of a JavaScript file that will hold the main module implementation.
      Specified by:
      getModulePrefix in class com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
      Throws:
      UnableToCompleteException
    • getModuleSuffix2

      protected String getModuleSuffix2(TreeLogger logger, LinkerContext context, String strongName)
      Description copied from class: com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
      Returns the suffix for the initial JavaScript fragment.
      Overrides:
      getModuleSuffix2 in class com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
    • getScriptChunkSeparator

      protected String getScriptChunkSeparator(TreeLogger logger, LinkerContext context)
      Description copied from class: com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
      Some subclasses support "chunking" of the primary fragment. If chunking will be supported, this function should be overridden to return the string which should be inserted between each chunk.
      Overrides:
      getScriptChunkSeparator in class com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
    • getSelectionScriptTemplate

      protected String getSelectionScriptTemplate(TreeLogger logger, LinkerContext context)
      Specified by:
      getSelectionScriptTemplate in class com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
    • getSourceMapUrl

      protected String getSourceMapUrl(LinkerContext context, String strongName, int fragmentId)
      Returns the sourcemap URL that will be put in the comment at the end of a JavaScript fragment, or null if the comment should be omitted. The default implementation uses the includeSourceMapUrl config property.
    • getStringConfigurationProperty

      protected String getStringConfigurationProperty(LinkerContext context, String name, String def)
    • includeJs

      protected void includeJs(StringBuffer selectionScript, TreeLogger logger, String jsSource, String templateVar) throws UnableToCompleteException
      Throws:
      UnableToCompleteException
    • maybeAddHostedModeFile

      protected void maybeAddHostedModeFile(TreeLogger logger, LinkerContext context, ArtifactSet artifacts, CompilationResult result) throws UnableToCompleteException
      Description copied from class: com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
      Add the Development Mode file to the artifact set.
      Overrides:
      maybeAddHostedModeFile in class com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
      Throws:
      UnableToCompleteException
    • maybeOutputPropertyMap

      protected void maybeOutputPropertyMap(TreeLogger logger, LinkerContext context, ArtifactSet toReturn)
      Overrides:
      maybeOutputPropertyMap in class com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
    • shouldIncludeBootstrapInPrimaryFragment

      protected boolean shouldIncludeBootstrapInPrimaryFragment(LinkerContext context)
    • shouldInstallCode

      protected boolean shouldInstallCode(LinkerContext context)
      Determines the strategy for installing JavaScript code into the iframe. If set to false, a <script> tag pointing to the js file is added directly to the iframe. Otherwise, GWT downloads the JavaScript code as a list of strings and then adds it to the iframe.
    • shouldUseSelfForWindowAndDocument

      protected boolean shouldUseSelfForWindowAndDocument(LinkerContext context)
      Returns whether to use "self" for $wnd and $doc references. Defaults to false. Useful for worker threads.
    • wrapDeferredFragment

      protected String wrapDeferredFragment(TreeLogger logger, LinkerContext context, int fragment, String js, ArtifactSet artifacts)
      Overrides:
      wrapDeferredFragment in class com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
    • wrapPrimaryFragment

      protected String wrapPrimaryFragment(TreeLogger logger, LinkerContext context, String script, ArtifactSet artifacts, CompilationResult result) throws UnableToCompleteException
      Overrides:
      wrapPrimaryFragment in class com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
      Throws:
      UnableToCompleteException