author Quentin Headen <>
Thu, 08 Aug 2013 14:55:17 -0400
changeset 17201 d2bb806f7e34f52f8acdccc884f3d05c606494e2
parent 12286 84ac3c71109811da751f0ef2d72108075938f094
child 29315 21ba31e50f44235767d1959b54e9fc7eb7738480
permissions -rw-r--r--
Bug 920801 - Port chat/ changes from Instantbird to comm-central - 6 - Bio 2079 - JS-Yahoo has no protocol icon, r=clokep.

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at

# For test-font-chooser.js we need a few default prefs -- this module does that.

import os
import shutil
import sys

_pref_file_names = {
    "win32": "windows-prefs.js",
    "darwin": "mac-prefs.js",
    "linux2": "linux-prefs.js",

def on_profile_created(profiledir):
    On profile creation, this copies prefs.js from the current folder to
    profile_dir/preferences. This is a somewhat undocumented feature -- anything
    in profile_dir/preferences gets treated as a default pref, which is what we
    want here.
    prefdir = os.path.join(profiledir, "preferences")
    # This needs to be a directory, so if it's a file, raise an exception
    if os.path.isfile(prefdir):
        raise Exception("%s needs to be a directory, but is a file" % prefdir)
    if not os.path.exists(prefdir):
    # The pref file is in the same directory this script is in
    # Fallback to Linux prefs for anything not in the dictionary -- we're
    # assuming that they're other unixes
    preffile = os.path.join(os.path.dirname(__file__),
                            _pref_file_names.get(sys.platform, "linux-prefs.js"))
    shutil.copy(preffile, prefdir)