Package com.google.gwt.core.linker
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.
-
Field Summary
Fields inherited from class com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
COMPUTE_SCRIPT_BASE_JS, FRAGMENT_EXTENSION, FRAGMENT_SUBDIR, permutationsUtil, PROCESS_METAS_JS, USE_SOURCE_MAPS_PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringfillSelectionScriptTemplate(StringBuffer ss, TreeLogger logger, LinkerContext context, ArtifactSet artifacts, CompilationResult result) Generate a selection script.protected booleangetBooleanConfigurationProperty(LinkerContext context, String name, boolean def) protected StringgetCompilationExtension(TreeLogger logger, LinkerContext context) protected StringgetDeferredFragmentSuffix2(TreeLogger logger, LinkerContext context, int fragment, String strongName) Returns the suffix at the end of a JavaScript fragment other than the initial fragment.Returns a human-readable String describing the Linker.protected Stringprotected StringgetHostedFilenameFull(LinkerContext context) protected StringgetJsComputeScriptBase(LinkerContext context) Returns the name of theComputeScriptBasescript.protected StringgetJsComputeUrlForResource(LinkerContext context) Returns the name of theUrlForResourcescript.protected StringgetJsDevModeRedirectHook(LinkerContext context) Returns a JavaScript fragment that starts Super Dev Mode, if enabled.protected StringReturns a JavaScript expression that determines whether Super Dev Mode may be turned on for the current page.protected StringgetJsDevModeUrlValidation(LinkerContext context) Returns a JavaScript fragment that validates "devModeUrl"—the URL that Super Dev Mode's JavaScript is loaded from—before it's used.protected StringgetJsInstallLocation(LinkerContext context) Returns the name of theJsInstallLocationscript.protected StringgetJsInstallScript(LinkerContext context) Returns the name of theJsInstallScriptscript.protected StringgetJsIsBodyLoaded(LinkerContext context) Returns the name of theJsIsBodyLoadedscript.protected StringReturns the name of theJsLoadExternalStylesheetsscript.protected StringReturns the name of theJsModuleFunctionErrorCatchscript.protected StringgetJsPermutations(LinkerContext context) Returns the name of theJsPermutationsscript.protected StringgetJsProcessMetas(LinkerContext context) Returns the name of theJsProcessMetasscript.protected StringgetJsProperties(LinkerContext context) Returns the name of theJsPropertiesscript.protected StringgetJsRunAsync(LinkerContext context) Returns the name of theJsRunAsyncscript.protected StringgetJsWaitForBodyLoaded(LinkerContext context) Returns the name of theJsWaitForBodyLoadedscript.protected StringgetModulePrefix(TreeLogger logger, LinkerContext context, String strongName) Compute the beginning of a JavaScript file that will hold the main module implementation.protected StringgetModuleSuffix2(TreeLogger logger, LinkerContext context, String strongName) Returns the suffix for the initial JavaScript fragment.protected StringgetScriptChunkSeparator(TreeLogger logger, LinkerContext context) Some subclasses support "chunking" of the primary fragment.protected StringgetSelectionScriptTemplate(TreeLogger logger, LinkerContext context) protected StringgetSourceMapUrl(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.protected StringgetStringConfigurationProperty(LinkerContext context, String name, String def) protected voidincludeJs(StringBuffer selectionScript, TreeLogger logger, String jsSource, String templateVar) protected voidmaybeAddHostedModeFile(TreeLogger logger, LinkerContext context, ArtifactSet artifacts, CompilationResult result) Add the Development Mode file to the artifact set.protected voidmaybeOutputPropertyMap(TreeLogger logger, LinkerContext context, ArtifactSet toReturn) protected booleanprotected booleanshouldInstallCode(LinkerContext context) Determines the strategy for installing JavaScript code into the iframe.protected booleanReturns whether to use "self" for $wnd and $doc references.protected StringwrapDeferredFragment(TreeLogger logger, LinkerContext context, int fragment, String js, ArtifactSet artifacts) protected StringwrapPrimaryFragment(TreeLogger logger, LinkerContext context, String script, ArtifactSet artifacts, CompilationResult result) Methods inherited from class com.google.gwt.core.ext.linker.impl.SelectionScriptLinker
charsPerChunk, doEmitCompilation, emitSelectionInformation, emitSelectionScript, generateDeferredFragment, generatePrimaryFragment, generatePrimaryFragmentString, generateSelectionScript, generateSelectionScript, getDeferredFragmentPrefix, getFragmentSubdir, getModulePrefix, link, link, readFileToStringBuffer, replaceAll, splitPrimaryJavaScript, supportsDevModeInJunitMethods inherited from class com.google.gwt.core.ext.linker.AbstractLinker
emitBytes, emitBytes, emitInputStream, emitInputStream, emitString, emitString, emitWithStrongName, emitWithStrongNameMethods inherited from class com.google.gwt.core.ext.Linker
isShardable, relink
-
Constructor Details
-
CrossSiteIframeLinker
public CrossSiteIframeLinker()
-
-
Method Details
-
getDescription
Description copied from class:LinkerReturns a human-readable String describing the Linker.- Specified by:
getDescriptionin classLinker
-
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.SelectionScriptLinkerGenerate a selection script. The selection information should previously have been scanned usingPermutationsUtil.setupPermutationsMap(ArtifactSet).- Overrides:
fillSelectionScriptTemplatein classcom.google.gwt.core.ext.linker.impl.SelectionScriptLinker- Throws:
UnableToCompleteException
-
getBooleanConfigurationProperty
-
getCompilationExtension
- Specified by:
getCompilationExtensionin classcom.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.SelectionScriptLinkerReturns the suffix at the end of a JavaScript fragment other than the initial fragment.- Overrides:
getDeferredFragmentSuffix2in classcom.google.gwt.core.ext.linker.impl.SelectionScriptLinker
-
getHostedFilename
- Overrides:
getHostedFilenamein classcom.google.gwt.core.ext.linker.impl.SelectionScriptLinker
-
getHostedFilenameFull
-
getJsComputeScriptBase
Returns the name of theComputeScriptBasescript. By default, returns"com/google/gwt/core/ext/linker/impl/computeScriptBase.js".- Parameters:
context- a LinkerContext
-
getJsComputeUrlForResource
Returns the name of theUrlForResourcescript. By default, returns"com/google/gwt/core/ext/linker/impl/computeUrlForResource.js".- Parameters:
context- a LinkerContext
-
getJsDevModeRedirectHook
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
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
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
Returns the name of theJsInstallLocationscript. By default, returns"com/google/gwt/core/ext/linker/impl/installLocationIframe.js".- Parameters:
context- a LinkerContext
-
getJsInstallScript
Returns the name of theJsInstallScriptscript. The default is chosen based on the value ofshouldInstallCode(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
Returns the name of theJsIsBodyLoadedscript. By default, returns"com/google/gwt/core/ext/linker/impl/isBodyLoaded.js".- Parameters:
context- a LinkerContext
-
getJsLoadExternalStylesheets
Returns the name of theJsLoadExternalStylesheetsscript. By default, returns"com/google/gwt/core/ext/linker/impl/loadExternalStylesheets.js".- Parameters:
context- a LinkerContext
-
getJsModuleFunctionErrorCatch
Returns the name of theJsModuleFunctionErrorCatchscript. 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
Returns the name of theJsPermutationsscript. By default, returns"com/google/gwt/core/ext/linker/impl/permutations.js".- Parameters:
context- a LinkerContext
-
getJsProcessMetas
Returns the name of theJsProcessMetasscript. By default, returns"com/google/gwt/core/ext/linker/impl/processMetas.js".- Parameters:
context- a LinkerContext
-
getJsProperties
Returns the name of theJsPropertiesscript. By default, returns"com/google/gwt/core/ext/linker/impl/properties.js".- Parameters:
context- a LinkerContext
-
getJsRunAsync
Returns the name of theJsRunAsyncscript. By default, returns"com/google/gwt/core/ext/linker/impl/runAsync.js".- Parameters:
context- a LinkerContext
-
getJsWaitForBodyLoaded
Returns the name of theJsWaitForBodyLoadedscript. 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.SelectionScriptLinkerCompute the beginning of a JavaScript file that will hold the main module implementation.- Specified by:
getModulePrefixin classcom.google.gwt.core.ext.linker.impl.SelectionScriptLinker- Throws:
UnableToCompleteException
-
getModuleSuffix2
Description copied from class:com.google.gwt.core.ext.linker.impl.SelectionScriptLinkerReturns the suffix for the initial JavaScript fragment.- Overrides:
getModuleSuffix2in classcom.google.gwt.core.ext.linker.impl.SelectionScriptLinker
-
getScriptChunkSeparator
Description copied from class:com.google.gwt.core.ext.linker.impl.SelectionScriptLinkerSome 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:
getScriptChunkSeparatorin classcom.google.gwt.core.ext.linker.impl.SelectionScriptLinker
-
getSelectionScriptTemplate
- Specified by:
getSelectionScriptTemplatein classcom.google.gwt.core.ext.linker.impl.SelectionScriptLinker
-
getSourceMapUrl
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
-
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.SelectionScriptLinkerAdd the Development Mode file to the artifact set.- Overrides:
maybeAddHostedModeFilein classcom.google.gwt.core.ext.linker.impl.SelectionScriptLinker- Throws:
UnableToCompleteException
-
maybeOutputPropertyMap
protected void maybeOutputPropertyMap(TreeLogger logger, LinkerContext context, ArtifactSet toReturn) - Overrides:
maybeOutputPropertyMapin classcom.google.gwt.core.ext.linker.impl.SelectionScriptLinker
-
shouldIncludeBootstrapInPrimaryFragment
-
shouldInstallCode
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
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:
wrapDeferredFragmentin classcom.google.gwt.core.ext.linker.impl.SelectionScriptLinker
-
wrapPrimaryFragment
protected String wrapPrimaryFragment(TreeLogger logger, LinkerContext context, String script, ArtifactSet artifacts, CompilationResult result) throws UnableToCompleteException - Overrides:
wrapPrimaryFragmentin classcom.google.gwt.core.ext.linker.impl.SelectionScriptLinker- Throws:
UnableToCompleteException
-