36 const Cc = Components.classes;
37 const Ci = Components.interfaces;
40 Components.utils.import(
"resource://app/jsmodules/StringUtils.jsm");
48 var sbs =
Cc[
"@mozilla.org/intl/stringbundle;1"]
49 .getService(
Ci.nsIStringBundleService);
50 var songbirdStrings = sbs.createBundle(
"chrome://songbird/locale/songbird.properties");
51 var brandingStrings = sbs.createBundle(
"chrome://branding/locale/brand.properties");
60 var notificationName =
"remoteapi-called";
62 "Web Page has accessed %S directly",
64 var editOptionsLabel =
SBString(
"rapi.access.button.label.options",
67 var editOptionsAccessKey =
SBString(
"rapi.access.button.accessKey.options",
70 var allowAlwaysLabel =
SBString(
"rapi.access.button.label.allow.always",
73 var iconURL =
SBString(
"rapi.access.iconURL",
"", brandingStrings);
74 var appName =
SBString(
"brandShortName",
"Songbird", songbirdStrings);
76 message = message.replace(/\%S/, appName);
79 var
doc =
event.currentTarget.document;
81 var allowAlwaysCallback =
function(aHat, aButtonInfo) {
83 var permManager = Components.classes[
"@mozilla.org/permissionmanager;1"]
84 .getService(nsIPermissionManager);
85 permManager.add(closure.siteScope,
"rapi." + closure.categoryID, nsIPermissionManager.ALLOW_ACTION);
87 var allowEvt = Components.classes[
"@songbirdnest.com/remoteapi/security-event;1"]
88 .createInstance(Components.interfaces.sbIMutableRemoteSecurityEvent);
90 allowEvt.initSecurityEvent( doc,
96 aHat.closeEvent = allowEvt;
99 var editOptionsCallback =
function(aHat, aButtonInfo) {
100 var editEvt = Components.classes[
"@songbirdnest.com/remoteapi/security-event;1"]
101 .createInstance(Components.interfaces.sbIMutableRemoteSecurityEvent);
104 editEvt.initSecurityEvent( doc,
110 aHat.closeEvent = editEvt;
112 var prefWindow = SBOpenPreferences(
"paneRemoteAPI");
113 if (prefWindow.gRemoteAPIPane) {
116 prefWindow.gRemoteAPIPane.configureWhitelist(closure.categoryID,
117 closure.siteScope.spec);
121 prefWindow.pleaseConfigureWhitelist =
122 [closure.categoryID, closure.siteScope.spec];
128 label: editOptionsLabel,
129 accessKey: editOptionsAccessKey,
134 label: allowAlwaysLabel,
141 var
tabbrowser =
event.currentTarget.gBrowser;
142 var
browser = tabbrowser.getBrowserForDocument(
event.target);
143 var notificationBox = tabbrowser.getNotificationBox(browser);
144 const priority = notificationBox.PRIORITY_WARNING_MEDIUM;
145 var notification = tabbrowser.showNotification(browser, notificationName,
146 message, iconURL, priority,
149 var defaultEvt = Components.classes[
"@songbirdnest.com/remoteapi/security-event;1"]
150 .createInstance(Components.interfaces.sbIMutableRemoteSecurityEvent);
152 defaultEvt.initSecurityEvent( doc,
158 notification.closeEvent = defaultEvt;
function doc() browser.contentDocument
function onRemoteAPI(event)
function SBString(aKey, aDefault, aStringBundle)
this _contentSandbox label
const nsIPermissionManager