Bug 805260: turn can't-attach-mozSocialAPI error into a warning, since it's not usually a problem, r=markh

--HG--
extra : transplant_source : %97b%B6B%A8%E4%1F%134%94%C0%7E%E2%A9q%94%E9%BB%C8%80
This commit is contained in:
Gavin Sharp 2012-10-24 17:29:09 -07:00
parent 28c105ccf5
commit 285411706a

View File

@ -59,7 +59,7 @@ function injectController(doc, topic, data) {
}
SocialService.getProvider(origin, function(provider) {
if (provider && provider.workerURL) {
if (provider && provider.workerURL && provider.enabled) {
attachToWindow(provider, window);
}
});
@ -70,14 +70,15 @@ function injectController(doc, topic, data) {
// Loads mozSocial support functions associated with provider into targetWindow
function attachToWindow(provider, targetWindow) {
// If the loaded document isn't from the provider's origin, don't attach
// the mozSocial API.
let origin = provider.origin;
if (!provider.enabled) {
throw new Error("MozSocialAPI: cannot attach disabled provider " + origin);
}
let targetDocURI = targetWindow.document.documentURIObject;
if (provider.origin != targetDocURI.prePath) {
throw new Error("MozSocialAPI: cannot attach " + origin + " to " + targetDocURI.spec);
let msg = "MozSocialAPI: not attaching mozSocial API for " + origin +
" to " + targetDocURI.spec + " since origins differ."
Services.console.logStringMessage(msg);
return;
}
var port = provider.getWorkerPort(targetWindow);
@ -179,6 +180,7 @@ function attachToWindow(provider, targetWindow) {
// set a timer which will fire after the unload events have all fired.
schedule(function () { port.close(); });
});
// We allow window.close() to close the panel, so add an event handler for
// this, then cancel the event (so the window itself doesn't die) and
// close the panel instead.