diff --git a/browser/base/content/browser-social.js b/browser/base/content/browser-social.js index f1ad9efbf9aa..e714adfba894 100644 --- a/browser/base/content/browser-social.js +++ b/browser/base/content/browser-social.js @@ -40,6 +40,7 @@ let SocialUI = { SocialShareButton.updateButtonHiddenState(); SocialToolbar.updateButtonHiddenState(); SocialSidebar.updateSidebar(); + SocialChatBar.update(); } catch (e) { Components.utils.reportError(e); throw e; @@ -157,6 +158,27 @@ let SocialUI = { } } +let SocialChatBar = { + get chatbar() { + return document.getElementById("pinnedchats"); + }, + // Whether the chats can be shown for this window. + get canShow() { + let docElem = document.documentElement; + let chromeless = docElem.getAttribute("disablechrome") || + docElem.getAttribute("chromehidden").indexOf("extrachrome") >= 0; + return Social.uiVisible && !chromeless; + }, + newChat: function(aProvider, aURL, aCallback) { + if (this.canShow) + this.chatbar.newChat(aProvider, aURL, aCallback); + }, + update: function() { + if (!this.canShow) + this.chatbar.removeAll(); + } +} + let SocialShareButton = { // Called once, after window load, when the Social.provider object is initialized init: function SSB_init() { diff --git a/browser/base/content/browser.css b/browser/base/content/browser.css index 7c222ea59bba..c0166b7d5d5c 100644 --- a/browser/base/content/browser.css +++ b/browser/base/content/browser.css @@ -615,3 +615,12 @@ stack[anonid=browserStack][responsivemode] { stack[anonid=browserStack][responsivemode][notransition] { transition: none; } + +chatbox { + -moz-binding: url("chrome://browser/content/socialchat.xml#chatbox"); +} + +chatbar { + -moz-binding: url("chrome://browser/content/socialchat.xml#chatbar"); + height: 0; +} diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index e566b7935ce0..5f5f8c78c899 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -3161,6 +3161,52 @@ const DOMLinkHandler = { break; } }, + getLinkIconURI: function(aLink) { + let targetDoc = aLink.ownerDocument; + var uri = makeURI(aLink.href, targetDoc.characterSet); + + // Verify that the load of this icon is legal. + // Some error or special pages can load their favicon. + // To be on the safe side, only allow chrome:// favicons. + var isAllowedPage = [ + /^about:neterror\?/, + /^about:blocked\?/, + /^about:certerror\?/, + /^about:home$/, + ].some(function (re) re.test(targetDoc.documentURI)); + + if (!isAllowedPage || !uri.schemeIs("chrome")) { + var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"]. + getService(Ci.nsIScriptSecurityManager); + try { + ssm.checkLoadURIWithPrincipal(targetDoc.nodePrincipal, uri, + Ci.nsIScriptSecurityManager.DISALLOW_SCRIPT); + } catch(e) { + return null; + } + } + + try { + var contentPolicy = Cc["@mozilla.org/layout/content-policy;1"]. + getService(Ci.nsIContentPolicy); + } catch(e) { + return null; // Refuse to load if we can't do a security check. + } + + // Security says okay, now ask content policy + if (contentPolicy.shouldLoad(Ci.nsIContentPolicy.TYPE_IMAGE, + uri, targetDoc.documentURIObject, + aLink, aLink.type, null) + != Ci.nsIContentPolicy.ACCEPT) + return null; + + try { + uri.userPass = ""; + } catch(e) { + // some URIs are immutable + } + return uri; + }, onLinkAdded: function (event) { var link = event.originalTarget; var rel = link.rel && link.rel.toLowerCase(); @@ -3194,54 +3240,20 @@ const DOMLinkHandler = { if (!gPrefService.getBoolPref("browser.chrome.site_icons")) break; - var targetDoc = link.ownerDocument; - var uri = makeURI(link.href, targetDoc.characterSet); + var uri = this.getLinkIconURI(link); + if (!uri) + break; if (gBrowser.isFailedIcon(uri)) break; - // Verify that the load of this icon is legal. - // Some error or special pages can load their favicon. - // To be on the safe side, only allow chrome:// favicons. - var isAllowedPage = [ - /^about:neterror\?/, - /^about:blocked\?/, - /^about:certerror\?/, - /^about:home$/, - ].some(function (re) re.test(targetDoc.documentURI)); - - if (!isAllowedPage || !uri.schemeIs("chrome")) { - var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"]. - getService(Ci.nsIScriptSecurityManager); - try { - ssm.checkLoadURIWithPrincipal(targetDoc.nodePrincipal, uri, - Ci.nsIScriptSecurityManager.DISALLOW_SCRIPT); - } catch(e) { - break; - } - } - - try { - var contentPolicy = Cc["@mozilla.org/layout/content-policy;1"]. - getService(Ci.nsIContentPolicy); - } catch(e) { - break; // Refuse to load if we can't do a security check. - } - - // Security says okay, now ask content policy - if (contentPolicy.shouldLoad(Ci.nsIContentPolicy.TYPE_IMAGE, - uri, targetDoc.documentURIObject, - link, link.type, null) - != Ci.nsIContentPolicy.ACCEPT) - break; - - var browserIndex = gBrowser.getBrowserIndexForDocument(targetDoc); + var browserIndex = gBrowser.getBrowserIndexForDocument(link.ownerDocument); // no browser? no favicon. if (browserIndex == -1) break; let tab = gBrowser.tabs[browserIndex]; - gBrowser.setIcon(tab, link.href); + gBrowser.setIcon(tab, uri.spec); iconAdded = true; } break; diff --git a/browser/base/content/browser.xul b/browser/base/content/browser.xul index 28d74bdc7f33..9573c0867801 100644 --- a/browser/base/content/browser.xul +++ b/browser/base/content/browser.xul @@ -1051,6 +1051,7 @@ contentcontextmenu="contentAreaContextMenu" autocompletepopup="PopupAutoComplete" onclick="contentAreaClick(event, false);"/> +