Skip to content

Commit

Permalink
Added Mobile support and extended compatibility.
Browse files Browse the repository at this point in the history
Supports all current Aurora versions.
Adds support for Firefox Mobile. Removed use of FUEL library because of this.
Moved menu item to the Web Developer submenu.
  • Loading branch information
Jorge Villalobos committed Oct 1, 2011
1 parent f7f6ea2 commit e33f34e
Show file tree
Hide file tree
Showing 12 changed files with 168 additions and 60 deletions.
1 change: 1 addition & 0 deletions extension/Makefile
Expand Up @@ -80,6 +80,7 @@ xpi_built := install.rdf \
$(wildcard locale/*/*.dtd) \ $(wildcard locale/*/*.dtd) \
$(wildcard locale/*/*.properties) \ $(wildcard locale/*/*.properties) \
$(wildcard modules/*.js) \ $(wildcard modules/*.js) \
$(wildcard components/*.js) \
$(template_files) \ $(template_files) \
# defaults/preferences/$(extension_name).js # defaults/preferences/$(extension_name).js


Expand Down
10 changes: 8 additions & 2 deletions extension/chrome.manifest
Expand Up @@ -27,5 +27,11 @@ locale remotexulmanager fr locale/fr/
locale remotexulmanager sv-SE locale/sv-SE/ locale remotexulmanager sv-SE locale/sv-SE/
locale remotexulmanager zh-CN locale/zh-CN/ locale remotexulmanager zh-CN locale/zh-CN/


overlay chrome://browser/content/browser.xul chrome://remotexulmanager/content/rxmBrowserOverlay.xul overlay chrome://browser/content/browser.xul chrome://remotexulmanager/content/rxmBrowserOverlay.xul application!={a23983c0-fd0e-11dc-95ff-0800200c9a66}
overlay chrome://navigator/content/navigator.xul chrome://remotexulmanager/content/rxmBrowserOverlay.xul application={92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}
# Mobile Firefox.
component {aa76f1c0-a902-4afe-ab37-e51d8c6d2e68} components/aboutRXM.js application={a23983c0-fd0e-11dc-95ff-0800200c9a66}
contract @mozilla.org/network/protocol/about;1?what=remotexul {aa76f1c0-a902-4afe-ab37-e51d8c6d2e68} application={a23983c0-fd0e-11dc-95ff-0800200c9a66}

# SeaMonkey.
overlay chrome://navigator/content/navigator.xul chrome://remotexulmanager/content/rxmBrowserOverlay.xul application={92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}
56 changes: 56 additions & 0 deletions extension/components/aboutRXM.js
@@ -0,0 +1,56 @@
/**
* Copyright 2011 Jorge Villalobos
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

const Cc = Components.classes;
const Ci = Components.interfaces;

Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");

/**
* Registers itself as an about: provider, so that about:remotexul points to a
* chrome path in this extension.
*/
function AboutRXM() {}

AboutRXM.prototype = {
classDescription : "about:remotexul",
contractID : "@mozilla.org/network/protocol/about;1?what=remotexul",
classID : Components.ID("{aa76f1c0-a902-4afe-ab37-e51d8c6d2e68}"),

getURIFlags : function(aURI) {
return Ci.nsIAboutModule.ALLOW_SCRIPT;
},

newChannel : function(aURI) {
let ioService =
Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
let channel =
ioService.newChannel(
"chrome://remotexulmanager/content/rxmAbout.xul", null, null);

channel.originalURI = aURI;

return channel;
},

QueryInterface : XPCOMUtils.generateQI([ Ci.nsIAboutModule ])
};

if (XPCOMUtils.generateNSGetFactory) {
var NSGetFactory = XPCOMUtils.generateNSGetFactory([ AboutRXM ]);
} else {
var NSGetModule = XPCOMUtils.generateNSGetModule([ AboutRXM ]);
}
46 changes: 46 additions & 0 deletions extension/content/rxmAbout.xul
@@ -0,0 +1,46 @@
<?xml version="1.0"?>

<!--
- Copyright 2011 Jorge Villalobos
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-->

<?xml-stylesheet type="text/css" href="chrome://global/skin/" ?>
<?xml-stylesheet type="text/css"
href="chrome://remotexulmanager/skin/rxmManager.css" ?>

<!DOCTYPE window SYSTEM "chrome://remotexulmanager/locale/rxmManager.dtd">

<window id="remotexulmanager-about-window"
windowtype="remotexulmanager-about-window"
title="&remotexulmanager.manager.title;"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<script type="application/x-javascript"
src="chrome://remotexulmanager/content/rxmManager.js" />

<vbox id="window-content" flex="1">
<label control="domains" value="&remotexulmanager.allowed.label;" />
<listbox id="domains" rows="15" seltype="multiple"
onselect="RXULMChrome.Manager.select(event);" />
<button id="add" label="&remotexulmanager.add.label;"
accesskey="&remotexulmanager.add.accesskey;"
oncommand="RXULMChrome.Manager.add(event);" />
<button id="remove" disabled="true"
label="&remotexulmanager.remove.label;"
accesskey="&remotexulmanager.remove.accesskey;"
oncommand="RXULMChrome.Manager.remove(event);" />
</vbox>

</window>
7 changes: 3 additions & 4 deletions extension/content/rxmBrowserOverlay.xul
Expand Up @@ -20,16 +20,15 @@


<!DOCTYPE overlay SYSTEM "chrome://remotexulmanager/locale/rxmBrowserOverlay.dtd"> <!DOCTYPE overlay SYSTEM "chrome://remotexulmanager/locale/rxmBrowserOverlay.dtd">


<overlay id="powersearchbox-browser-overlay" <overlay id="rxm-browser-overlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">


<script type="application/x-javascript" <script type="application/x-javascript"
src="chrome://remotexulmanager/content/rxmBrowserOverlay.js" /> src="chrome://remotexulmanager/content/rxmBrowserOverlay.js" />


<!-- Main menu. --> <!-- Main menu. -->
<menupopup id="menu_ToolsPopup"> <menupopup id="menuWebDeveloperPopup">
<menuitem id="rxm-main-menu" <menuitem id="rxm-main-menu" insertbefore="devToolsEndSeparator"
insertafter="javascriptConsole,devToolsSeparator"
label="&rxm.menu.label;" accesskey="&rxm.menu.accesskey;" label="&rxm.menu.label;" accesskey="&rxm.menu.accesskey;"
oncommand="RXULMChrome.BrowserOverlay.launchManager(event);" /> oncommand="RXULMChrome.BrowserOverlay.launchManager(event);" />
</menupopup> </menupopup>
Expand Down
11 changes: 9 additions & 2 deletions extension/content/rxmManager.js
Expand Up @@ -96,7 +96,10 @@ RXULMChrome.Manager = {
domains.appendChild(item); domains.appendChild(item);
} }


