Refactor the sign in code to ensure everything runs in the host page

Even the application callback should run in the host page, not within
the iframe context.

Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2009-01-14 18:18:52 -08:00
parent 57fd9e3856
commit 35bf5b4783
2 changed files with 19 additions and 18 deletions

View File

@@ -28,7 +28,6 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.user.client.Command; import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Cookies; import com.google.gwt.user.client.Cookies;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.History; import com.google.gwt.user.client.History;
import com.google.gwt.user.client.HistoryListener; import com.google.gwt.user.client.HistoryListener;
import com.google.gwt.user.client.Window; import com.google.gwt.user.client.Window;
@@ -235,7 +234,7 @@ public class Gerrit implements EntryPoint {
.myAccount(new AsyncCallback<Account>() { .myAccount(new AsyncCallback<Account>() {
public void onSuccess(final Account result) { public void onSuccess(final Account result) {
if (result != null) { if (result != null) {
postSignIn(result); postSignIn(result, null);
} else { } else {
Cookies.removeCookie(ACCOUNT_COOKIE); Cookies.removeCookie(ACCOUNT_COOKIE);
refreshMenuBar(); refreshMenuBar();
@@ -272,19 +271,20 @@ public class Gerrit implements EntryPoint {
} }
/** Hook from {@link SignInDialog} to let us know to refresh the UI. */ /** Hook from {@link SignInDialog} to let us know to refresh the UI. */
static void postSignIn(final Account acct) { static void postSignIn(final Account acct, final AsyncCallback<?> ac) {
myAccount = acct; myAccount = acct;
refreshMenuBar(); refreshMenuBar();
DeferredCommand.addCommand(new Command() {
public void execute() {
for (final SignedInListener l : signedInListeners) { for (final SignedInListener l : signedInListeners) {
l.onSignIn(); l.onSignIn();
} }
if (currentScreen != null) { if (currentScreen != null) {
currentScreen.onSignIn(); currentScreen.onSignIn();
} }
if (ac != null) {
ac.onSuccess(null);
} }
});
} }
public static void refreshMenuBar() { public static void refreshMenuBar() {

View File

@@ -185,11 +185,12 @@ public class SignInDialog extends AutoCenterDialogBox {
com.google.gerrit.client.account.Util.ACCOUNT_SVC com.google.gerrit.client.account.Util.ACCOUNT_SVC
.myAccount(new GerritCallback<Account>() { .myAccount(new GerritCallback<Account>() {
public void onSuccess(final Account result) { public void onSuccess(final Account result) {
Gerrit.postSignIn(result); DeferredCommand.addCommand(new Command() {
public void execute() {
hide(); hide();
if (ac != null) { Gerrit.postSignIn(result, ac);
ac.onSuccess(null);
} }
});
} }
@Override @Override