Bug 794512 - Add a checkbox and preference to disable toast notifications for the Social API. r=markh
This commit is contained in:
@@ -1181,5 +1181,6 @@ pref("social.manifest.motown", "{\"origin\":\"https://motown-dev.mozillalabs.com
|
||||
pref("social.activation.whitelist", "https://motown-dev.mozillalabs.com");
|
||||
pref("social.sidebar.open", true);
|
||||
pref("social.active", false);
|
||||
pref("social.toast-notifications.enabled", true);
|
||||
|
||||
pref("dom.identity.enabled", false);
|
||||
|
||||
@@ -109,6 +109,7 @@
|
||||
<command id="Social:SharePage" oncommand="SocialShareButton.sharePage();"/>
|
||||
<command id="Social:UnsharePage" oncommand="SocialShareButton.unsharePage();"/>
|
||||
<command id="Social:ToggleSidebar" oncommand="Social.toggleSidebar();"/>
|
||||
<command id="Social:ToggleNotifications" oncommand="Social.toggleNotifications();"/>
|
||||
<command id="Social:Toggle" oncommand="Social.toggle();" hidden="true"/>
|
||||
</commandset>
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ let SocialUI = {
|
||||
Services.obs.addObserver(this, "social:profile-changed", false);
|
||||
|
||||
Services.prefs.addObserver("social.sidebar.open", this, false);
|
||||
Services.prefs.addObserver("social.toast-notifications.enabled", this, false);
|
||||
|
||||
gBrowser.addEventListener("ActivateSocialFeature", this._activationEventHandler, true, true);
|
||||
|
||||
@@ -23,6 +24,7 @@ let SocialUI = {
|
||||
Services.obs.removeObserver(this, "social:profile-changed");
|
||||
|
||||
Services.prefs.removeObserver("social.sidebar.open", this);
|
||||
Services.prefs.removeObserver("social.toast-notifications.enabled", this);
|
||||
},
|
||||
|
||||
showProfile: function SocialUI_showProfile() {
|
||||
@@ -57,6 +59,7 @@ let SocialUI = {
|
||||
break;
|
||||
case "nsPref:changed":
|
||||
SocialSidebar.updateSidebar();
|
||||
SocialToolbar.updateButton();
|
||||
}
|
||||
},
|
||||
|
||||
@@ -589,6 +592,9 @@ var SocialToolbar = {
|
||||
let notificationFrames = document.createDocumentFragment();
|
||||
let iconContainers = document.createDocumentFragment();
|
||||
|
||||
let command = document.getElementById("Social:ToggleNotifications");
|
||||
command.setAttribute("checked", Services.prefs.getBoolPref("social.toast-notifications.enabled"));
|
||||
|
||||
for each(let name in iconNames) {
|
||||
let icon = provider.ambientNotificationIcons[name];
|
||||
|
||||
|
||||
@@ -684,6 +684,12 @@
|
||||
command="Social:ToggleSidebar"
|
||||
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;"/>
|
||||
</menupopup>
|
||||
</button>
|
||||
<hbox id="social-status-iconbox" flex="1">
|
||||
|
||||
@@ -651,5 +651,8 @@ toolbar button -->
|
||||
<!ENTITY social.toggleSidebar.label "Show sidebar">
|
||||
<!ENTITY social.toggleSidebar.accesskey "s">
|
||||
|
||||
<!ENTITY social.toggleNotifications.label "Show desktop notifications">
|
||||
<!ENTITY social.toggleNotifications.accesskey "n">
|
||||
|
||||
<!ENTITY social.activated.undobutton.label "Undo">
|
||||
<!ENTITY social.activated.undobutton.accesskey "U">
|
||||
|
||||
@@ -62,6 +62,11 @@ let Social = {
|
||||
Services.prefs.setBoolPref("social.sidebar.open", !prefValue);
|
||||
},
|
||||
|
||||
toggleNotifications: function SocialNotifications_toggle() {
|
||||
let prefValue = Services.prefs.getBoolPref("social.toast-notifications.enabled");
|
||||
Services.prefs.setBoolPref("social.toast-notifications.enabled", !prefValue);
|
||||
},
|
||||
|
||||
// Sharing functionality
|
||||
_getShareablePageUrl: function Social_getShareablePageUrl(aURI) {
|
||||
let uri = aURI.clone();
|
||||
|
||||
@@ -75,6 +75,9 @@ WorkerAPI.prototype = {
|
||||
openChatWindow(xulWindow, this._provider, data, null, "minimized");
|
||||
},
|
||||
'social.notification-create': function(data) {
|
||||
if (!Services.prefs.getBoolPref("social.toast-notifications.enabled"))
|
||||
return;
|
||||
|
||||
let port = this._port;
|
||||
let provider = this._provider;
|
||||
let {id, type, icon, body, action, actionArgs} = data;
|
||||
|
||||
Reference in New Issue
Block a user