fune/toolkit/profile/nsIToolkitProfileService.idl
Dave Townsend ce00037e9a Bug 1555319: Normalize the case of the installation path to always get a consistent install hash. r=froydnj
The XRE_EXECUTABLE_FILE directory entry gives us the actual path that the binary
was launched with. On systems where the filesystem is case insensitive this
can be in any case, which ends up being a different install hash. This patch
ensures that we get the correct case for the install path before generating the
hash.

We have the problem of users who are already affected by this issue. This patch
also leaves the old hash available, if no default profile is found for the
correct hash then we also check for a profile for the old hash, if so we use it
for this hash going forwards. Testing this is kind of a pain, we have to add a
way to override the old hash that we will check against. I'm not totally happy with
how it is done here but not sure there is anything better.

This also adds a test that calling xpcshell with differing cases returns the
same install hash.

Differential Revision: https://phabricator.services.mozilla.com/D34774

--HG--
extra : source : 1a595782402c95aa1f7b26e892e38a500ebb9a77
extra : amend_source : 749b03b93cd4687a83cd696a5cbedc9f2ebc69fc
extra : histedit_source : 459eae02e0e953d5108fd6d7609d9e640eeb695e%2C9fdaaec17723a5e1e7d277d08cd41d16da99437f
2019-06-12 10:48:09 -07:00

153 lines
5.6 KiB
Text

/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* 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 http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
interface nsISimpleEnumerator;
interface nsIFile;
interface nsIToolkitProfile;
interface nsIProfileLock;
[scriptable, builtinclass, uuid(1947899b-f369-48fa-89da-f7c37bb1e6bc)]
interface nsIToolkitProfileService : nsISupports
{
/**
* Tests whether the profile lists on disk have changed since they were
* loaded. When this is true attempts to flush changes to disk will fail.
*/
[infallible] readonly attribute boolean isListOutdated;
/**
* When a downgrade is detected UI is presented to the user to ask how to
* proceed. These flags are used to pass some information to the UI.
*/
cenum downgradeUIFlags: 8 {
hasSync = 1,
};
/**
* When a downgrade is detected UI is presented to the user to ask how to
* proceed. These are the possible options the user can choose.
*/
cenum downgradeUIChoice: 8 {
quit = 0,
createNewProfile = 1,
};
cenum profileManagerResult: 8 {
exit = 0,
launchWithProfile = 1,
restart = 2,
};
attribute boolean startWithLastProfile;
readonly attribute nsISimpleEnumerator /*nsIToolkitProfile*/ profiles;
/**
* The profile currently in use if it is a named profile. This will return
* null if the current profile path doesn't match a profile in the database.
*/
readonly attribute nsIToolkitProfile currentProfile;
/**
* The default profile for this build.
* On startup this is the profile selected unless overridden by command line
* arguments or environment variables. Setting this will change the profile
* used by default the next time the application is started.
* Attempting to change the default may throw an exception on builds that do
* not support changing the default profile, such as developer edition.
*/
attribute nsIToolkitProfile defaultProfile;
/**
* True if during startup a new profile was created for this install instead
* of using the profile that was the default for older versions.
*/
readonly attribute boolean createdAlternateProfile;
/**
* Selects or creates a profile to use based on the profiles database, any
* environment variables and any command line arguments. Will not create
* a profile if aIsResetting is true. The profile is selected based on this
* order of preference:
* * Environment variables (set when restarting the application).
* * --profile command line argument.
* * --createprofile command line argument (this also causes the app to exit).
* * -p command line argument.
* * A new profile created if this is the first run of the application.
* * The default profile.
* aRootDir and aLocalDir are set to the data and local directories for the
* profile data. If a profile from the database was selected it will be
* returned in aProfile.
* This returns true if a new profile was created.
* This method is primarily for testing. It can be called only once.
*/
bool selectStartupProfile(in Array<ACString> aArgv,
in boolean aIsResetting, in AUTF8String aUpdateChannel,
in AUTF8String aLegacyInstallHash,
out nsIFile aRootDir, out nsIFile aLocalDir,
out nsIToolkitProfile aProfile);
/**
* Get a profile by name. This is mainly for use by the -P
* commandline flag.
*
* @param aName The profile name to find.
*/
nsIToolkitProfile getProfileByName(in AUTF8String aName);
/**
* Create a new profile.
*
* The profile temporary directory will be chosen based on where the
* profile directory is located.
*
* If a profile with the given name already exists it will be returned
* instead of creating a new profile.
*
* @param aRootDir
* The profile directory. May be null, in which case a suitable
* default will be chosen based on the profile name.
* @param aName
* The profile name.
*/
nsIToolkitProfile createProfile(in nsIFile aRootDir,
in AUTF8String aName);
/**
* Create a new profile with a unique name.
*
* As above however the name given will be altered to make it a unique
* profile name.
*
* @param aRootDir
* The profile directory. May be null, in which case a suitable
* default will be chosen based on the profile name.
* @param aNamePrefix
* The prefix to use for the profile name. If unused this will be
* used as the profile name otherwise additional characters will be
* added to make the name unique.
*/
nsIToolkitProfile createUniqueProfile(in nsIFile aRootDir,
in AUTF8String aNamePrefix);
/**
* Returns the number of profiles.
* @return the number of profiles.
*/
readonly attribute unsigned long profileCount;
/**
* Flush the profiles list file. This will fail with
* NS_ERROR_DATABASE_CHANGED if the files on disk have changed since the
* profiles were loaded.
*/
void flush();
};
%{C++
#define NS_PROFILESERVICE_CONTRACTID "@mozilla.org/toolkit/profile-service;1"
%}