2002-08-21 14:25:54 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2002-08-21 14:25:54 +04:00
|
|
|
|
|
|
|
#ifndef _nsXREDirProvider_h__
|
|
|
|
#define _nsXREDirProvider_h__
|
|
|
|
|
|
|
|
#include "nsIDirectoryService.h"
|
2004-06-18 01:23:51 +04:00
|
|
|
#include "nsIProfileMigrator.h"
|
2012-06-06 06:08:30 +04:00
|
|
|
#include "nsIFile.h"
|
2018-09-24 17:55:37 +03:00
|
|
|
#include "nsIXREDirProvider.h"
|
2002-08-21 14:25:54 +04:00
|
|
|
|
2007-09-04 16:55:29 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsCOMArray.h"
|
2012-06-20 07:49:05 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-09-04 16:55:29 +04:00
|
|
|
|
2018-09-24 17:55:37 +03:00
|
|
|
// {5573967d-f6cf-4c63-8e0e-9ac06e04d62b}
|
|
|
|
#define NS_XREDIRPROVIDER_CID \
|
2018-11-30 13:46:48 +03:00
|
|
|
{ \
|
2018-09-24 17:55:37 +03:00
|
|
|
0x5573967d, 0xf6cf, 0x4c63, { \
|
|
|
|
0x8e, 0x0e, 0x9a, 0xc0, 0x6e, 0x04, 0xd6, 0x2b \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
#define NS_XREDIRPROVIDER_CONTRACTID "@mozilla.org/xre/directory-provider;1"
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsXREDirProvider final : public nsIDirectoryServiceProvider2,
|
2018-09-24 17:55:37 +03:00
|
|
|
public nsIXREDirProvider,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsIProfileStartup {
|
2002-08-21 14:25:54 +04:00
|
|
|
public:
|
2004-06-18 01:23:51 +04:00
|
|
|
// we use a custom isupports implementation (no refcount)
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
|
|
|
|
NS_IMETHOD_(MozExternalRefCountType) AddRef(void) override;
|
|
|
|
NS_IMETHOD_(MozExternalRefCountType) Release(void) override;
|
2002-08-21 14:25:54 +04:00
|
|
|
|
2002-09-29 10:51:54 +04:00
|
|
|
NS_DECL_NSIDIRECTORYSERVICEPROVIDER
|
2004-06-18 01:23:51 +04:00
|
|
|
NS_DECL_NSIDIRECTORYSERVICEPROVIDER2
|
2018-09-24 17:55:37 +03:00
|
|
|
NS_DECL_NSIXREDIRPROVIDER
|
2004-06-18 01:23:51 +04:00
|
|
|
NS_DECL_NSIPROFILESTARTUP
|
|
|
|
|
|
|
|
nsXREDirProvider();
|
2006-01-12 18:29:10 +03:00
|
|
|
|
|
|
|
// if aXULAppDir is null, use gArgv[0]
|
|
|
|
nsresult Initialize(nsIFile* aXULAppDir, nsIFile* aGREDir,
|
2012-07-30 18:20:58 +04:00
|
|
|
nsIDirectoryServiceProvider* aAppProvider = nullptr);
|
2004-06-18 01:23:51 +04:00
|
|
|
~nsXREDirProvider();
|
|
|
|
|
2018-09-24 17:55:37 +03:00
|
|
|
static already_AddRefed<nsXREDirProvider> GetSingleton();
|
2012-05-22 18:50:04 +04:00
|
|
|
|
2017-11-08 19:36:51 +03:00
|
|
|
nsresult GetUserProfilesRootDir(nsIFile** aResult);
|
|
|
|
nsresult GetUserProfilesLocalDir(nsIFile** aResult);
|
2012-05-24 18:29:52 +04:00
|
|
|
|
2004-06-18 01:23:51 +04:00
|
|
|
// We only set the profile dir, we don't ensure that it exists;
|
|
|
|
// that is the responsibility of the toolkit profile service.
|
|
|
|
// We also don't fire profile-changed notifications... that is
|
|
|
|
// the responsibility of the apprunner.
|
2005-04-26 04:37:23 +04:00
|
|
|
nsresult SetProfile(nsIFile* aProfileDir, nsIFile* aProfileLocalDir);
|
2004-06-18 01:23:51 +04:00
|
|
|
|
2017-09-14 21:35:01 +03:00
|
|
|
void InitializeUserPrefs();
|
|
|
|
|
2004-06-18 01:23:51 +04:00
|
|
|
void DoShutdown();
|
|
|
|
|
2012-06-06 06:08:30 +04:00
|
|
|
static nsresult GetUserAppDataDirectory(nsIFile** aFile) {
|
2017-11-08 19:36:51 +03:00
|
|
|
return GetUserDataDirectory(aFile, false);
|
2005-04-26 04:37:23 +04:00
|
|
|
}
|
2012-06-06 06:08:30 +04:00
|
|
|
static nsresult GetUserLocalDataDirectory(nsIFile** aFile) {
|
2017-11-08 19:36:51 +03:00
|
|
|
return GetUserDataDirectory(aFile, true);
|
2005-04-26 04:37:23 +04:00
|
|
|
}
|
2004-06-18 01:23:51 +04:00
|
|
|
|
2017-11-08 19:36:51 +03:00
|
|
|
// GetUserDataDirectory gets the profile path from gAppData.
|
|
|
|
static nsresult GetUserDataDirectory(nsIFile** aFile, bool aLocal);
|
2012-05-24 18:29:52 +04:00
|
|
|
|
2004-06-18 01:23:51 +04:00
|
|
|
/* make sure you clone it, if you need to do stuff to it */
|
2005-12-23 17:51:39 +03:00
|
|
|
nsIFile* GetGREDir() { return mGREDir; }
|
2014-10-04 00:48:49 +04:00
|
|
|
nsIFile* GetGREBinDir() { return mGREBinDir; }
|
2007-09-26 22:35:21 +04:00
|
|
|
nsIFile* GetAppDir() {
|
2005-12-23 17:51:39 +03:00
|
|
|
if (mXULAppDir) return mXULAppDir;
|
|
|
|
return mGREDir;
|
|
|
|
}
|
2002-08-21 14:25:54 +04:00
|
|
|
|
2007-04-20 19:22:17 +04:00
|
|
|
/**
|
|
|
|
* Get the directory under which update directory is created.
|
|
|
|
* This method may be called before XPCOM is started. aResult
|
|
|
|
* is a clone, it may be modified.
|
Bug 1458314 - Move the update directory to an installation specific location r=rstrong
This change applies to Windows only.
Firefox will need to migrate the directory from the old location to the new location. This will be done only once by setting the pref `app.update.migrated.updateDir2.<install path hash>` to `true` once migration has completed.
Note: The pref name app.update.migrated.updateDir has already been used, thus the '2' suffix. It can be found in ESR24.
This also removes the old handling fallback for generating the update directory path. Since xulrunner is no longer supported, this should no longer be needed. If neither the vendor nor app name are defined, it falls back to the literal string "Mozilla".
The code to generate the update directory path and the installation hash have been moved to the updatecommon library. This will allow those functions to be used in Firefox, the Mozilla Maintenance Service, the Mozilla Maintenance Service Installer, and TestAUSHelper.
Additionally, the function that generates the update directory path now has extra functionality. It creates the update directory, sets the permissions on it and, optionally, recursively sets the permissions on everything within.
This patch adds functionality that allows Firefox to set permissions on the new update directory on write failure. It attempts to set the permissions itself and, if that fails and the maintenance service is enabled, it calls into the maintenance service to try from there. If a write fails and the permissions cannot be fixed, the user is prompted to reinstall.
Differential Revision: https://phabricator.services.mozilla.com/D4249
--HG--
rename : toolkit/mozapps/update/updater/win_dirent.cpp => toolkit/mozapps/update/common/win_dirent.cpp
rename : toolkit/mozapps/update/tests/unit_aus_update/cleanupSuccessLogMove.js => toolkit/mozapps/update/tests/unit_aus_update/updateDirectoryMigrate.js
extra : moz-landing-system : lando
2018-10-24 00:41:04 +03:00
|
|
|
*
|
|
|
|
* If aGetOldLocation is true, this function will return the location of
|
|
|
|
* the update directory before it was moved from the user profile directory
|
|
|
|
* to a per-installation directory. This functionality is only meant to be
|
|
|
|
* used for migration of the update directory to the new location. It is only
|
|
|
|
* valid to request the old update location on Windows, since that is the only
|
|
|
|
* platform on which the update directory was migrated.
|
2007-04-20 19:22:17 +04:00
|
|
|
*/
|
Bug 1458314 - Move the update directory to an installation specific location r=rstrong
This change applies to Windows only.
Firefox will need to migrate the directory from the old location to the new location. This will be done only once by setting the pref `app.update.migrated.updateDir2.<install path hash>` to `true` once migration has completed.
Note: The pref name app.update.migrated.updateDir has already been used, thus the '2' suffix. It can be found in ESR24.
This also removes the old handling fallback for generating the update directory path. Since xulrunner is no longer supported, this should no longer be needed. If neither the vendor nor app name are defined, it falls back to the literal string "Mozilla".
The code to generate the update directory path and the installation hash have been moved to the updatecommon library. This will allow those functions to be used in Firefox, the Mozilla Maintenance Service, the Mozilla Maintenance Service Installer, and TestAUSHelper.
Additionally, the function that generates the update directory path now has extra functionality. It creates the update directory, sets the permissions on it and, optionally, recursively sets the permissions on everything within.
This patch adds functionality that allows Firefox to set permissions on the new update directory on write failure. It attempts to set the permissions itself and, if that fails and the maintenance service is enabled, it calls into the maintenance service to try from there. If a write fails and the permissions cannot be fixed, the user is prompted to reinstall.
Differential Revision: https://phabricator.services.mozilla.com/D4249
--HG--
rename : toolkit/mozapps/update/updater/win_dirent.cpp => toolkit/mozapps/update/common/win_dirent.cpp
rename : toolkit/mozapps/update/tests/unit_aus_update/cleanupSuccessLogMove.js => toolkit/mozapps/update/tests/unit_aus_update/updateDirectoryMigrate.js
extra : moz-landing-system : lando
2018-10-24 00:41:04 +03:00
|
|
|
nsresult GetUpdateRootDir(nsIFile** aResult, bool aGetOldLocation = false);
|
2007-04-20 19:22:17 +04:00
|
|
|
|
2006-01-12 18:29:10 +03:00
|
|
|
/**
|
|
|
|
* Get the profile startup directory as determined by this class or by
|
|
|
|
* mAppProvider. This method may be called before XPCOM is started. aResult
|
|
|
|
* is a clone, it may be modified.
|
|
|
|
*/
|
2007-04-20 19:22:17 +04:00
|
|
|
nsresult GetProfileStartupDir(nsIFile** aResult);
|
2006-01-12 18:29:10 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the profile directory as determined by this class or by an
|
|
|
|
* embedder-provided XPCOM directory provider. Only call this method
|
|
|
|
* when XPCOM is initialized! aResult is a clone, it may be modified.
|
|
|
|
*/
|
|
|
|
nsresult GetProfileDir(nsIFile** aResult);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2004-06-18 01:23:51 +04:00
|
|
|
protected:
|
2006-01-12 18:29:10 +03:00
|
|
|
nsresult GetFilesInternal(const char* aProperty,
|
|
|
|
nsISimpleEnumerator** aResult);
|
2012-06-06 06:08:30 +04:00
|
|
|
static nsresult GetUserDataDirectoryHome(nsIFile** aFile, bool aLocal);
|
|
|
|
static nsresult GetSysUserExtensionsDirectory(nsIFile** aFile);
|
2017-10-04 20:43:49 +03:00
|
|
|
static nsresult GetSysUserExtensionsDevDirectory(nsIFile** aFile);
|
2008-03-07 04:58:18 +03:00
|
|
|
#if defined(XP_UNIX) || defined(XP_MACOSX)
|
2012-06-06 06:08:30 +04:00
|
|
|
static nsresult GetSystemExtensionsDirectory(nsIFile** aFile);
|
2008-03-07 04:58:18 +03:00
|
|
|
#endif
|
2004-06-18 01:23:51 +04:00
|
|
|
static nsresult EnsureDirectoryExists(nsIFile* aDirectory);
|
2002-08-21 14:25:54 +04:00
|
|
|
|
2007-09-26 22:35:21 +04:00
|
|
|
// Determine the profile path within the UAppData directory. This is different
|
|
|
|
// on every major platform.
|
2017-11-08 19:36:51 +03:00
|
|
|
static nsresult AppendProfilePath(nsIFile* aFile, bool aLocal);
|
2007-09-26 22:35:21 +04:00
|
|
|
|
2008-01-15 18:13:59 +03:00
|
|
|
static nsresult AppendSysUserExtensionPath(nsIFile* aFile);
|
2017-10-04 20:43:49 +03:00
|
|
|
static nsresult AppendSysUserExtensionsDevPath(nsIFile* aFile);
|
2008-01-15 18:13:59 +03:00
|
|
|
|
2007-09-26 22:35:21 +04:00
|
|
|
// Internal helper that splits a path into components using the '/' and '\\'
|
|
|
|
// delimiters.
|
|
|
|
static inline nsresult AppendProfileString(nsIFile* aFile, const char* aPath);
|
|
|
|
|
2018-01-09 18:29:40 +03:00
|
|
|
#if defined(MOZ_CONTENT_SANDBOX)
|
2016-03-07 22:26:35 +03:00
|
|
|
// Load the temp directory for sandboxed content processes
|
|
|
|
nsresult LoadContentProcessTempDir();
|
|
|
|
#endif
|
2018-10-13 01:36:22 +03:00
|
|
|
#if defined(MOZ_SANDBOX)
|
|
|
|
nsresult LoadPluginProcessTempDir();
|
|
|
|
#endif
|
2016-03-07 22:26:35 +03:00
|
|
|
|
2007-09-04 16:55:29 +04:00
|
|
|
void Append(nsIFile* aDirectory);
|
|
|
|
|
2006-01-12 18:29:10 +03:00
|
|
|
nsCOMPtr<nsIDirectoryServiceProvider> mAppProvider;
|
2014-09-29 22:51:04 +04:00
|
|
|
// On OSX, mGREDir points to .app/Contents/Resources
|
2012-06-06 06:08:30 +04:00
|
|
|
nsCOMPtr<nsIFile> mGREDir;
|
2014-10-04 00:48:49 +04:00
|
|
|
// On OSX, mGREBinDir points to .app/Contents/MacOS
|
|
|
|
nsCOMPtr<nsIFile> mGREBinDir;
|
2014-09-29 22:51:04 +04:00
|
|
|
// On OSX, mXULAppDir points to .app/Contents/Resources/browser
|
2004-09-07 22:59:07 +04:00
|
|
|
nsCOMPtr<nsIFile> mXULAppDir;
|
2004-06-18 01:23:51 +04:00
|
|
|
nsCOMPtr<nsIFile> mProfileDir;
|
2005-04-26 04:37:23 +04:00
|
|
|
nsCOMPtr<nsIFile> mProfileLocalDir;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mProfileNotified;
|
2017-09-14 21:35:01 +03:00
|
|
|
bool mPrefsInitialized = false;
|
2018-01-09 18:29:40 +03:00
|
|
|
#if defined(MOZ_CONTENT_SANDBOX)
|
2016-03-07 22:26:35 +03:00
|
|
|
nsCOMPtr<nsIFile> mContentTempDir;
|
2016-07-06 00:48:25 +03:00
|
|
|
nsCOMPtr<nsIFile> mContentProcessSandboxTempDir;
|
2018-10-13 01:36:22 +03:00
|
|
|
#endif
|
|
|
|
#if defined(MOZ_SANDBOX)
|
|
|
|
nsCOMPtr<nsIFile> mPluginTempDir;
|
|
|
|
nsCOMPtr<nsIFile> mPluginProcessSandboxTempDir;
|
2016-03-07 22:26:35 +03:00
|
|
|
#endif
|
2007-09-04 16:55:29 +04:00
|
|
|
nsCOMArray<nsIFile> mAppBundleDirectories;
|
2002-08-21 14:25:54 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|