generateItem.disabled = (0 == allowedCount); // null in the about:remotexul window.
if (null != generateItem) {
generateItem.disabled = (0 == allowedCount);
}
} catch (e) { } catch (e) {
this._logger.error("_loadPermissions\n" + e); this._logger.error("_loadPermissions\n" + e);
} }
Expand Down Expand Up @@ -198,7 +201,11 @@ RXULMChrome.Manager = {
let listbox = document.getElementById("domains"); let listbox = document.getElementById("domains");


removeButton.disabled = (0 == listbox.selectedCount); removeButton.disabled = (0 == listbox.selectedCount);
exportMenu.disabled = (0 == listbox.selectedCount);
// null in the about:remotexul window.
if (null != exportMenu) {
exportMenu.disabled = (0 == listbox.selectedCount);
}
}, },


/** /**
Expand Down
19 changes: 14 additions & 5 deletions extension/install.rdf
Expand Up @@ -23,7 +23,7 @@
<em:id>remotexulmanager@xulforge.com</em:id> <em:id>remotexulmanager@xulforge.com</em:id>
<em:name>Remote XUL Manager</em:name> <em:name>Remote XUL Manager</em:name>
<em:description>Manages the Remote XUL whitelist.</em:description> <em:description>Manages the Remote XUL whitelist.</em:description>
<em:version>1.0.2</em:version> <em:version>1.1</em:version>
<em:creator>Jorge Villalobos</em:creator> <em:creator>Jorge Villalobos</em:creator>
<em:homepageURL>http://github.com/jvillalobos/Remote-XUL-Manager</em:homepageURL> <em:homepageURL>http://github.com/jvillalobos/Remote-XUL-Manager</em:homepageURL>
<em:type>2</em:type> <em:type>2</em:type>
Expand All @@ -32,17 +32,26 @@
<em:targetApplication> <em:targetApplication>
<Description> <Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>4.0b9</em:minVersion> <em:minVersion>6.0</em:minVersion>
<em:maxVersion>6.*</em:maxVersion> <em:maxVersion>9.*</em:maxVersion>
</Description> </Description>
</em:targetApplication> </em:targetApplication>


<!-- SeaMonkey --> <!-- SeaMonkey -->
<em:targetApplication> <em:targetApplication>
<Description> <Description>
<em:id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</em:id> <em:id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</em:id>
<em:minVersion>2.1b2</em:minVersion> <em:minVersion>2.2</em:minVersion>
<em:maxVersion>2.2.*</em:maxVersion> <em:maxVersion>2.6.*</em:maxVersion>
</Description>
</em:targetApplication>

<!-- Firefox Mobile -->
<em:targetApplication>
<Description>
<em:id>{a23983c0-fd0e-11dc-95ff-0800200c9a66}</em:id>
<em:minVersion>6.0</em:minVersion>
<em:maxVersion>9.*</em:maxVersion>
</Description> </Description>
</em:targetApplication> </em:targetApplication>


Expand Down
31 changes: 8 additions & 23 deletions extension/modules/rxmCommon.js
Expand Up @@ -24,10 +24,8 @@ const Ci = Components.interfaces;
*/ */
if ("undefined" == typeof(RXULM)) { if ("undefined" == typeof(RXULM)) {
var RXULM = { var RXULM = {
/* The root branch for all RXM preferences. */ /* The preferences service. */
get PREF_BRANCH() { return "extensions.rxulm."; }, _prefService : null,
/* The FUEL Application object. */
_application : null,
/* Array of timer references, keeps timeouts alive. */ /* Array of timer references, keeps timeouts alive. */
_timers : [], _timers : [],


Expand Down Expand Up @@ -104,28 +102,15 @@ if ("undefined" == typeof(RXULM)) {
}, },


/** /**
* Gets the FUEL Application object. * Gets the preferences service.
*/ */
get Application() { get prefService() {
if (null == this._application) { if (null == this._prefService) {
if (null != Cc["@mozilla.org/fuel/application;1"]) { this._prefService =
// Firefox and Flock. Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
this._application =
Cc["@mozilla.org/fuel/application;1"].
getService(Ci.fuelIApplication);
} else if (null != Cc["@mozilla.org/smile/application;1"]) {
// SeaMonkey.
this._application =
Cc["@mozilla.org/smile/application;1"].
getService(Ci.smileIApplication);
} else {
// Other?
this._logger.fatal(
"get Application: Couldn't load FUEL or equivalent.");
}
} }


return this._application; return this._prefService;
}, },


/** /**
Expand Down
14 changes: 10 additions & 4 deletions extension/modules/rxmPermissions.js
Expand Up @@ -70,7 +70,13 @@ RXULM.Permissions = {


try { try {
let enumerator = this._permissionManager.enumerator; let enumerator = this._permissionManager.enumerator;
let localFilePref = RXULM.Application.prefs.get(LOCAL_FILE_PREF); let allowLocalFiles = false;

try {
allowLocalFiles = RXULM.prefService.getBoolPref(LOCAL_FILE_PREF);
} catch (e) {
this._logger.info("getAll. No value for local files pref.");
}


while (enumerator.hasMoreElements()) { while (enumerator.hasMoreElements()) {
permission = enumerator.getNext().QueryInterface(Ci.nsIPermission); permission = enumerator.getNext().QueryInterface(Ci.nsIPermission);
Expand All @@ -81,7 +87,7 @@ RXULM.Permissions = {
} }
} }


if ((null != localFilePref) && localFilePref.value) { if (allowLocalFiles) {
list.push(this.LOCAL_FILES); list.push(this.LOCAL_FILES);
} }
} catch (e) { } catch (e) {
Expand All @@ -107,7 +113,7 @@ RXULM.Permissions = {


this._permissionManager.add(uri, ALLOW_REMOTE_XUL, ALLOW); this._permissionManager.add(uri, ALLOW_REMOTE_XUL, ALLOW);
} else { } else {
RXULM.Application.prefs.setValue(LOCAL_FILE_PREF, true); RXULM.prefService.setBoolPref(LOCAL_FILE_PREF, true);
} }


success = true; success = true;
Expand All @@ -132,7 +138,7 @@ RXULM.Permissions = {
if (this.LOCAL_FILES != aDomain) { if (this.LOCAL_FILES != aDomain) {
this._permissionManager.remove(aDomain, ALLOW_REMOTE_XUL); this._permissionManager.remove(aDomain, ALLOW_REMOTE_XUL);
} else { } else {
RXULM.Application.prefs.setValue(LOCAL_FILE_PREF, false); RXULM.prefService.setBoolPref(LOCAL_FILE_PREF, false);
} }


success = true; success = true;
Expand Down
4 changes: 4 additions & 0 deletions extension/skin/rxmManager.css
Expand Up @@ -18,6 +18,10 @@
height: 16em; height: 16em;
} }


#remotexulmanager-about-window > #domains {
height: 8em;
}

#window-content { #window-content {
padding: 1em; padding: 1em;
} }
Expand Down
17 changes: 3 additions & 14 deletions installer/bootstrap.js
Expand Up @@ -125,21 +125,10 @@ var RXULMInstaller = {
uri = this._ioService.newURI(aDomain, null, null); uri = this._ioService.newURI(aDomain, null, null);
this._permissionManager.add(uri, this.ALLOW_REMOTE_XUL, this.ALLOW); this._permissionManager.add(uri, this.ALLOW_REMOTE_XUL, this.ALLOW);
} else { } else {
let application; let prefService =

Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
if (null != Cc["@mozilla.org/fuel/application;1"]) {
// Firefox and Flock.
application =
Cc["@mozilla.org/fuel/application;1"].
getService(Ci.fuelIApplication);
} else if (null != Cc["@mozilla.org/smile/application;1"]) {
// SeaMonkey.
application =
Cc["@mozilla.org/smile/application;1"].
getService(Ci.smileIApplication);
}


application.prefs.setValue(this.LOCAL_FILE_PREF, true); prefService.setBoolPref(this.LOCAL_FILE_PREF, true);
} }
} catch (e) { } catch (e) {
this._showAlert( this._showAlert(
Expand Down
12 changes: 6 additions & 6 deletions installer/install.rdf
Expand Up @@ -33,26 +33,26 @@
<em:targetApplication> <em:targetApplication>
<Description> <Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>4.0b6</em:minVersion> <em:minVersion>4.0</em:minVersion>
<em:maxVersion>6.*</em:maxVersion> <em:maxVersion>9.*</em:maxVersion>
</Description> </Description>
</em:targetApplication> </em:targetApplication>


<!-- SeaMonkey --> <!-- SeaMonkey -->
<em:targetApplication> <em:targetApplication>
<Description> <Description>
<em:id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</em:id> <em:id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</em:id>
<em:minVersion>2.1b2</em:minVersion> <em:minVersion>2.2</em:minVersion>
<em:maxVersion>2.2.*</em:maxVersion> <em:maxVersion>2.6.*</em:maxVersion>
</Description> </Description>
</em:targetApplication> </em:targetApplication>


<!-- Firefox Mobile --> <!-- Firefox Mobile -->
<em:targetApplication> <em:targetApplication>
<Description> <Description>
<em:id>{a23983c0-fd0e-11dc-95ff-0800200c9a66}</em:id> <em:id>{a23983c0-fd0e-11dc-95ff-0800200c9a66}</em:id>
<em:minVersion>4.0</em:minVersion> <em:minVersion>6.0</em:minVersion>
<em:maxVersion>6.*</em:maxVersion> <em:maxVersion>9.*</em:maxVersion>
</Description> </Description>
</em:targetApplication> </em:targetApplication>


Expand Down

0 comments on commit e33f34e

Please sign in to comment.