Skip to content

Commit

Permalink
Merge pull request #1 from marco-c/desktop_notification_perm
Browse files Browse the repository at this point in the history
Enable desktop-notification permission too
  • Loading branch information
mykmelez committed Nov 12, 2014
2 parents e19615f + 1efa2e9 commit 2178b40
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Introduction
============

This Firefox extension toggles the mozTCPSocket, mozContacts, and mozbrowser
APIs for web pages in Firefox, so you can test Open Web Apps that need access
to those APIs in the browser.
This Firefox extension toggles the mozTCPSocket, mozContacts, mozbrowser and
Notification APIs for web pages in Firefox, so you can test Open Web Apps that
need access to those APIs in the browser.

Install it, then press the "Plug-In" button in your toolbar while the page
in question is loaded into the active tab, and the extension will enable
Expand Down
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const CONTACTS_READ_PERM = "contacts-read";
const CONTACTS_WRITE_PERM = "contacts-write";
const CONTACTS_CREATE_PERM = "contacts-create";
const BROWSER_PERM = "browser";
const DESKTOP_NOTIFICATION_PERM = "desktop-notification";
const LABEL_DISABLED = "mozTCPSocket/mozContacts APIs disabled";
const LABEL_ENABLED = "mozTCPSocket/mozContacts APIs enabled";
const ICON_DISABLED = "./unplugged.svg";
Expand Down Expand Up @@ -58,6 +59,7 @@ var button = ActionButton({
Services.perms.addFromPrincipal(getPrincipal(tabs.activeTab), CONTACTS_WRITE_PERM, Services.perms.ALLOW_ACTION);
Services.perms.addFromPrincipal(getPrincipal(tabs.activeTab), CONTACTS_CREATE_PERM, Services.perms.ALLOW_ACTION);
Services.perms.addFromPrincipal(getPrincipal(tabs.activeTab), BROWSER_PERM, Services.perms.ALLOW_ACTION);
Services.perms.addFromPrincipal(getPrincipal(tabs.activeTab), DESKTOP_NOTIFICATION_PERM, Services.perms.ALLOW_ACTION);
button.state("tab", STATE_ENABLED);
}
else {
Expand All @@ -66,6 +68,7 @@ var button = ActionButton({
Services.perms.removeFromPrincipal(getPrincipal(tabs.activeTab), CONTACTS_WRITE_PERM);
Services.perms.removeFromPrincipal(getPrincipal(tabs.activeTab), CONTACTS_CREATE_PERM);
Services.perms.removeFromPrincipal(getPrincipal(tabs.activeTab), BROWSER_PERM);
Services.perms.removeFromPrincipal(getPrincipal(tabs.activeTab), DESKTOP_NOTIFICATION_PERM);
button.state("tab", STATE_DISABLED);
}
},
Expand All @@ -77,7 +80,8 @@ tabs.on("pageshow", function(tab) {
Services.perms.testPermissionFromPrincipal(getPrincipal(tab), CONTACTS_READ_PERM) == Services.perms.ALLOW_ACTION &&
Services.perms.testPermissionFromPrincipal(getPrincipal(tab), CONTACTS_WRITE_PERM) == Services.perms.ALLOW_ACTION &&
Services.perms.testPermissionFromPrincipal(getPrincipal(tab), CONTACTS_CREATE_PERM) == Services.perms.ALLOW_ACTION &&
Services.perms.testPermissionFromPrincipal(getPrincipal(tab), BROWSER_PERM) == Services.perms.ALLOW_ACTION) {
Services.perms.testPermissionFromPrincipal(getPrincipal(tab), BROWSER_PERM) == Services.perms.ALLOW_ACTION &&
Services.perms.testPermissionFromPrincipal(getPrincipal(tab), DESKTOP_NOTIFICATION_PERM) == Services.perms.ALLOW_ACTION) {
button.state(tab, STATE_ENABLED);
}
else {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"title": "API Enabler",
"name": "tcpsocketpup",
"version": "0.5.0",
"description": "Toggle mozTCPSocket/mozContacts/mozbrowser access for a page.",
"version": "0.6.0",
"description": "Toggle mozTCPSocket/mozContacts/mozbrowser/desktop-notification access for a page.",
"main": "index.js",
"author": "Myk Melez",
"engines": {
Expand Down

0 comments on commit 2178b40

Please sign in to comment.