0

This is a firefox-addon question, just tagging osx for ya.

On MacOS X I have copied the all contents of /Applications/Firefox.app to /Users/noit/Desktop/custom profile.app. Except all files are copied as alias (folders are copied as folders). Only non-alias file is the icon in custom profile.app/Contents/Resources/firefox.icns, i overrwrite that one with custom icon. (Well to be accurate, the plist.info is copied but CFBundleExecutable is changed to a new exec i place in the MacOS folder, which launches the firefox from MacOS with command line arguments to ensure right profile launches)

This allows me to run a seperate profile as a "shortcut". Now if user "Keeps in Dock" the dock icon that shows, or on restart of computer marks "Re-open windows from last time", or if user right clicks dock icon and says "Open at log in", or if user restarts Firefox it properly launches back into right profile. Added bonus is it obeys the custom icon.

Some issues when running a profile out of here:

  • On update, the files are written to the /Desktop/custom profile.app, not the Applications/Firefox.app. So right now on browser startup, i test if its first time starting up in update profile, and if so, then I ensure to copy the newly made files back to Applications/Firefox.app and set them as alias's in my /Desktop/custom profile.app. __Is there any way for me to change the path so it updates to Applications/Firefox.app?
  • The other issue is, some special paths are now pointing differently, like FileUtils.getFile('XREExeF', []).path is now /Desktop/custom profile.app/Contents/MacOS/firefox instead of Applications/Firefox.app/...., is there anyway for me to change this to be the Applications path?

Thanks

EDIT:

Here is a diff between the regular app on right and alias copied app on left:

https://www.diffchecker.com/lihx3o8w

So the keys that got changed are a total of 20:

Key             Regular.app                                                                 Alias.app
`XREExeF`       `/Applications/Firefox.app/Contents/MacOS/firefox`                          `/Users/noit/Desktop/Firefox - dev.app/Contents/MacOS/firefox`
`ProfLDS`       `/Users/noit/Library/Caches/Firefox/Profiles/jv5ijq47.Unnamed Profile 1`    `/Users/noit/Library/Application Support/Firefox/Profiles/jv5ijq47.Unnamed Profile 1`
`XREAppDist`    `/Applications/Firefox.app/Contents/Resources/distribution`                 `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources/distribution`
`UpdRootD`      `/Users/noit/Library/Caches/Mozilla/updates/Applications/Firefox`           `/Users/noit/Library/Caches/Mozilla/updates/Users/noit/Desktop/Firefox - dev`
`DefRt`         `/Applications/Firefox.app/Contents/Resources/browser/defaults`             `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources/browser/defaults`
`PrfDef`        `/Applications/Firefox.app/Contents/Resources/defaults/pref`                `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources/defaults/pref`
`profDef`       `/Applications/Firefox.app/Contents/Resources/browser/defaults/profile`     `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources/browser/defaults/profile`
`ProfDefNoLoc`  `/Applications/Firefox.app/Contents/Resources/browser/defaults/profile`     `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources/browser/defaults/profile`
`ARes`          `/Applications/Firefox.app/Contents/Resources/browser/res`                  `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources/browser/res`
`AChrom`        `/Applications/Firefox.app/Contents/Resources/browser/chrome`               `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources/browser/chrome`
`APlugns`       `/Applications/Firefox.app/Contents/Resources/browser/plugins`              `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources/browser/plugins`
`SrchPlugns`    `/Applications/Firefox.app/Contents/Resources/browser/searchplugins`        `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources/browser/searchplugins`
`ProfLD`        `/Users/noit/Library/Caches/Firefox/Profiles/jv5ijq47.Unnamed Profile 1`    `/Users/noit/Library/Application Support/Firefox/Profiles/jv5ijq47.Unnamed Profile 1`
`XPIClnupD`     `/Applications/Firefox.app/Contents/Resources/browser`                      `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources/browser`
`CurProcD`      `/Applications/Firefox.app/Contents/Resources/browser`                      `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources/browser`
`XCurProcD`     `/Applications/Firefox.app/Contents/Resources/browser`                      `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources/browser`
`XpcomLib`      `/Applications/Firefox.app/Contents/MacOS/XUL`                              `/Users/noit/Desktop/Firefox - dev.app/Contents/MacOS/XUL`
`GreD`          `/Applications/Firefox.app/Contents/Resources`                              `/Users/noit/Desktop/Firefox - dev.app/Contents/Resources`
`GreBinD`       `/Applications/Firefox.app/Contents/MacOS`                                  `/Users/noit/Desktop/Firefox - dev.app/Contents/MacOS`
Noitidart
  • 35,443
  • 37
  • 154
  • 323
  • If you would like to create a profile launcher with this method (to experiment with or whatever) you can do so by copying and pasting this code. [GitHubGIST :: Noitidart / _ff-addon-snippet-macProfileLauncherAliasApp.js](https://gist.github.com/Noitidart/bac41811fe797e1a0041) – Noitidart Feb 05 '15 at 05:19
  • I feel im getting close here: https://dxr.mozilla.org/mozilla-central/source/toolkit/mozapps/update/tests/unit_aus_update/head_update.js#3389 but im not sure how to use that, anyone any ideas? – Noitidart Feb 06 '15 at 02:24

1 Answers1

0

I think I'm going in the right direction: https://dxr.mozilla.org/mozilla-central/source/toolkit/mozapps/update/tests/unit_aus_update/head_update.js#3389

If you copy paste this code below it will replace the path if you do: Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties).get('XREExeF', Ci.nsIFile).path; but if you do FileUtils.getFile('XREExeF', []) it throws

