Greg Sheremeta has uploaded a new change for review. Change subject: userportal, webadmin: workaround for Firefox favicon bug ......................................................................
userportal, webadmin: workaround for Firefox favicon bug Workaround for Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=519028, 'change location.hash leads to location bar icon (favicon) disappearance.' The symptom is that the favicon disappears in Firefox on the initial hashchange when logging in. The workaround is to simple detach and re-attach the favicon link element on hashchange (only register this handler in Firefox). Change-Id: Ia4b0d8a0176eb9299aec01ae6772297409ef3108 Bug-Url: https://bugzilla.redhat.com/999436 Signed-off-by: Greg Sheremeta <[email protected]> --- M backend/manager/modules/branding/src/main/resources/META-INF/tags/obrand/favicon.tag A frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/FaviconRefreshUtil.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/system/BaseApplicationInit.java M frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/login/presenter/LoginSectionPresenter.java M frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/system/ApplicationInit.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/login/presenter/LoginSectionPresenter.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/system/ApplicationInit.java 7 files changed, 66 insertions(+), 7 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/98/20798/1 diff --git a/backend/manager/modules/branding/src/main/resources/META-INF/tags/obrand/favicon.tag b/backend/manager/modules/branding/src/main/resources/META-INF/tags/obrand/favicon.tag index 8214ef2..0fe75e1 100644 --- a/backend/manager/modules/branding/src/main/resources/META-INF/tags/obrand/favicon.tag +++ b/backend/manager/modules/branding/src/main/resources/META-INF/tags/obrand/favicon.tag @@ -1,3 +1,3 @@ <%@ tag language="java" pageEncoding="UTF-8"%> <%@ tag body-content="empty" %> -<link rel="shortcut icon" href="${pageContext.request.contextPath}${initParam['obrandResourcePath']}/favicon" type="image/x-icon" /> +<link id="id-link-favicon" rel="shortcut icon" href="${pageContext.request.contextPath}${initParam['obrandResourcePath']}/favicon" type="image/x-icon" /> diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/FaviconRefreshUtil.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/FaviconRefreshUtil.java new file mode 100644 index 0000000..7827f7a --- /dev/null +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/FaviconRefreshUtil.java @@ -0,0 +1,22 @@ +package org.ovirt.engine.ui.common; + +import com.google.gwt.dom.client.Node; +import com.google.gwt.user.client.DOM; + +public class FaviconRefreshUtil { + + /** + * Work around Firefox bug + * https://bugzilla.mozilla.org/show_bug.cgi?id=519028 + * (change location.hash leads to location bar icon (favicon) disappearance). + * Simply detach and re-attach the favicon link tag on hashchange. + * Also needs to be called on login as the hashchange event timing + * seems to occur too late there. + */ + public static void refreshFavicon() { + Node favicon = DOM.getElementById("id-link-favicon"); //$NON-NLS-1$ + Node parent = favicon.getParentNode(); + favicon.removeFromParent(); + parent.appendChild(favicon); + } +} diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/system/BaseApplicationInit.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/system/BaseApplicationInit.java index e49c077..1dd7473 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/system/BaseApplicationInit.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/system/BaseApplicationInit.java @@ -1,9 +1,11 @@ package org.ovirt.engine.ui.common.system; import org.ovirt.engine.core.common.businessentities.DbUser; +import org.ovirt.engine.ui.common.FaviconRefreshUtil; import org.ovirt.engine.ui.common.auth.AutoLoginData; import org.ovirt.engine.ui.common.auth.CurrentUser; import org.ovirt.engine.ui.common.auth.CurrentUser.LogoutHandler; +import org.ovirt.engine.ui.common.uicommon.ClientAgentType; import org.ovirt.engine.ui.common.uicommon.FrontendEventsHandlerImpl; import org.ovirt.engine.ui.common.uicommon.FrontendFailureEventListener; import org.ovirt.engine.ui.common.uicommon.model.UiCommonInitEvent; @@ -17,7 +19,10 @@ import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; +import com.google.gwt.event.logical.shared.ValueChangeEvent; +import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.event.shared.EventBus; +import com.google.gwt.user.client.History; import com.google.inject.Provider; /** @@ -39,13 +44,15 @@ private final Provider<T> loginModelProvider; private final LockInteractionManager lockInteractionManager; + protected ClientAgentType clientAgentType; public BaseApplicationInit(ITypeResolver typeResolver, FrontendEventsHandlerImpl frontendEventsHandler, FrontendFailureEventListener frontendFailureEventListener, CurrentUser user, EventBus eventBus, Provider<T> loginModelProvider, - LockInteractionManager lockInteractionManager) { + LockInteractionManager lockInteractionManager, + ClientAgentType clientAgentType) { this.typeResolver = typeResolver; this.frontendEventsHandler = frontendEventsHandler; this.frontendFailureEventListener = frontendFailureEventListener; @@ -53,9 +60,13 @@ this.eventBus = eventBus; this.loginModelProvider = loginModelProvider; this.lockInteractionManager = lockInteractionManager; + this.clientAgentType = clientAgentType; // Handle UI logout requests user.setLogoutHandler(this); + + // workaround favicon-missing bug in Firefox + registerHistoryChangeHandler(); // Initialize UiCommon infrastructure initUiCommon(); @@ -140,6 +151,24 @@ } /** + * Work around Firefox bug + * https://bugzilla.mozilla.org/show_bug.cgi?id=519028 + * (change location.hash leads to location bar icon (favicon) disappearance). + * Simply detach and re-attach the favicon link tag on hashchange. + */ + private void registerHistoryChangeHandler() { + if ("firefox".equalsIgnoreCase(clientAgentType.getBrowser())) { //$NON-NLS-1$ + History.addValueChangeHandler(new ValueChangeHandler<String>() { + + @Override + public void onValueChange(ValueChangeEvent<String> event) { + FaviconRefreshUtil.refreshFavicon(); + } + }); + } + } + + /** * Indicates if all queries triggered through {@link Frontend} should be filtered or not. * <p> * A query that is filtered has its results constrained by user permissions. On the other hand, a query that is not diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/login/presenter/LoginSectionPresenter.java b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/login/presenter/LoginSectionPresenter.java index cabd5b0..90872eb 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/login/presenter/LoginSectionPresenter.java +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/login/presenter/LoginSectionPresenter.java @@ -1,5 +1,6 @@ package org.ovirt.engine.ui.userportal.section.login.presenter; +import org.ovirt.engine.ui.common.FaviconRefreshUtil; import org.ovirt.engine.ui.common.auth.CurrentUser; import org.ovirt.engine.ui.userportal.place.ApplicationPlaces; @@ -42,6 +43,9 @@ protected void onReset() { super.onReset(); + // work around Firefox favicon bug that appears on login screen + FaviconRefreshUtil.refreshFavicon(); + if (user.isLoggedIn()) { placeManager.revealDefaultPlace(); } else { diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/system/ApplicationInit.java b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/system/ApplicationInit.java index 55d0a47..d867222 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/system/ApplicationInit.java +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/system/ApplicationInit.java @@ -29,7 +29,6 @@ private final CurrentUserRole userRole; private final ConnectAutomaticallyManager connectAutomaticallyManager; - private final ClientAgentType clientAgentType; @Inject public ApplicationInit(ITypeResolver typeResolver, @@ -43,10 +42,9 @@ ApplicationDynamicMessages dynamicMessages, ClientAgentType clientAgentType) { super(typeResolver, frontendEventsHandler, frontendFailureEventListener, - user, eventBus, loginModelProvider, lockInteractionManager); + user, eventBus, loginModelProvider, lockInteractionManager, clientAgentType); this.userRole = userRole; this.connectAutomaticallyManager = connectAutomaticallyManager; - this.clientAgentType = clientAgentType; Window.setTitle(dynamicMessages.applicationTitle()); } diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/login/presenter/LoginSectionPresenter.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/login/presenter/LoginSectionPresenter.java index f878df1..3dcfd13 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/login/presenter/LoginSectionPresenter.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/login/presenter/LoginSectionPresenter.java @@ -1,5 +1,6 @@ package org.ovirt.engine.ui.webadmin.section.login.presenter; +import org.ovirt.engine.ui.common.FaviconRefreshUtil; import org.ovirt.engine.ui.common.auth.CurrentUser; import org.ovirt.engine.ui.webadmin.place.ApplicationPlaces; @@ -42,6 +43,9 @@ protected void onReset() { super.onReset(); + // work around Firefox favicon bug that appears on login screen + FaviconRefreshUtil.refreshFavicon(); + if (user.isLoggedIn()) { placeManager.revealDefaultPlace(); } else { diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/system/ApplicationInit.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/system/ApplicationInit.java index aaaeb06..0bbc63e 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/system/ApplicationInit.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/system/ApplicationInit.java @@ -5,6 +5,7 @@ import org.ovirt.engine.ui.common.auth.CurrentUser; import org.ovirt.engine.ui.common.system.BaseApplicationInit; import org.ovirt.engine.ui.common.system.LockInteractionManager; +import org.ovirt.engine.ui.common.uicommon.ClientAgentType; import org.ovirt.engine.ui.common.uicommon.FrontendEventsHandlerImpl; import org.ovirt.engine.ui.common.uicommon.FrontendFailureEventListener; import org.ovirt.engine.ui.common.uicommon.model.CommonModelManager; @@ -41,9 +42,10 @@ Provider<LoginModel> loginModelProvider, LockInteractionManager lockInteractionManager, ApplicationDynamicMessages dynamicMessages, - RestApiSessionManager restApiSessionManager) { + RestApiSessionManager restApiSessionManager, + ClientAgentType clientAgentType) { super(typeResolver, frontendEventsHandler, frontendFailureEventListener, - user, eventBus, loginModelProvider, lockInteractionManager); + user, eventBus, loginModelProvider, lockInteractionManager, clientAgentType); this.restApiSessionManager = restApiSessionManager; Window.setTitle(dynamicMessages.applicationTitle()); -- To view, visit http://gerrit.ovirt.org/20798 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia4b0d8a0176eb9299aec01ae6772297409ef3108 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Greg Sheremeta <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
