Modified the implementation of GWT.getModuleBaseURL() so that it will
point back to the original server when the new development mode hook is on.
Also, added GWT.getModuleBaseForStaticFiles() API call, which can be used
when you don't want this behavior.
Review by: cromwellian@google.com
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@10906 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/core/linker/CrossSiteIframeTemplate.js b/dev/core/src/com/google/gwt/core/linker/CrossSiteIframeTemplate.js
index 166646c..3af0538 100644
--- a/dev/core/src/com/google/gwt/core/linker/CrossSiteIframeTemplate.js
+++ b/dev/core/src/com/google/gwt/core/linker/CrossSiteIframeTemplate.js
@@ -18,8 +18,6 @@
var $wnd = __WINDOW_DEF__;
var $doc = __DOCUMENT_DEF__;
- __DEV_MODE_REDIRECT_HOOK__
-
sendStats('bootstrap', 'begin');
/****************************************************************************
@@ -120,6 +118,8 @@
/****************************************************************************
* Bootstrap startup code
***************************************************************************/
+ __DEV_MODE_REDIRECT_HOOK__
+
// Must be called before computeScriptBase() and getCompiledFilename()
processMetas();
diff --git a/dev/core/src/com/google/gwt/core/linker/DevModeRedirectHook.js b/dev/core/src/com/google/gwt/core/linker/DevModeRedirectHook.js
index 6a04155..72cf9d4 100644
--- a/dev/core/src/com/google/gwt/core/linker/DevModeRedirectHook.js
+++ b/dev/core/src/com/google/gwt/core/linker/DevModeRedirectHook.js
@@ -27,6 +27,10 @@
if (devModeUrl && !$wnd[devModeKey]) {
$wnd[devModeKey] = true; // Don't try to redirect more than once,
var script = $doc.createElement('script');
+
+ // save original module base
+ $wnd[devModeKey + ':moduleBase'] = computeScriptBase();
+
script.src = devModeUrl;
var head = $doc.getElementsByTagName('head')[0];
diff --git a/user/src/com/google/gwt/core/client/GWT.java b/user/src/com/google/gwt/core/client/GWT.java
index 4e66b6c..736f3e3 100644
--- a/user/src/com/google/gwt/core/client/GWT.java
+++ b/user/src/com/google/gwt/core/client/GWT.java
@@ -111,10 +111,30 @@
}
/**
- * Gets the URL prefix of the module which should be prepended to URLs that
- * are intended to be module-relative, such as RPC entry points and files in
- * the module's public path.
- *
+ * Gets the URL prefix that should be prepended to URLs that point to
+ * static files generated by the GWT compiler, such as files in the
+ * module's public path.
+ *
+ * <p>
+ * Normally this will be the same value as {@link #getModuleBaseURL}, but
+ * may be different when a GWT app is configured to get its static resources
+ * from a different server.
+ * </p>
+ *
+ * @return if non-empty, the base URL is guaranteed to end with a slash
+ */
+ public static String getModuleBaseForStaticFiles() {
+ return Impl.getModuleBaseURLForStaticFiles();
+ }
+
+ /**
+ * Gets the URL prefix that should be prepended to URLs that
+ * are intended to be module-relative, such as RPC entry points.
+ *
+ * <p>If the URL points to an output file of the GWT compiler (such as
+ * a file in the public path), use {@link #getModuleBaseForStaticFiles()}
+ * instead.</p>
+ *
* @return if non-empty, the base URL is guaranteed to end with a slash
*/
public static String getModuleBaseURL() {
diff --git a/user/src/com/google/gwt/core/client/impl/Impl.java b/user/src/com/google/gwt/core/client/impl/Impl.java
index f0080bf..5a224dd 100644
--- a/user/src/com/google/gwt/core/client/impl/Impl.java
+++ b/user/src/com/google/gwt/core/client/impl/Impl.java
@@ -114,6 +114,14 @@
}-*/;
public static native String getModuleBaseURL() /*-{
+ // Check to see if DevModeRedirectHook has set an alternate value.
+ // The key should match DevModeRedirectHook.js.
+ var key = "__gwtDevModeHook:" + $moduleName + ":moduleBase";
+ var global = $wnd || self;
+ return global[key] || $moduleBase;
+ }-*/;
+
+ public static native String getModuleBaseURLForStaticFiles() /*-{
return $moduleBase;
}-*/;