[Exception... "Component returned failure code: 0x80520015 (NS_ERROR_FILE_ACCESS_DENIED) [nsIFile.create]" nsresult: "0x80520015 (NS_ERROR_FILE_ACCESS_DENIED)" location: "JS frame :: resource://gre/modules/FileUtils.jsm :: FileUtils_getDir :: line 70" data: no]

Any ideas on how to fix this error?

I think im really on the right track! wee thanks! :D

function do_get_file(path, allowNonexistent) { //https://dxr.mozilla.org/mozilla-central/source/mobile/android/base/tests/robocop_head.js#803
  try {
    let lf = Components.classes["@mozilla.org/file/directory_service;1"]
      .getService(Components.interfaces.nsIProperties)
      .get("CurWorkD", Components.interfaces.nsILocalFile);

    let bits = path.split("/");
    for (let i = 0; i < bits.length; i++) {
      if (bits[i]) {
        if (bits[i] == "..")
          lf = lf.parent;
        else
          lf.append(bits[i]);
      }
    }

    if (!allowNonexistent && !lf.exists()) {
      // Not using do_throw(): caller will continue.
      _passed = false;
      var stack = Components.stack.caller;
      console.error("TEST-UNEXPECTED-FAIL | " + stack.filename + " | [" +
            stack.name + " : " + stack.lineNumber + "] " + lf.path +
            " does not exist\n");
    }

    return lf;
  }
  catch (ex) {
    console.error(ex.toString(), Components.stack.caller);
  }

  return null;
}

var gTestID = 'gTestID/';
function getApplyDirPath() {
  return gTestID + "/dir.app/";
}

function getApplyDirFile(aRelPath, aAllowNonexistent) {
  let relpath = getApplyDirPath() + (aRelPath ? aRelPath : "");
  return do_get_file(relpath, aAllowNonexistent);
}
var DIR_MACOS = 'DIR_MACOS';
var FILE_APP_BIN = 'FILE_APP_BIN';
var XRE_EXECUTABLE_FILE = 'XREExeF';
var XRE_UPDATE_ROOT_DIR = 'XRE_UPDATE_ROOT_DIR';
let dirProvider = {
    getFile: function AGP_DP_getFile(aProp, aPersistent) {
      aPersistent.value = true;
      switch (aProp) {
        case XRE_EXECUTABLE_FILE:
            return getApplyDirFile(DIR_MACOS + FILE_APP_BIN, true);
          break;
      }
      return null;
    },
    QueryInterface: function(aIID) {
      if (aIID.equals(Ci.nsIDirectoryServiceProvider) ||
          aIID.equals(Ci.nsISupports))
        return this;
      throw Cr.NS_ERROR_NO_INTERFACE;
    }
  };

var ds = Services.dirsvc.QueryInterface(Ci.nsIDirectoryService);
ds.QueryInterface(Ci.nsIProperties).undefine('XREExeF');
console.log(rez)
ds.registerProvider(dirProvider);
Noitidart
  • 35,443
  • 37
  • 154
  • 323
  • Oh FileUtils was throwing that because it throws when file doesnt exist at path. I created at path: `C:\Program Files (x86)\Mozilla Firefox\gTestID\dir.app\DIR_MACOSFILE_APP_BIN` and it stopped throwing. now im praying that this replacement happens early enough to affect all of Firefoxes internals. – Noitidart Feb 06 '15 at 03:00
  • This section on "OS and Application Level" sounds very relavent but I don't understand it. Does anyone understand it and can help me understand? Thx :) https://developer.mozilla.org/en-US/docs/Using_nsIDirectoryService#Defined_Locations – Noitidart Feb 06 '15 at 06:30