Bug 804910 - Part 2. Watch for error notification and display recovery UI. r=jaws

This commit is contained in:
Felipe Gomes 2012-10-30 13:10:04 -07:00
parent 51787ffff9
commit 230f94e6ee
3 changed files with 36 additions and 6 deletions

View File

@ -64,6 +64,9 @@
config.tryAgainCallback = loadQueryURL;
config.queryURL = url;
break;
case "workerFailure":
config.tryAgainCallback = reloadProvider;
break;
default:
break;
}
@ -103,7 +106,10 @@
}
function reloadProvider() {
Social.provider.reload();
Social.enabled = false;
Services.tm.mainThread.dispatch(function() {
Social.enabled = true;
}, Components.interfaces.nsIThread.DISPATCH_NORMAL);
}
parseQueryString();

View File

@ -12,6 +12,7 @@ let SocialUI = {
Services.obs.addObserver(this, "social:pref-changed", false);
Services.obs.addObserver(this, "social:ambient-notification-changed", false);
Services.obs.addObserver(this, "social:profile-changed", false);
Services.obs.addObserver(this, "social:frameworker-error", false);
Services.prefs.addObserver("social.sidebar.open", this, false);
Services.prefs.addObserver("social.toast-notifications.enabled", this, false);
@ -29,6 +30,7 @@ let SocialUI = {
Services.obs.removeObserver(this, "social:pref-changed");
Services.obs.removeObserver(this, "social:ambient-notification-changed");
Services.obs.removeObserver(this, "social:profile-changed");
Services.obs.removeObserver(this, "social:frameworker-error");
Services.prefs.removeObserver("social.sidebar.open", this);
Services.prefs.removeObserver("social.toast-notifications.enabled", this);
@ -69,6 +71,12 @@ let SocialUI = {
SocialShareButton.updateProfileInfo();
SocialChatBar.update();
break;
case "social:frameworker-error":
if (Social.provider) {
Social.errorState = "frameworker-error";
SocialSidebar.setSidebarErrorMessage("frameworker-error");
}
break;
case "nsPref:changed":
SocialSidebar.updateSidebar();
SocialToolbar.updateButton();
@ -1001,6 +1009,11 @@ var SocialSidebar = {
);
}
} else {
if (Social.errorState == "frameworker-error") {
SocialSidebar.setSidebarErrorMessage("frameworker-error");
return;
}
// Make sure the right sidebar URL is loaded
if (sbrowser.getAttribute("origin") != Social.provider.origin) {
sbrowser.setAttribute("origin", Social.provider.origin);
@ -1049,10 +1062,18 @@ var SocialSidebar = {
_unloadTimeoutId: 0,
setSidebarErrorMessage: function() {
setSidebarErrorMessage: function(aType) {
let sbrowser = document.getElementById("social-sidebar-browser");
let url = encodeURIComponent(Social.provider.sidebarURL);
sbrowser.loadURI("about:socialerror?mode=tryAgain&url=" + url, null, null);
switch (aType) {
case "sidebar-error":
let url = encodeURIComponent(Social.provider.sidebarURL);
sbrowser.loadURI("about:socialerror?mode=tryAgain&url=" + url, null, null);
break;
case "frameworker-error":
sbrowser.setAttribute("src", "about:socialerror?mode=workerFailure");
break;
}
}
}
@ -1090,7 +1111,7 @@ SocialErrorListener.prototype = {
onLocationChange: function SPL_onLocationChange(aWebProgress, aRequest, aLocation, aFlags) {
let failure = aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_ERROR_PAGE;
if (failure) {
if (failure && Social.errorState != "frameworker-error") {
aRequest.cancel(Components.results.NS_BINDING_ABORTED);
window.setTimeout(function(self) {
self.setErrorMessage(aWebProgress);
@ -1109,7 +1130,7 @@ SocialErrorListener.prototype = {
break;
case "sidebar":
SocialSidebar.setSidebarErrorMessage();
SocialSidebar.setSidebarErrorMessage("sidebar-error");
break;
case "notification-panel":

View File

@ -42,6 +42,9 @@ this.Social = {
},
set enabled(val) {
if (!val) {
delete this.errorState;
}
SocialService.enabled = val;
},
get enabled() {