Bug 803344 - Add a menuitem in the social toolbar button menu to disable the Social API with confirmation. r+a=gavin
--- a/browser/base/content/browser-social.js
+++ b/browser/base/content/browser-social.js
@@ -199,16 +199,35 @@ let SocialUI = {
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShell)
.chromeEventHandler;
let containerParent = container.parentNode;
if (containerParent.classList.contains("social-panel") &&
containerParent instanceof Ci.nsIDOMXULPopupElement) {
containerParent.hidePopup();
}
+ },
+
+ disableWithConfirmation: function SocialUI_disableWithConfirmation() {
+ let brandShortName = document.getElementById("bundle_brand").getString("brandShortName");
+ let dialogTitle = gNavigatorBundle.getFormattedString("social.remove.confirmationOK",
+ [Social.provider.name]);
+ let text = gNavigatorBundle.getFormattedString("social.remove.confirmationLabel",
+ [Social.provider.name, brandShortName]);
+ let okButtonText = dialogTitle;
+
+ let ps = Services.prompt;
+ let flags = ps.BUTTON_TITLE_IS_STRING * ps.BUTTON_POS_0 +
+ ps.BUTTON_TITLE_CANCEL * ps.BUTTON_POS_1 +
+ ps.BUTTON_POS_0_DEFAULT;
+
+ let confirmationIndex = ps.confirmEx(null, dialogTitle, text, flags,
+ okButtonText, null, null, null, {});
+ if (confirmationIndex == 0)
+ Social.active = false;
}
}
let SocialChatBar = {
get chatbar() {
return document.getElementById("pinnedchats");
},
// Whether the chats can be shown for this window.
@@ -653,16 +672,25 @@ var SocialMenu = {
}
}
};
var SocialToolbar = {
// Called once, after window load, when the Social.provider object is initialized
init: function SocialToolbar_init() {
this.button.setAttribute("image", Social.provider.iconURL);
+
+ let removeItem = document.getElementById("social-remove-menuitem");
+ let brandShortName = document.getElementById("bundle_brand").getString("brandShortName");
+ let label = gNavigatorBundle.getFormattedString("social.remove.label",
+ [brandShortName]);
+ let accesskey = gNavigatorBundle.getString("social.remove.accesskey");
+ removeItem.setAttribute("label", label);
+ removeItem.setAttribute("accesskey", accesskey);
+
this.updateButton();
this.updateProfile();
this._dynamicResizer = new DynamicResizeWatcher();
},
get button() {
return document.getElementById("social-provider-button");
},
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -686,16 +686,19 @@
label="&social.toggleSidebar.label;"
accesskey="&social.toggleSidebar.accesskey;"/>
<menuitem id="social-toggle-notifications-menuitem"
type="checkbox"
autocheck="false"
command="Social:ToggleNotifications"
label="&social.toggleNotifications.label;"
accesskey="&social.toggleNotifications.accesskey;"/>
+ <menuseparator/>
+ <menuitem id="social-remove-menuitem"
+ oncommand="SocialUI.disableWithConfirmation();"/>
</menupopup>
</toolbarbutton>
</toolbaritem>
<toolbaritem id="bookmarks-menu-button-container"
class="chromeclass-toolbar-additional"
removable="true"
title="&bookmarksMenuButton.label;">
--- a/browser/locales/en-US/chrome/browser/browser.properties
+++ b/browser/locales/en-US/chrome/browser/browser.properties
@@ -389,16 +389,24 @@ fullscreen.rememberDecision=Remember dec
# LOCALIZATION NOTE (social.toggle.label): %1$S is the name of the social provider, %2$S is brandShortName (e.g. Firefox)
social.toggle.label=%1$S for %2$S
social.toggle.accesskey=f
# LOCALIZATION NOTE (social.activated.description): %1$S is the name of the social provider, %2$S is brandShortName (e.g. Firefox)
social.activated.description=You've turned on %1$S for %2$S.
+# LOCALIZATION NOTE (social.remove.label): %S = brandShortName
+social.remove.label=Remove from %S
+social.remove.accesskey=R
+# LOCALIZATION NOTE (social.remove.confirmationLabel): %1$S is the name of the social provider, %2$S is brandShortName (e.g. Firefox)
+social.remove.confirmationLabel=Are you sure you want to remove %1$S for %2$S?
+# LOCALIZATION NOTE (social.remove.confirmationOK): %S is the name of the social provider
+social.remove.confirmationOK=Remove %S
+
# LOCALIZATION NOTE (social.error.message): %1$S is brandShortName (e.g. Firefox), %2$S is the name of the social provider
social.error.message=%1$S is unable to connect with %2$S right now.
social.error.tryAgain.label=Try Again
social.error.tryAgain.accesskey=T
social.error.ok.label=OK
social.error.ok.accesskey=O
social.error.closeSidebar.label=Close This Sidebar
social.error.closeSidebar.accesskey=C